diff --git a/web/modals/threads/color-selector-button.react.js b/web/modals/threads/color-selector-button.react.js index 0dc836211..62bd2ed57 100644 --- a/web/modals/threads/color-selector-button.react.js +++ b/web/modals/threads/color-selector-button.react.js @@ -1,33 +1,41 @@ // @flow import classNames from 'classnames'; import * as React from 'react'; +import { type SetState } from 'lib/types/hook-types.js'; + import css from './color-selector-button.css'; type ColorSelectorButtonProps = { +color: string, - +active: boolean, + +pendingColorSelection: string, + +setPendingColorSelection: SetState, }; function ColorSelectorButton(props: ColorSelectorButtonProps): React.Node { - const { color, active } = props; + const { color, pendingColorSelection, setPendingColorSelection } = props; + const active = color === pendingColorSelection; const containerClassName = classNames(css.container, { [css.active]: active, }); const colorSplotchStyle = React.useMemo( () => ({ backgroundColor: color, }), [color], ); + const onColorSplotchClicked = React.useCallback(() => { + setPendingColorSelection(color); + }, [setPendingColorSelection, color]); + return ( -
+
); } export default ColorSelectorButton; diff --git a/web/modals/threads/color-selector.react.js b/web/modals/threads/color-selector.react.js index 08f42b0d4..28a7cfebc 100644 --- a/web/modals/threads/color-selector.react.js +++ b/web/modals/threads/color-selector.react.js @@ -1,29 +1,77 @@ // @flow import * as React from 'react'; 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 (
- - - - - + + + + +
- - - - - + + + + +
); } export default ColorSelector;