diff --git a/src/view/form/ColorPicker.tsx b/src/view/form/ColorPicker.tsx index 3e85cff..f266cab 100644 --- a/src/view/form/ColorPicker.tsx +++ b/src/view/form/ColorPicker.tsx @@ -13,7 +13,9 @@ import { useState } from "react"; export function ColorPicker(props: { color?: string; - onChange: (color: string) => void; + defaultColor?: string; + onChange: (color?: string) => void; + onReset?: (color?: string) => void; }): JSX.Element { const [showColorPicker, setShowColorPicker] = useState(false); const { refs, floatingStyles, context } = useFloating({ @@ -35,6 +37,20 @@ export function ColorPicker(props: { }} onClick={() => setShowColorPicker(!showColorPicker)} > + {props.color && ( +
+ {props.color ?? ""} + { + if (props.onReset) { + props.onReset(props.defaultColor); + } else { + props.onChange(props.defaultColor); + } + }}> + x + +
+ )} {showColorPicker ? (
{ + changeFormData( + "mainContainerStyle", + { + ...formData.mainContainerStyle, + backgroundColor: + color, + } + ); + }} />
diff --git a/styles.css b/styles.css index 5b4a3d6..303175f 100644 --- a/styles.css +++ b/styles.css @@ -288,6 +288,25 @@ opacity: 0.6; } +.color-label { + display: flex; + gap: 6px; + background-color: hsl(var(--interactive-accent-hsl), 0.2); + color: hsl(var(--interactive-accent-hsl), 0.8); + align-items: center; + border-radius: 6px; + padding: 4px 8px; +} + +.color-label:hover { + background-color: hsl(var(--interactive-accent-hsl), 0.8); + color: var(--text-on-accent); +} + +.color-reset-button:hover { + color: var(--text-normal); +} + /* default cell rule indicator */ .contribution-graph .cell-rule-indicator-container { position: relative;