From 12edbaaf576336a7645ee30b0bc352d7ab04bb06 Mon Sep 17 00:00:00 2001 From: Emmanuel Krebs Date: Sun, 15 Oct 2023 19:56:43 +0200 Subject: [PATCH] fix: improve selection: --- TODO.md | 1 + src/Button/index.tsx | 4 ++-- src/Inputs/NumberInput.tsx | 12 +++++++----- src/Inputs/TextInput.tsx | 12 +++++++----- src/Select/Select.tsx | 13 ++++++++++--- src/tailwind.css | 6 +++++- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/TODO.md b/TODO.md index 86fcf19..b98fd7a 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,7 @@ - [ ] one for ladle custom UI - [ ] update README by documenting how to theme - [ ] document group/??? on newly themed components when/if relevant (waiting for `tailwindcss-react-aria-components` update) +- [ ] `Select`: don't rely on `errorMessage &&` but use custom `data-...` + `group-...` instead ## Tips diff --git a/src/Button/index.tsx b/src/Button/index.tsx index 04e022d..73d753d 100644 --- a/src/Button/index.tsx +++ b/src/Button/index.tsx @@ -38,12 +38,12 @@ export const Button: FC = ({ variant === 'primary' && `font-medium text-th-reversed border-primary ring-primary - bg-primary hover:enabled:bg-primary/95`, + bg-primary hover:enabled:bg-primary/95 selection:bg-gray-900 selection:dark:bg-gray-50`, variant === 'destructive' && `font-medium text-destructive border-destructive - bg-th hover:enabled:bg-destructive/5 + bg-th hover:enabled:bg-destructive/5 selection:bg-error ring-destructive`, className, )} diff --git a/src/Inputs/NumberInput.tsx b/src/Inputs/NumberInput.tsx index 2d351a6..96d9979 100644 --- a/src/Inputs/NumberInput.tsx +++ b/src/Inputs/NumberInput.tsx @@ -33,16 +33,18 @@ export const NumberInput = ({ {...numberFieldProps} isInvalid={numberFieldProps.isInvalid || !!errorMessage} className={twMerge( - 'flex', + 'flex group', flow === 'row' ? 'flex-row space-x-2' : 'flex-col w-fit', wrapperClassName, )} > - + {description && ( - + {description} )} {errorMessage && ( - + {errorMessage} )} diff --git a/src/Inputs/TextInput.tsx b/src/Inputs/TextInput.tsx index 8168ca0..92e89b3 100644 --- a/src/Inputs/TextInput.tsx +++ b/src/Inputs/TextInput.tsx @@ -33,12 +33,14 @@ export const TextInput: FC = ({ {...textFieldProps} isInvalid={textFieldProps.isInvalid || !!errorMessage} className={twMerge( - 'flex', + 'group flex', flow === 'row' ? 'flex-row space-x-2' : 'flex-col w-fit', wrapperClassName, )} > - + = ({ ring-primary invalid:ring-error caret-primary - invalid:caret-error`, + invalid:caret-error invalid:selection:bg-error`, border !== 'bottom' ? 'rounded-md' : 'rounded-none', // rounded-none is necessary for iPad border === 'bottom' && `border-b focus:border-b-transparent focus:dark:border-b-transparent @@ -62,12 +64,12 @@ export const TextInput: FC = ({ )} /> {description && ( - + {description} )} {errorMessage && ( - + {errorMessage} )} diff --git a/src/Select/Select.tsx b/src/Select/Select.tsx index c8d455d..d90c09e 100644 --- a/src/Select/Select.tsx +++ b/src/Select/Select.tsx @@ -48,7 +48,9 @@ export const Select = ({ {...props} className={twMerge('flex', flow === 'row' ? 'flex-row space-x-2' : 'w-fit flex-col', flowClassName)} > - + {description && ( - + {description} )} {errorMessage && ( - + {errorMessage} )} diff --git a/src/tailwind.css b/src/tailwind.css index edb4d20..b01e6b2 100644 --- a/src/tailwind.css +++ b/src/tailwind.css @@ -26,6 +26,10 @@ .bg-primary\/95 { @apply bg-primary-500/95 dark:bg-primary-400/95; } + .bg-destructive, + .bg-error { + @apply bg-red-600 dark:bg-red-500; + } .bg-destructive\/5 { @apply bg-red-600/5 dark:bg-red-500/5; } @@ -104,6 +108,6 @@ } .caret-destructive, .caret-error { - @apply caret-primary-600 dark:caret-primary-500; + @apply caret-red-600 dark:caret-red-500; } }