diff --git a/pkgs/clan-app/ui/src/components/Search/TagSelect.module.css b/pkgs/clan-app/ui/src/components/Search/TagSelect.module.css index 9c80c90c0..d3fcc1c7c 100644 --- a/pkgs/clan-app/ui/src/components/Search/TagSelect.module.css +++ b/pkgs/clan-app/ui/src/components/Search/TagSelect.module.css @@ -1,22 +1,3 @@ -.dummybg { - padding: 1rem; - width: 20rem; - min-height: 10rem; - border-radius: 8px; - border: 1px solid #2e4a4b; - background: - linear-gradient(0deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.2) 100%), - linear-gradient( - 180deg, - theme(colors.bg.inv.2) 0%, - theme(colors.bg.inv.3) 100% - ); - - box-shadow: - 0 10px 15px -3px rgba(0, 0, 0, 0.1), - 0 4px 6px -2px rgba(0, 0, 0, 0.05); -} - .trigger { @apply rounded-md bg-inv-4 w-full min-h-11; diff --git a/pkgs/clan-app/ui/src/components/Search/TagSelect.stories.tsx b/pkgs/clan-app/ui/src/components/Search/TagSelect.stories.tsx index ef70a71e0..379345e24 100644 --- a/pkgs/clan-app/ui/src/components/Search/TagSelect.stories.tsx +++ b/pkgs/clan-app/ui/src/components/Search/TagSelect.stories.tsx @@ -3,6 +3,7 @@ import { Meta, StoryObj } from "@kachurun/storybook-solid"; import { TagSelect, TagSelectProps } from "./TagSelect"; import { Tag } from "../Tag/Tag"; import Icon from "../Icon/Icon"; +import { createSignal } from "solid-js"; const meta = { title: "Components/Custom/SelectStepper", @@ -11,28 +12,51 @@ const meta = { export default meta; -type Story = StoryObj>; +interface Item { + value: string; + label: string; +} -const Item = (item: string) => ( +type Story = StoryObj>; + +const Item = (item: Item) => ( ( )} > - {item} + {item.label} ); export const Default: Story = { args: { renderItem: Item, - values: ["foo", "bar"], - options: ["foo", "bar", "baz", "qux", "quux"], - onChange: (values: string[]) => { - console.log("Selected values:", values); - }, - onClick: () => { - console.log("Combobox clicked"); - }, + label: "Peer", + options: [ + { value: "foo", label: "Foo" }, + { value: "bar", label: "Bar" }, + { value: "baz", label: "Baz" }, + { value: "qux", label: "Qux" }, + { value: "quux", label: "Quux" }, + { value: "corge", label: "Corge" }, + { value: "grault", label: "Grault" }, + ], + } satisfies Partial>, + render: (args: TagSelectProps) => { + const [state, setState] = createSignal([]); + return ( + + {...args} + values={state()} + onClick={() => { + console.log("Clicked, current values:"); + setState(() => [ + { value: "baz", label: "Baz" }, + { value: "qux", label: "Qux" }, + ]); + }} + /> + ); }, }; diff --git a/pkgs/clan-app/ui/src/components/Search/TagSelect.tsx b/pkgs/clan-app/ui/src/components/Search/TagSelect.tsx index 43a541134..590577fd8 100644 --- a/pkgs/clan-app/ui/src/components/Search/TagSelect.tsx +++ b/pkgs/clan-app/ui/src/components/Search/TagSelect.tsx @@ -5,43 +5,58 @@ import styles from "./TagSelect.module.css"; import { Combobox } from "@kobalte/core/combobox"; import { Button } from "../Button/Button"; +// Base props common to both modes export interface TagSelectProps { - // Define any props needed for the SelectStepper component + onClick: () => void; + label: string; values: T[]; options: T[]; - onChange: (values: T[]) => void; - onClick: () => void; renderItem: (item: T) => JSX.Element; } -export function TagSelect(props: TagSelectProps) { +/** + * Shallowly interactive field for selecting multiple tags / machines. + * It does only handle click and focus interactions + * Displays the selected items as tags + */ +export function TagSelect( + props: TagSelectProps, +) { + const optionValue = "value"; return ( -
-
-
- - Servers - - -
- - multiple - value={props.values} - onChange={props.onChange} - options={props.options} - allowsEmptyCollection - class="w-full" +
+
+ - aria-label="Fruits"> - {(state) => ( + {props.label} + + +
+ + multiple + optionValue={optionValue} + value={props.values} + options={props.options} + allowsEmptyCollection + class="w-full" + > + aria-label="Fruits"> + {(state) => { + console.log("combobox state selected", state.selectedOptions()); + return ( (props: TagSelectProps) { {props.renderItem}
- )} - - -
+ ); + }} + +
); }