Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
zoul committed Sep 18, 2024
1 parent df49fac commit cd22a92
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 50 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.md
*.tf
*.json
62 changes: 13 additions & 49 deletions components/profile/SkillSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Select from "react-select";
import Select, { createFilter } from "react-select";

import defaultTags from "~/src/tags.json";

type Option = {
label: string;
value: string;
name: string;
searchSynonyms?: string;
};

export type Props = {
Expand All @@ -19,65 +21,27 @@ export const SkillSelect = ({
value,
}: Props) => (
<Select
options={values.map((v) => ({ label: v, value: v }))}
options={defaultTags}
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.name}
value={decodeSelection(value)}
onChange={(selection) => onChange(encodeSelection(selection))}
placeholder="copywriting, TypeScript, právo, dotace, operations, …"
noOptionsMessage={() => "Žádný tag neodpovídá"}
filterOption={createFilter({
stringify: (option) => `${option.label}, ${option.data.searchSynonyms}`,
})}
className={className}
isDisabled={disabled}
isMulti
/>
);

const encodeSelection = (d: readonly Option[]) =>
d.map((d) => d.label).join(" ");
d.map((d) => d.name).join(" ");

const decodeSelection = (s: string): Option[] =>
s
.split(/ /)
.filter((s) => s !== "")
.map((name) => ({ label: name, value: name }));

const values = [
"#audio",
"#backend",
"#cloud",
"#copywriting",
"#css",
"#databáze",
"#design",
"#devops",
"#eventy",
"#finance",
"#frontend",
"#fundraising",
"#hr",
"#html",
"#java",
"#javascript",
"#junior",
"#komunity",
"#kotlin",
"#marketing",
"#medior",
"#mentor",
"#mobile",
"#node",
"#php",
"#pr",
"#product-owner",
"#projektové-řízení",
"#python",
"#react",
"#scrum",
"#senior",
"#strategie",
"#testování",
"#typescript",
"#ui",
"#ux",
"#video",
"#výzkum",
"#wordpress",
];
.map((name) => defaultTags.find((tag) => tag.name === name) ?? { name });
1 change: 1 addition & 0 deletions src/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions src/tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import defaultTags from "./tags.json";

const x = defaultTags;

0 comments on commit cd22a92

Please sign in to comment.