diff --git a/frontend/src/components/select.tsx b/frontend/src/components/select.tsx new file mode 100644 index 0000000..9bd8c74 --- /dev/null +++ b/frontend/src/components/select.tsx @@ -0,0 +1,59 @@ +import { MdArrowDropDown } from "react-icons/md"; +import { createRef } from "react"; + +export default function Select({ + current, + values, + onSelected, +}: { + current?: number; + values: string[]; + onSelected: (value: number) => void; +}) { + const menuRef = createRef(); + + if (!values || values.length === 0) { + return <>; + } + if (current && (current < 0 || current >= values.length)) { + current = undefined; + } + + return ( +
+
+
+ + {current != null && values[current]} + + + +
+
+ +
+ ); +} diff --git a/frontend/src/pages/home_page.tsx b/frontend/src/pages/home_page.tsx index bbe6e97..59350d6 100644 --- a/frontend/src/pages/home_page.tsx +++ b/frontend/src/pages/home_page.tsx @@ -5,6 +5,7 @@ import { app } from "../app.ts"; import { RSort } from "../network/models.ts"; import { useTranslation } from "react-i18next"; import { useAppContext } from "../components/AppContext.tsx"; +import Select from "../components/select.tsx"; export default function HomePage() { useEffect(() => { @@ -30,23 +31,24 @@ export default function HomePage() { return ( <> -
- { + setOrder(index); + if (appContext) { + appContext.set("home_page_order", index); + } }} - > - - - - - - - - + />