From 95799029ea5e47fff7862146a24daeedf22288e4 Mon Sep 17 00:00:00 2001 From: NightKnight Date: Fri, 17 Feb 2023 18:17:54 +0200 Subject: [PATCH] feat: add dropdown for topics in Explore (#877) Fixes #533 --- .../atoms/LanguagePill/LanguagePill.tsx | 4 +- components/atoms/Radio/radio.tsx | 4 +- components/atoms/Selector/selector.tsx | 36 ++++++++ .../FilterCardSelect/filter-card-select.tsx | 86 +++++++++++++++++++ .../molecules/FilterHeader/filter-header.tsx | 14 ++- lib/utils/getTopicOptions.ts | 7 ++ ...ase-naming.ts => topic-name-formatting.ts} | 6 +- stories/atoms/selector.stories.tsx | 20 +++++ .../molecules/filter-card-select.stories.tsx | 21 +++++ ....test.ts => topic-name-formatting.test.ts} | 6 +- 10 files changed, 192 insertions(+), 12 deletions(-) create mode 100644 components/atoms/Selector/selector.tsx create mode 100644 components/molecules/FilterCardSelect/filter-card-select.tsx create mode 100644 lib/utils/getTopicOptions.ts rename lib/utils/{check-camelcase-naming.ts => topic-name-formatting.ts} (59%) create mode 100644 stories/atoms/selector.stories.tsx create mode 100644 stories/molecules/filter-card-select.stories.tsx rename tests/lib/utils/{check-camelcase-naming.test.ts => topic-name-formatting.test.ts} (66%) diff --git a/components/atoms/LanguagePill/LanguagePill.tsx b/components/atoms/LanguagePill/LanguagePill.tsx index f28e90ed9d..4ce0081d90 100644 --- a/components/atoms/LanguagePill/LanguagePill.tsx +++ b/components/atoms/LanguagePill/LanguagePill.tsx @@ -7,7 +7,7 @@ import PythonIcon from "/img/icons/🐍.svg"; import AIIcon from "/img/icons/🤖.svg"; import MLIcon from "/img/icons/🧠.svg"; import RustIcon from "/img/icons/🦀.svg"; -import checkCamelCaseNaming from "lib/utils/check-camelcase-naming"; +import topicNameFormatting from "lib/utils/topic-name-formatting"; interface LanguagePillProps { topic: "react" | "javascript" | "python" | "ML" | "AI" | "rust" | string; @@ -36,7 +36,7 @@ const LanguagePill = ({ topic, classNames, onClick }: LanguagePillProps) => { }`} > {topic} - {checkCamelCaseNaming(topic)} + {topicNameFormatting(topic)} ); }; diff --git a/components/atoms/Radio/radio.tsx b/components/atoms/Radio/radio.tsx index 3a4660e19d..9c5d998bb5 100644 --- a/components/atoms/Radio/radio.tsx +++ b/components/atoms/Radio/radio.tsx @@ -8,7 +8,7 @@ interface RadioProps { checked?: boolean; onClick?: () => void; value?: string; - withLabel: string; + withLabel?: string; css?: string; } @@ -32,7 +32,7 @@ const Radio = ({ css, withLabel, id, children, value, checked = false, onClick } onChange={onClick} id={id} /> -