From f54df889a362d98adc906745f5543c706ca455cb Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 17 Jun 2024 15:04:32 +0800 Subject: [PATCH] feat: re-design `` (#67) * feat: resign `` Signed-off-by: Innei * fix: unify styles and prevent `esc` to trigger input event Signed-off-by: Innei * fix: adjust button height Signed-off-by: Innei * fix: unify button style Signed-off-by: Innei * fix: popover button Signed-off-by: Innei --------- Signed-off-by: Innei --- components.json | 2 +- src/renderer/index.html | 2 +- .../ui/auto-completion/AutoCompletion.tsx | 4 +- .../src/components/ui/button/index.tsx | 3 +- .../src/components/ui/button/variants.tsx | 2 +- src/renderer/src/components/ui/form.tsx | 19 +-- src/renderer/src/components/ui/input.tsx | 21 ---- .../src/components/ui/input/Input.tsx | 36 ++++++ .../src/components/ui/input/TextArea.tsx | 114 ++++++++++++++++++ src/renderer/src/components/ui/input/index.ts | 2 + src/renderer/src/components/ui/select.tsx | 15 +-- .../src/hooks/common/use-input-composition.ts | 60 +++++++++ src/renderer/src/modules/discover/import.tsx | 6 +- .../src/modules/entry-column/index.tsx | 20 +-- .../src/pages/(external)/redirect.tsx | 9 +- .../(context)/(nonhome)/profile/index.tsx | 25 ++-- src/renderer/src/pages/settings/actions.tsx | 73 +++++++---- src/renderer/src/pages/settings/profile.tsx | 6 +- src/renderer/src/styles/base.css | 4 + src/renderer/src/styles/colors.css | 4 +- src/renderer/src/styles/tailwind-extend.css | 50 ++++++++ 21 files changed, 372 insertions(+), 105 deletions(-) delete mode 100644 src/renderer/src/components/ui/input.tsx create mode 100644 src/renderer/src/components/ui/input/Input.tsx create mode 100644 src/renderer/src/components/ui/input/TextArea.tsx create mode 100644 src/renderer/src/components/ui/input/index.ts create mode 100644 src/renderer/src/hooks/common/use-input-composition.ts diff --git a/components.json b/components.json index fcf21ac23..793d5be3d 100644 --- a/components.json +++ b/components.json @@ -1,6 +1,6 @@ { "$schema": "https://ui.shadcn.com/schema.json", - "style": "default", + "style": "new-york", "rsc": false, "tsx": true, "tailwind": { diff --git a/src/renderer/index.html b/src/renderer/index.html index 5090dec0b..23e3031f3 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -24,7 +24,7 @@
-
+
diff --git a/src/renderer/src/components/ui/auto-completion/AutoCompletion.tsx b/src/renderer/src/components/ui/auto-completion/AutoCompletion.tsx index a213dd7fc..ecc7bb9ca 100644 --- a/src/renderer/src/components/ui/auto-completion/AutoCompletion.tsx +++ b/src/renderer/src/components/ui/auto-completion/AutoCompletion.tsx @@ -205,7 +205,7 @@ export const Autocomplete = forwardRef( exit={{ opacity: 0, y: 10 }} className={clsx( "pointer-events-auto max-h-48 grow", - "overflow-auto rounded-md border border-zinc-200 bg-zinc-50/90 backdrop-blur dark:border-neutral-800 dark:bg-neutral-900/90", + "overflow-auto rounded-md border border-zinc-200 bg-popover text-popover-foreground", )} // FIXME: https://github.com/radix-ui/primitives/issues/2125 onWheel={stopPropagation} @@ -220,7 +220,7 @@ export const Autocomplete = forwardRef( } return (
  • )} - {props.children} + {props.children} ) diff --git a/src/renderer/src/components/ui/button/variants.tsx b/src/renderer/src/components/ui/button/variants.tsx index 899899c5d..c84a6888b 100644 --- a/src/renderer/src/components/ui/button/variants.tsx +++ b/src/renderer/src/components/ui/button/variants.tsx @@ -31,7 +31,7 @@ export const buttonVariants = cva( }, ) export const styledButtonVariant = cva( - "inline-flex select-none disabled:cursor-not-allowed cursor-default items-center gap-2 justify-center rounded-lg py-2 px-3 text-sm outline-offset-2 transition active:transition-none", + "inline-flex select-none disabled:cursor-not-allowed cursor-default items-center gap-2 justify-center rounded-lg py-1.5 px-3 text-sm outline-offset-2 transition active:transition-none", { compoundVariants: [ { diff --git a/src/renderer/src/components/ui/form.tsx b/src/renderer/src/components/ui/form.tsx index bf7659fb4..0cf563bee 100644 --- a/src/renderer/src/components/ui/form.tsx +++ b/src/renderer/src/components/ui/form.tsx @@ -3,16 +3,8 @@ import { Slot } from "@radix-ui/react-slot" import { Label } from "@renderer/components/ui/label" import { cn } from "@renderer/lib/utils" import * as React from "react" -import type { - ControllerProps, - FieldPath, - FieldValues, -} from "react-hook-form" -import { - Controller, - FormProvider, - useFormContext, -} from "react-hook-form" +import type { ControllerProps, FieldPath, FieldValues } from "react-hook-form" +import { Controller, FormProvider, useFormContext } from "react-hook-form" const Form = FormProvider @@ -92,7 +84,7 @@ const FormLabel = React.forwardRef< return (