Skip to content

Commit cc528b5

Browse files
committed
needs fwd for storybook
1 parent aa8e5ff commit cc528b5

File tree

1 file changed

+40
-1
lines changed
  • apps/frontend/ui/src/navigation/partials/OptionTrace

1 file changed

+40
-1
lines changed

apps/frontend/ui/src/navigation/partials/OptionTrace/func.tsx

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from "react";
12
import type { JSX } from "react";
23

34
import { useComboboxFilter, useId } from "@lib-hooks";
@@ -7,10 +8,35 @@ import type { TComboboxProps } from "@lib-components";
78
import { OptionLayoutTemplate } from "../../templates";
89
import useClasses from "./styles";
910

11+
const options = [
12+
{ children: "Alligator", value: "Alligator" },
13+
{ children: "Bee", value: "Bee" },
14+
{ children: "Bird", value: "Bird" },
15+
{ children: "Cheetah", disabled: true, value: "Cheetah" },
16+
{ children: "Dog", value: "Dog" },
17+
{ children: "Dolphin", value: "Dolphin" },
18+
{ children: "Ferret", value: "Ferret" },
19+
{ children: "Firefly", value: "Firefly" },
20+
{ children: "Fish", value: "Fish" },
21+
{ children: "Goat", value: "Goat" },
22+
{ children: "Horse", value: "Horse" },
23+
{ children: "Lion", value: "Lion" },
24+
];
25+
1026
type TProps = {};
1127

1228
export default function OptionTrace({}: TProps): JSX.Element {
1329
const classes = useClasses();
30+
const comboId = useId();
31+
const [query, setQuery] = useState<string>("");
32+
33+
const children = useComboboxFilter(query, options, {
34+
noOptionsMessage: "No animals match your search.",
35+
});
36+
const onOptionSelect: TComboboxProps["onOptionSelect"] = (e, data) => {
37+
setQuery(data.optionText ?? "");
38+
};
39+
1440
return (
1541
<OptionLayoutTemplate
1642
header="Trace a Word"
@@ -19,6 +45,19 @@ export default function OptionTrace({}: TProps): JSX.Element {
1945
isLoading={false}
2046
disableClick={false}
2147
buttonLabel="Construct trace tree"
22-
></OptionLayoutTemplate>
48+
>
49+
<Flex direction="column" gap="SNudge">
50+
<label id={comboId}>Search</label>
51+
<Combobox
52+
onOptionSelect={onOptionSelect}
53+
aria-labelledby={comboId}
54+
placeholder="Select a known word from the dictionary"
55+
onChange={(ev) => setQuery(ev.target.value)}
56+
value={query}
57+
>
58+
{children}
59+
</Combobox>
60+
</Flex>
61+
</OptionLayoutTemplate>
2362
);
2463
}

0 commit comments

Comments
 (0)