From 68583bfea243813431c40d0d49d30054cd434c8d Mon Sep 17 00:00:00 2001 From: Fuma Nama Date: Mon, 8 Jan 2024 20:18:39 +0800 Subject: [PATCH] UI: Improve button styles --- packages/ui/src/components/accordion.tsx | 9 ++++- packages/ui/src/components/roll-button.tsx | 7 +++- packages/ui/src/components/ui/command.tsx | 35 ++++++++++++----- packages/ui/src/components/ui/dialog.tsx | 18 ++++++--- packages/ui/src/components/ui/drawer.tsx | 21 ++++++---- packages/ui/src/mdx/pre.tsx | 6 ++- packages/ui/src/nav.tsx | 45 +++++++++++++++------- packages/ui/src/tailwind-plugin.ts | 2 +- packages/ui/src/theme/animations.ts | 1 - packages/ui/src/theme/shared.ts | 20 ++++++++++ 10 files changed, 122 insertions(+), 42 deletions(-) create mode 100644 packages/ui/src/theme/shared.ts diff --git a/packages/ui/src/components/accordion.tsx b/packages/ui/src/components/accordion.tsx index adfde37c4..8ef9e71bd 100644 --- a/packages/ui/src/components/accordion.tsx +++ b/packages/ui/src/components/accordion.tsx @@ -14,6 +14,7 @@ import { } from 'react'; import { cn } from '@/utils/cn'; import { useCopyButton } from '@/utils/use-copy-button'; +import { buttonVariants } from '@/theme/shared'; export const Accordions = forwardRef< HTMLDivElement, @@ -106,7 +107,13 @@ function CopyButton({ id }: { id: string }): JSX.Element { ) : null} diff --git a/packages/ui/src/tailwind-plugin.ts b/packages/ui/src/tailwind-plugin.ts index 7519c0eb7..4c81b0e21 100644 --- a/packages/ui/src/tailwind-plugin.ts +++ b/packages/ui/src/tailwind-plugin.ts @@ -240,7 +240,7 @@ export const docsUi = plugin.withOptions( export function createPreset(options: DocsUIOptions = {}): PresetsConfig { return { - plugins: [...docsUiPlugins, docsUi(options)], + plugins: [typography, docsUi(options)], }; } diff --git a/packages/ui/src/theme/animations.ts b/packages/ui/src/theme/animations.ts index 56da8988d..c663e7052 100644 --- a/packages/ui/src/theme/animations.ts +++ b/packages/ui/src/theme/animations.ts @@ -47,7 +47,6 @@ export const animations = { to: { opacity: '1' }, }, 'fade-out': { - from: { opacity: '1' }, to: { opacity: '0' }, }, }, diff --git a/packages/ui/src/theme/shared.ts b/packages/ui/src/theme/shared.ts new file mode 100644 index 000000000..af66c17db --- /dev/null +++ b/packages/ui/src/theme/shared.ts @@ -0,0 +1,20 @@ +import { cva } from 'class-variance-authority'; + +export const buttonVariants = cva( + 'inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100', + { + variants: { + color: { + outline: 'border hover:bg-accent hover:text-accent-foreground', + ghost: 'hover:bg-accent hover:text-accent-foreground', + secondary: + 'border bg-secondary text-secondary-foreground hover:bg-accent hover:text-accent-foreground', + muted: + 'bg-muted text-secondary-foreground hover:bg-accent hover:text-accent-foreground', + }, + size: { + icon: 'p-1.5 [&_svg]:h-5 [&_svg]:w-5', + }, + }, + }, +);