Skip to content

Commit

Permalink
chore(react-select): Copy updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Aug 5, 2023
1 parent a2989d3 commit abf46cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions packages/react/src/Settings/FilterDropdowns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import {
activityTypeStyles,
getSelectOptions,
LanguageOption,
languagesStyles,
languageStyles,
OrgOption,
orgStyles,
type IOptionType,
type ISelectOption,
type OptionType,
type SelectOption,
type StyleOption,
} from "../react-select";

function CustomSelect<
Option extends IOptionType,
Option extends OptionType,
IsMulti extends boolean = true,
Group extends GroupBase<Option> = GroupBase<Option>,
>(props: Props<Option, IsMulti, Group>) {
Expand Down Expand Up @@ -83,7 +83,7 @@ const EllipsisLabel: React.FC<{

const MAX_ITEMS_CUTOFF_COUNT = 3;

export const MultiValue: React.FC<MultiValueProps<IOptionType>> = ({
export const MultiValue: React.FC<MultiValueProps<OptionType>> = ({
index,
getValue,
...props
Expand Down Expand Up @@ -186,14 +186,14 @@ export const FilterDropdowns: React.FC = () => {
Object.values(cvState.languages ?? {}).map(({ id }) => id as string),
)}
isMulti
onChange={(value: PropsValue<IOptionType>): void => {
onChange={(value: PropsValue<OptionType>): void => {
cvState.setLanguages(
(value as IOptionType[]).map(({ value: v }) => v),
(value as OptionType[]).map(({ value: v }) => v),
);
}}
className="react-select"
placeholder="Language"
styles={{ ...colourStyles, ...languagesStyles }}
styles={{ ...colourStyles, ...languageStyles }}
components={{ Option: LanguageOption, MultiValue: MultiValueCount }}
hideSelectedOptions={false}
closeMenuOnSelect={false}
Expand All @@ -207,12 +207,12 @@ export const FilterDropdowns: React.FC = () => {
cvState.activityTypes.map((a) => ({
label: a.name,
value: a.id,
})) as ISelectOption
})) as SelectOption
}
isMulti={true}
onChange={(value: PropsValue<IOptionType>): void => {
onChange={(value: PropsValue<OptionType>): void => {
cvState.setActivityTypes(
(value as IOptionType[]).map(({ value: v }) => v),
(value as OptionType[]).map(({ value: v }) => v),
);
}}
className="react-select"
Expand All @@ -235,11 +235,11 @@ export const FilterDropdowns: React.FC = () => {
cvState.orgs.map((org) => ({
label: org.name,
value: org.id?.toString() ?? org.id,
})) as ISelectOption
})) as SelectOption
}
isMulti={true}
onChange={(value: PropsValue<IOptionType>): void => {
cvState.setOrgs((value as IOptionType[]).map(({ value: v }) => v));
onChange={(value: PropsValue<OptionType>): void => {
cvState.setOrgs((value as OptionType[]).map(({ value: v }) => v));
}}
className="react-select"
placeholder="Organization and projects"
Expand Down
12 changes: 6 additions & 6 deletions packages/react/src/react-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ import { ActivityTypeEmojiMap } from "@tony/cv-data/constants";
import { useMst } from "./mobx";
import { LanguageTag, OrgTypeTag } from "./Tag";

export interface IOptionType {
export interface OptionType {
readonly label: string;
readonly value: string;
}
export interface StyleOption extends IOptionType {
export interface StyleOption extends OptionType {
readonly color: string;
readonly isFixed?: boolean;
readonly isDisabled?: boolean;
}
export type ISelectOption = Options<IOptionType>;
export type SelectOption = Options<OptionType>;

export const getSelectOptions = (items: string[]): ISelectOption =>
export const getSelectOptions = (items: string[]): SelectOption =>
items.map((actorName) => ({
label: actorName,
value: actorName,
})) as ISelectOption;
})) as SelectOption;

export const orgStyles: StylesConfig<StyleOption, true> = {
option: (styles: CSSObject, _props) => {
Expand Down Expand Up @@ -119,7 +119,7 @@ export const LanguageOption: React.FC<OptionProps<StyleOption, true>> = ({
);
};

export const languagesStyles: StylesConfig<StyleOption, true> = {
export const languageStyles: StylesConfig<StyleOption, true> = {
option: (styles: CSSObject, { data, isFocused, isSelected }) => {
const cvState = useMst();
const language = cvState.languages.find(({ id }) => id === data.value);
Expand Down

0 comments on commit abf46cd

Please sign in to comment.