diff --git a/pkgs/webview-ui/app/src/Form/fields/TextInput.tsx b/pkgs/webview-ui/app/src/Form/fields/TextInput.tsx index 96e665eaf..74640f345 100644 --- a/pkgs/webview-ui/app/src/Form/fields/TextInput.tsx +++ b/pkgs/webview-ui/app/src/Form/fields/TextInput.tsx @@ -1,6 +1,8 @@ import { createEffect, Show, type JSX } from "solid-js"; import cx from "classnames"; import { Label } from "../base/label"; +import { InputBase, InputLabel } from "@/src/components/inputBase"; +import { Typography } from "@/src/components/Typography"; interface TextInputProps { value: string; @@ -22,49 +24,39 @@ interface TextInputProps { } export function TextInput(props: TextInputProps) { - const value = () => props.value; - + // createEffect(() => { + // console.log("TextInput", props.error, props.value); + // }); return ( - + + {props.label} + + + {props.error && ( + + {props.error} + + )} + ); } diff --git a/pkgs/webview-ui/app/src/api_test.tsx b/pkgs/webview-ui/app/src/api_test.tsx index 0fc9a6648..299de699f 100644 --- a/pkgs/webview-ui/app/src/api_test.tsx +++ b/pkgs/webview-ui/app/src/api_test.tsx @@ -4,7 +4,7 @@ import { getValues, SubmitHandler, } from "@modular-forms/solid"; -import { TextInput } from "./components/TextInput"; +import { TextInput } from "@/src/Form/fields/TextInput"; import { Button } from "./components/button"; import { callApi } from "./api"; import { API } from "@/api/API"; @@ -68,7 +68,6 @@ export const ApiTester = () => { label={"endpoint"} value={field.value || ""} inputProps={fieldProps} - formStore={formStore} /> )} @@ -78,7 +77,6 @@ export const ApiTester = () => { label={"payload"} value={field.value || ""} inputProps={fieldProps} - formStore={formStore} /> )} diff --git a/pkgs/webview-ui/app/src/components/TextInput.tsx b/pkgs/webview-ui/app/src/components/TextInput.tsx deleted file mode 100644 index 43f24c861..000000000 --- a/pkgs/webview-ui/app/src/components/TextInput.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { FieldValues, FormStore, ResponseData } from "@modular-forms/solid"; -import { Show, type JSX } from "solid-js"; -import cx from "classnames"; - -interface TextInputProps { - formStore: FormStore; - value: string; - inputProps: JSX.InputHTMLAttributes; - label: JSX.Element; - error?: string; - required?: boolean; - type?: string; - inlineLabel?: JSX.Element; - class?: string; - adornment?: { - position: "start" | "end"; - content: JSX.Element; - }; - placeholder?: string; -} - -export function TextInput( - props: TextInputProps, -) { - const value = () => props.value; - - return ( - - ); -} diff --git a/pkgs/webview-ui/app/src/components/Typography/css/typography-hierarchy/typography-body.css b/pkgs/webview-ui/app/src/components/Typography/css/typography-hierarchy/typography-body.css index 57a3e18f3..53014bb37 100644 --- a/pkgs/webview-ui/app/src/components/Typography/css/typography-hierarchy/typography-body.css +++ b/pkgs/webview-ui/app/src/components/Typography/css/typography-hierarchy/typography-body.css @@ -15,3 +15,9 @@ line-height: 132%; letter-spacing: 3%; } + +.fnt-body-xxs { + font-size: 0.6875rem; + line-height: 132%; + letter-spacing: 0.00688rem; +} diff --git a/pkgs/webview-ui/app/src/components/Typography/index.tsx b/pkgs/webview-ui/app/src/components/Typography/index.tsx index 250b88934..fe138cf9f 100644 --- a/pkgs/webview-ui/app/src/components/Typography/index.tsx +++ b/pkgs/webview-ui/app/src/components/Typography/index.tsx @@ -24,6 +24,7 @@ interface SizeForHierarchy { body: { default: string; xs: string; + xxs: string; s: string; }; headline: { @@ -43,10 +44,9 @@ type AllowedSizes = keyof SizeForHierarchy[H]; const sizeHierarchyMap: SizeForHierarchy = { body: { default: cx("fnt-body-default"), - xs: cx("fnt-body-xs"), s: cx("fnt-body-s"), - // m: cx("fnt-body-m"), - // l: cx("fnt-body-l"), + xs: cx("fnt-body-xs"), + xxs: cx("fnt-body-xxs"), }, headline: { default: cx("fnt-headline-default"), 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..728a72451 --- /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/clans/create.tsx b/pkgs/webview-ui/app/src/routes/clans/create.tsx index b7ac26f65..022c42045 100644 --- a/pkgs/webview-ui/app/src/routes/clans/create.tsx +++ b/pkgs/webview-ui/app/src/routes/clans/create.tsx @@ -8,7 +8,7 @@ import { } from "@modular-forms/solid"; import toast from "solid-toast"; import { setActiveURI, setClanList } from "@/src/App"; -import { TextInput } from "@/src/components/TextInput"; +import { TextInput } from "@/src/Form/fields/TextInput"; import { useNavigate } from "@solidjs/router"; import { Button } from "@/src/components/button"; import Icon from "@/src/components/icon"; @@ -165,7 +165,6 @@ export const CreateClan = () => { ), position: "start", }} - formStore={formStore} inputProps={props} label="Template to use" value={field.value ?? ""} diff --git a/pkgs/webview-ui/app/src/routes/clans/details.tsx b/pkgs/webview-ui/app/src/routes/clans/details.tsx index a86a6432f..7a11eacac 100644 --- a/pkgs/webview-ui/app/src/routes/clans/details.tsx +++ b/pkgs/webview-ui/app/src/routes/clans/details.tsx @@ -11,7 +11,7 @@ import { setValue, SubmitHandler, } from "@modular-forms/solid"; -import { TextInput } from "@/src/components/TextInput"; +import { TextInput } from "@/src/Form/fields/TextInput"; import toast from "solid-toast"; import { set_single_service } from "@/src/api/inventory"; import { Button } from "@/src/components/button"; @@ -215,7 +215,6 @@ const AdminModuleForm = (props: AdminModuleFormProps) => { {(field, props) => ( { {(field, props) => ( <> { class="col-span-6" required /> - +