diff --git a/pkgs/webview-ui/app/src/components/inputBase/index.tsx b/pkgs/webview-ui/app/src/components/inputBase/index.tsx new file mode 100644 index 000000000..7a1ed0d2d --- /dev/null +++ b/pkgs/webview-ui/app/src/components/inputBase/index.tsx @@ -0,0 +1,146 @@ +import cx from "classnames"; +import { createEffect, JSX, splitProps } from "solid-js"; +import Icon, { IconVariant } from "../icon"; +import { Typography } from "../Typography"; + +type Variants = "outlined" | "ghost"; +interface InputBaseProps { + variant?: Variants; + value?: string; + inputProps?: JSX.InputHTMLAttributes; + required?: boolean; + type?: string; + inlineLabel?: JSX.Element; + class?: string; + placeholder?: string; + disabled?: boolean; + readonly?: boolean; + error?: boolean; + icon?: IconVariant; +} + +const variantBorder: Record = { + outlined: "border border-inv-3", + ghost: "", +}; + +const fgStateClasses = cx("aria-disabled:fg-def-4 aria-readonly:fg-def-3"); + +export const InputBase = (props: InputBaseProps) => { + const [, inputProps] = splitProps(props, ["class"]); + + createEffect(() => { + console.log("InputBase", props.value, props.variant); + }); + return ( +
+ {props.icon && ( + + + + )} + +
+ ); +}; + +interface InputLabelProps extends JSX.LabelHTMLAttributes { + description?: string; + required?: boolean; + error?: boolean; + help?: string; +} +export const InputLabel = (props: InputLabelProps) => { + const [labelProps, forwardProps] = splitProps(props, ["class"]); + return ( + + ); +}; diff --git a/pkgs/webview-ui/app/src/index.tsx b/pkgs/webview-ui/app/src/index.tsx index d6014c84b..37849ee84 100644 --- a/pkgs/webview-ui/app/src/index.tsx +++ b/pkgs/webview-ui/app/src/index.tsx @@ -20,6 +20,7 @@ import { ModuleDetails } from "./routes/modules/details"; import { ModuleDetails as AddModule } from "./routes/modules/add"; import { ApiTester } from "./api_test"; import { IconVariant } from "./components/icon"; +import { Components } from "./routes/components"; export const client = new QueryClient(); @@ -157,6 +158,12 @@ export const routes: AppRoute[] = [ hidden: false, component: () => , }, + { + path: "/components", + label: "Components", + hidden: false, + component: () => , + }, ], }, ]; diff --git a/pkgs/webview-ui/app/src/routes/components/index.tsx b/pkgs/webview-ui/app/src/routes/components/index.tsx new file mode 100644 index 000000000..9c49a17e7 --- /dev/null +++ b/pkgs/webview-ui/app/src/routes/components/index.tsx @@ -0,0 +1,118 @@ +import { Button } from "@/src/components/button"; +import { InputBase, InputLabel } from "@/src/components/inputBase"; +import { TextInput } from "@/src/Form/fields"; +import { Header } from "@/src/layout/header"; +import { createForm, required } from "@modular-forms/solid"; + +const disabled = [false, true]; +const readOnly = [false, true]; +const error = [false, true]; + +export const Components = () => { + const [formStore, { Form, Field }] = createForm<{ ef: string }>({}); + return ( + <> +
+ +
+ Input + + Default + Size S + + {disabled.map((disabled) => + readOnly.map((readOnly) => + error.map((hasError) => ( + <> + + {[ + disabled ? "Disabled" : "(default)", + readOnly ? "ReadOnly" : "", + hasError ? "Error" : "", + ] + .filter(Boolean) + .join(" + ")} + + + + )) + ) + )} + Input Ghost + {disabled.map((disabled) => + readOnly.map((readOnly) => + error.map((hasError) => ( + <> + + {[ + disabled ? "Disabled" : "(default)", + readOnly ? "ReadOnly" : "", + hasError ? "Error" : "", + ] + .filter(Boolean) + .join(" + ")} + + + + )) + ) + )} + Input Label + Default + Labeltext + Required + Labeltext + Error + Labeltext + Error + Reuired + + Labeltext + + Icon + Labeltext + Description + Labeltext +
+
+ Form Layout + +
{ + console.log("Nothing"); + }} + > + + {(field, inputProps) => ( + + )} + + +
+ +
+ + ); +};