diff --git a/invokeai/frontend/web/src/common/components/IAIColorPicker.tsx b/invokeai/frontend/web/src/common/components/IAIColorPicker.tsx index 5854f7503f5..b61693c86ac 100644 --- a/invokeai/frontend/web/src/common/components/IAIColorPicker.tsx +++ b/invokeai/frontend/web/src/common/components/IAIColorPicker.tsx @@ -1,9 +1,12 @@ -import { Box, ChakraProps } from '@chakra-ui/react'; -import { memo } from 'react'; +import { ChakraProps, Flex } from '@chakra-ui/react'; +import { memo, useCallback } from 'react'; import { RgbaColorPicker } from 'react-colorful'; import { ColorPickerBaseProps, RgbaColor } from 'react-colorful/dist/types'; +import IAINumberInput from './IAINumberInput'; -type IAIColorPickerProps = ColorPickerBaseProps; +type IAIColorPickerProps = ColorPickerBaseProps & { + withNumberInput?: boolean; +}; const colorPickerStyles: NonNullable = { width: 6, @@ -11,17 +14,84 @@ const colorPickerStyles: NonNullable = { borderColor: 'base.100', }; -const sx = { +const sx: ChakraProps['sx'] = { '.react-colorful__hue-pointer': colorPickerStyles, '.react-colorful__saturation-pointer': colorPickerStyles, '.react-colorful__alpha-pointer': colorPickerStyles, + gap: 2, + flexDir: 'column', }; +const numberInputWidth: ChakraProps['w'] = '4.2rem'; + const IAIColorPicker = (props: IAIColorPickerProps) => { + const { color, onChange, withNumberInput, ...rest } = props; + const handleChangeR = useCallback( + (r: number) => onChange({ ...color, r }), + [color, onChange] + ); + const handleChangeG = useCallback( + (g: number) => onChange({ ...color, g }), + [color, onChange] + ); + const handleChangeB = useCallback( + (b: number) => onChange({ ...color, b }), + [color, onChange] + ); + const handleChangeA = useCallback( + (a: number) => onChange({ ...color, a }), + [color, onChange] + ); return ( - - - + + + {withNumberInput && ( + + + + + + + )} + ); }; diff --git a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolChooserOptions.tsx b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolChooserOptions.tsx index b5770fdda67..0030f1f06ed 100644 --- a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolChooserOptions.tsx +++ b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolChooserOptions.tsx @@ -245,6 +245,7 @@ const IAICanvasToolChooserOptions = () => { }} > dispatch(setBrushColor(newColor))} />