mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-11 06:24:56 -05:00
* upgraded storybook dependencies * upgraded web dependencies * updated timezone selector * upgrade chakra in metamaps * upgraded react-dnd in metamaps * upgraded framer-motion * fixed types in metamaps * upgraded eslint * upgraded lerna, husky and graphql * upgraded node version * removed metamaps package * fixed all eslint issues * ran yarn format to prettier format all files * updated lint-staged & husky scripts * add executable perms to pre-push scripts * updated yarn.lock * fixed eslint and moved chakra icons to ds * fixed emotion errors * removed extra useContext * update yarn.lock * upgraded more packages * removed unnecessary .huskyrc.json * lint fix
97 lines
2.3 KiB
TypeScript
97 lines
2.3 KiB
TypeScript
import {
|
|
MetaTag,
|
|
MetaTheme,
|
|
SelectSearch,
|
|
selectStyles,
|
|
Tooltip,
|
|
Wrap,
|
|
WrapItem,
|
|
} from '@metafam/ds';
|
|
import { Skill, SkillCategory_Enum } from 'graphql/autogen/types';
|
|
import { SkillColors } from 'graphql/types';
|
|
import React from 'react';
|
|
import { CategoryOption, SkillOption } from 'utils/skillHelpers';
|
|
|
|
export type SetupSkillsProps = {
|
|
skillChoices: Array<CategoryOption>;
|
|
skills: Array<SkillOption>;
|
|
setSkills: React.Dispatch<React.SetStateAction<Array<SkillOption>>>;
|
|
placeHolder: string;
|
|
id?: string;
|
|
};
|
|
|
|
export const SkillsSelect: React.FC<SetupSkillsProps> = ({
|
|
skillChoices,
|
|
skills,
|
|
setSkills,
|
|
placeHolder,
|
|
id,
|
|
}) => {
|
|
const styles: typeof selectStyles = {
|
|
...selectStyles,
|
|
multiValue: (s, { data }) => ({
|
|
...s,
|
|
background: SkillColors[data.category as SkillCategory_Enum],
|
|
color: MetaTheme.colors.white,
|
|
}),
|
|
multiValueLabel: (s, { data }) => ({
|
|
...s,
|
|
background: SkillColors[data.category as SkillCategory_Enum],
|
|
color: MetaTheme.colors.white,
|
|
}),
|
|
groupHeading: (s, { children }) => ({
|
|
...s,
|
|
...(selectStyles.groupHeading &&
|
|
selectStyles.groupHeading(s, { children })),
|
|
background: SkillColors[children as SkillCategory_Enum],
|
|
}),
|
|
};
|
|
|
|
return (
|
|
<SelectSearch
|
|
isMulti
|
|
styles={styles}
|
|
value={skills}
|
|
onChange={(value) => setSkills(value as Array<SkillOption>)}
|
|
options={skillChoices}
|
|
autoFocus
|
|
closeMenuOnSelect={false}
|
|
placeholder={placeHolder}
|
|
id={`skills-select-container-${id || ''}`}
|
|
inputId={`skills-select-input-${id || ''}`}
|
|
/>
|
|
);
|
|
};
|
|
|
|
interface SkillsProps {
|
|
skills: Skill[];
|
|
maxSkills?: number;
|
|
}
|
|
export const SkillsTags: React.FC<SkillsProps> = ({
|
|
maxSkills = 4,
|
|
skills,
|
|
}) => (
|
|
<Wrap>
|
|
{skills.slice(0, maxSkills).map((skill) => (
|
|
<WrapItem key={skill.id}>
|
|
<Tooltip label={skill.category}>
|
|
<MetaTag
|
|
size="md"
|
|
fontWeight="normal"
|
|
backgroundColor={SkillColors[skill.category]}
|
|
>
|
|
{skill.name}
|
|
</MetaTag>
|
|
</Tooltip>
|
|
</WrapItem>
|
|
))}
|
|
{skills.length > maxSkills && (
|
|
<WrapItem>
|
|
<MetaTag size="md" fontWeight="normal">
|
|
{`+${skills.length - maxSkills}`}
|
|
</MetaTag>
|
|
</WrapItem>
|
|
)}
|
|
</Wrap>
|
|
);
|