From abaee70d356617d1c9df684ff7d4d1983617d5ca Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 20 Dec 2024 18:13:06 +0100 Subject: [PATCH] UI: fixup Select component design & api --- .../webview-ui/app/src/Form/fields/Select.tsx | 244 ++++++++++-------- .../app/src/components/inputBase/index.tsx | 4 +- 2 files changed, 138 insertions(+), 110 deletions(-) diff --git a/pkgs/webview-ui/app/src/Form/fields/Select.tsx b/pkgs/webview-ui/app/src/Form/fields/Select.tsx index 9afa52b6c..c8f67c6d7 100644 --- a/pkgs/webview-ui/app/src/Form/fields/Select.tsx +++ b/pkgs/webview-ui/app/src/Form/fields/Select.tsx @@ -7,14 +7,22 @@ import { createMemo, } from "solid-js"; import { Portal } from "solid-js/web"; -import cx from "classnames"; -import { Label } from "../base/label"; import { useFloating } from "../base"; -import { autoUpdate, flip, hide, shift, size } from "@floating-ui/dom"; +import { autoUpdate, flip, hide, offset, shift, size } from "@floating-ui/dom"; +import { Button } from "@/src/components/button"; +import { + InputBase, + InputError, + InputLabel, + InputLabelProps, +} from "@/src/components/inputBase"; +import { FieldLayout } from "./layout"; +import Icon from "@/src/components/icon"; export interface Option { value: string; label: string; + disabled?: boolean; } interface SelectInputpProps { @@ -22,7 +30,7 @@ interface SelectInputpProps { selectProps: JSX.InputHTMLAttributes; options: Option[]; label: JSX.Element; - altLabel?: JSX.Element; + labelProps?: InputLabelProps; helperText?: JSX.Element; error?: string; required?: boolean; @@ -36,6 +44,7 @@ interface SelectInputpProps { disabled?: boolean; placeholder?: string; multiple?: boolean; + loading?: boolean; } export function SelectInput(props: SelectInputpProps) { @@ -61,6 +70,7 @@ export function SelectInput(props: SelectInputpProps) { }); }, }), + offset({ mainAxis: 2 }), shift(), flip(), hide({ @@ -114,126 +124,144 @@ export function SelectInput(props: SelectInputpProps) { return ( <> - + ); } diff --git a/pkgs/webview-ui/app/src/components/inputBase/index.tsx b/pkgs/webview-ui/app/src/components/inputBase/index.tsx index b9608da1f..39780146d 100644 --- a/pkgs/webview-ui/app/src/components/inputBase/index.tsx +++ b/pkgs/webview-ui/app/src/components/inputBase/index.tsx @@ -55,7 +55,7 @@ export const InputBase = (props: InputBaseProps) => { // Cursor "aria-readonly:cursor-no-drop", - props.class + props.class, )} classList={{ [cx("!border !border-semantic-1 !outline-semantic-1")]: !!props.error, @@ -160,7 +160,7 @@ interface InputErrorProps { export const InputError = (props: InputErrorProps) => { const [typoClasses, rest] = splitProps( props.typographyProps || { class: "" }, - ["class"] + ["class"], ); return (