diff --git a/src/widgets/ColorPicker.tsx b/src/widgets/ColorPicker.tsx new file mode 100644 index 0000000..190c610 --- /dev/null +++ b/src/widgets/ColorPicker.tsx @@ -0,0 +1,69 @@ +import * as React from 'react'; + +import ColorBox from './ColorBox'; +import { colorHtmlToInt } from '../journal-processors'; +import { TextField, ButtonBase } from '@material-ui/core'; + +interface PropsType { + color: string; + defaultColor: string; + label?: string; + placeholder?: string; + error?: string; + onChange: (color: string) => void; +} + + +export default function ColorPicker(props: PropsType) { + const colors = [ + [ + '#F44336', + '#E91E63', + '#673AB7', + '#3F51B5', + '#2196F3', + ], + [ + '#03A9F4', + '#4CAF50', + '#8BC34A', + '#FFEB3B', + '#FF9800', + ], + ]; + const color = props.color; + + return ( +
+ {colors.map((colorGroup, idx) => ( +
+ {colorGroup.map((colorOption) => ( + props.onChange(colorOption)} + > + + + ))} +
+ ))} +
+ + ) => props.onChange(event.currentTarget.value)} + placeholder={props.placeholder ?? 'E.g. #aabbcc'} + label={props.label ?? 'Color'} + value={color} + helperText={props.error} + /> +
+
+ ); +} \ No newline at end of file