diff --git a/web/modals/threads/color-selector-button.react.js b/web/modals/threads/color-selector-button.react.js --- a/web/modals/threads/color-selector-button.react.js +++ b/web/modals/threads/color-selector-button.react.js @@ -7,10 +7,16 @@ type ColorSelectorButtonProps = { +color: string, - +active: boolean, + +pendingColorSelection: string, + +setPendingColorSelection: string => void, }; function ColorSelectorButton(props: ColorSelectorButtonProps): React.Node { - const { color, active } = props; + const { color, pendingColorSelection, setPendingColorSelection } = props; + + const active = React.useMemo(() => color === pendingColorSelection, [ + color, + pendingColorSelection, + ]); const containerClassName = classNames(css.container, { [css.active]: active, @@ -23,8 +29,12 @@ [color], ); + const onColorSplotchClicked = React.useCallback(() => { + setPendingColorSelection(color); + }, [setPendingColorSelection, color]); + return ( -
+
); diff --git a/web/modals/threads/color-selector.react.js b/web/modals/threads/color-selector.react.js --- a/web/modals/threads/color-selector.react.js +++ b/web/modals/threads/color-selector.react.js @@ -5,22 +5,70 @@ import ColorSelectorButton from './color-selector-button.react'; import css from './color-selector.css'; -function ColorSelector(): React.Node { +type ColorSelectorProps = { + +currentThreadColor: string, +}; +function ColorSelector(props: ColorSelectorProps): React.Node { + const { currentThreadColor } = props; + const [pendingColorSelection, setPendingColorSelection] = React.useState( + currentThreadColor, + ); + return (
- - - - - + + + + +
- - - - - + + + + +
);