From f492601d7b1c5144cc6baccf79d81d765c03b523 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 17 Dec 2024 19:37:07 +0100 Subject: [PATCH] UI: replace TextInput with simple Layout of InputBase, InputLabel, ErrorMessage --- .../app/src/Form/fields/TextInput.tsx | 76 +++++++++---------- pkgs/webview-ui/app/src/api_test.tsx | 4 +- .../app/src/components/TextInput.tsx | 72 ------------------ .../app/src/components/inputBase/index.tsx | 2 +- .../app/src/routes/clans/create.tsx | 3 +- .../app/src/routes/clans/details.tsx | 9 ++- .../app/src/routes/components/index.tsx | 10 +-- pkgs/webview-ui/app/src/routes/flash/view.tsx | 6 +- .../app/src/routes/machines/create.tsx | 7 +- .../app/src/routes/machines/details.tsx | 60 ++++++++------- .../app/src/routes/modules/details.tsx | 20 +---- 11 files changed, 85 insertions(+), 184 deletions(-) delete mode 100644 pkgs/webview-ui/app/src/components/TextInput.tsx 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/inputBase/index.tsx b/pkgs/webview-ui/app/src/components/inputBase/index.tsx index 7a1ed0d2d..728a72451 100644 --- a/pkgs/webview-ui/app/src/components/inputBase/index.tsx +++ b/pkgs/webview-ui/app/src/components/inputBase/index.tsx @@ -56,7 +56,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, 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 /> - +