From aa783268eb91e2715f1537043deb9eef430ec92d Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Tue, 25 Jul 2023 22:00:17 +0800 Subject: [PATCH] Update colorpicker component Add indicator in colorpicker component. --- TODO.md | 23 ++-- .../src/components/ColorPicker/index.tsx | 106 +++++++++++------- .../react/src/components/Swatch/index.tsx | 6 +- .../src/pages/categories/color/index.tsx | 27 +++++ 4 files changed, 107 insertions(+), 55 deletions(-) diff --git a/TODO.md b/TODO.md index deef466..7ac0faf 100644 --- a/TODO.md +++ b/TODO.md @@ -11,7 +11,7 @@ - [X] RadioButton - [X] RadioTickBox - Color - - [ ] ColorPicker + - [X] ColorPicker - [X] Swatch (unify with color picker? Swatch is basically a readonly color picker with click-to-copy behavior) - Code - [ ] CodeInput (extract to own package) @@ -20,6 +20,7 @@ - Formatted - [X] EmailInput - [X] PhoneNumberInput + - [X] PatternTextInput - [X] UrlInput - Freeform - [X] MaskedTextInput @@ -53,24 +54,24 @@ - RichText (extract to own package) - [ ] RichTextInput - Temporal - - [ ] Calendar + - [ ] ~~Calendar~~ - [X] DateDropdown - - [ ] DateTimeRangeInput - - [ ] DurationInput - - [ ] MonthInput - - [ ] MonthDayInput + - [ ] ~~DateTimeRangeInput~~ + - [ ] ~~DurationInput~~ + - [ ] ~~MonthInput~~ + - [ ] ~~MonthDayInput~~ - [X] TimeSpinner - [-] YearMonthInput - [-] WeekInput - - [ ] YearInput + - [ ] ~~YearInput~~ # Others - [X] Add `select-none` to input labels, etc. - [X] Add indicators to components (select, datetime input etc) -- [ ] Add proxies for setting component values - - [ ] formatted/phonenumberinput - - [ ] multichoice/taginput - - [ ] blob/fileselectbox (?) +- [X] Add proxies for setting component values + - [X] formatted/phonenumberinput + - [X] multichoice/taginput + - [X] blob/fileselectbox (?) - [ ] Test all components! - [ ] Where to put the "click-to-copy" textboxes? Does `Swatch` belong to this category? diff --git a/categories/color/react/src/components/ColorPicker/index.tsx b/categories/color/react/src/components/ColorPicker/index.tsx index cf6adc7..c2be7aa 100644 --- a/categories/color/react/src/components/ColorPicker/index.tsx +++ b/categories/color/react/src/components/ColorPicker/index.tsx @@ -16,10 +16,10 @@ export const colorPickerPlugin = plugin(({ addComponents }) => { 'padding': '0', }, '&::-webkit-color-swatch': { - 'border': '2px solid black', + 'border': '0', }, '&::-moz-color-swatch': { - 'border': '2px solid black', + 'border': '0', }, }, }); @@ -33,57 +33,81 @@ export const ColorPicker = React.forwardRef< className, id: idProp, style, - square = false, + square = false as const, size = 'medium' as const, ...etcProps }, forwardedRef, -) => { - return ( -
( +
+ - + + + + - {/* todo add chevron down to picker */} - - -
- ); -}); + + + + +
+)); ColorPicker.displayName = 'ColorPicker'; diff --git a/categories/color/react/src/components/Swatch/index.tsx b/categories/color/react/src/components/Swatch/index.tsx index 1bb85a5..77edec9 100644 --- a/categories/color/react/src/components/Swatch/index.tsx +++ b/categories/color/react/src/components/Swatch/index.tsx @@ -16,10 +16,9 @@ export interface SwatchProps extends Omit, export const useSwatchControls = () => { const id = React.useId(); - const copyColor: React.ReactEventHandler = React.useCallback((e) => { + const copyColor: React.ReactEventHandler = React.useCallback(async (e) => { const { value } = e.currentTarget; - // eslint-disable-next-line no-void - void window.navigator.clipboard.writeText(value); + await window.navigator.clipboard.writeText(value); }, []); return React.useMemo(() => ({ id, @@ -68,6 +67,7 @@ export const Swatch = React.forwardRef(({ title={colorValue} htmlFor={id} > + {/* todo border primary */} diff --git a/showcases/web-kitchensink-reactnext/src/pages/categories/color/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/color/index.tsx index f49e6ff..a02333f 100644 --- a/showcases/web-kitchensink-reactnext/src/pages/categories/color/index.tsx +++ b/showcases/web-kitchensink-reactnext/src/pages/categories/color/index.tsx @@ -2,6 +2,7 @@ import {NextPage} from 'next'; import {DefaultLayout} from '@/components/DefaultLayout'; import {Section, Subsection} from '@/components/Section'; import * as Color from '@tesseract-design/web-color-react'; +import { TextInput } from '@tesseract-design/web-freeform-react'; const ColorPage: NextPage = () => { return ( @@ -55,6 +56,32 @@ const ColorPage: NextPage = () => { disabled /> + + + + +
+ +
+
)