diff --git a/packages/pl-fe/src/features/pl-fe-config/components/color-picker.tsx b/packages/pl-fe/src/features/pl-fe-config/components/color-picker.tsx index 888e331dd..ab9173612 100644 --- a/packages/pl-fe/src/features/pl-fe-config/components/color-picker.tsx +++ b/packages/pl-fe/src/features/pl-fe-config/components/color-picker.tsx @@ -5,27 +5,33 @@ import Popover from 'pl-fe/components/ui/popover'; interface IColorPicker { value: string; - onChange: ColorChangeHandler; + onChange?: ColorChangeHandler; className?: string; } -const ColorPicker: React.FC = ({ value, onChange, className }) => ( -
- - } - isFlush - > -
- -
-); - +const ColorPicker: React.FC = ({ value, onChange, className }) => { + const colorPreview = ( +
+ ); + return ( +
+ {onChange ? ( + + } + isFlush + > + {colorPreview} + + ) : colorPreview} +
+ ); +}; export { ColorPicker as default }; diff --git a/packages/pl-fe/src/features/preferences/index.tsx b/packages/pl-fe/src/features/preferences/index.tsx index ee31cd601..30e7bfd69 100644 --- a/packages/pl-fe/src/features/preferences/index.tsx +++ b/packages/pl-fe/src/features/preferences/index.tsx @@ -175,6 +175,7 @@ const Preferences = () => { label={intl.formatMessage(messages.brandColor)} palette={colors(settings.theme?.brandColor || plFeConfig.brandColor || '#d80482')} onChange={(palette) => onBrandColorChange(palette['500'])} + allowTintChange={false} /> diff --git a/packages/pl-fe/src/features/theme-editor/components/color.tsx b/packages/pl-fe/src/features/theme-editor/components/color.tsx index 2739f5bc5..b92b0d48e 100644 --- a/packages/pl-fe/src/features/theme-editor/components/color.tsx +++ b/packages/pl-fe/src/features/theme-editor/components/color.tsx @@ -6,21 +6,21 @@ import type { ColorChangeHandler } from 'react-color'; interface IColor { color: string; - onChange: (color: string) => void; + onChange?: (color: string) => void; } /** Color input. */ const Color: React.FC = ({ color, onChange }) => { const handleChange: ColorChangeHandler = (result) => { - onChange(result.hex); + onChange?.(result.hex); }; return ( ); }; diff --git a/packages/pl-fe/src/features/theme-editor/components/palette.tsx b/packages/pl-fe/src/features/theme-editor/components/palette.tsx index cb8c1b6af..69f212bf3 100644 --- a/packages/pl-fe/src/features/theme-editor/components/palette.tsx +++ b/packages/pl-fe/src/features/theme-editor/components/palette.tsx @@ -17,10 +17,11 @@ interface IPalette { palette: ColorGroup; onChange: (palette: ColorGroup) => void; resetKey?: string; + allowTintChange?: boolean; } /** Editable color palette. */ -const Palette: React.FC = ({ palette, onChange, resetKey }) => { +const Palette: React.FC = ({ palette, onChange, resetKey, allowTintChange = true }) => { const tints = Object.keys(palette).sort(compareId); const [hue, setHue] = useState(0); @@ -52,7 +53,7 @@ const Palette: React.FC = ({ palette, onChange, resetKey }) => { {tints.map(tint => ( - + ))} diff --git a/packages/pl-fe/src/features/theme-editor/index.tsx b/packages/pl-fe/src/features/theme-editor/index.tsx index 5817740fd..989dfdc4a 100644 --- a/packages/pl-fe/src/features/theme-editor/index.tsx +++ b/packages/pl-fe/src/features/theme-editor/index.tsx @@ -249,12 +249,13 @@ interface IPaletteListItem { palette: ColorGroup | string; onChange: (palette: ColorGroup) => void; resetKey?: string; + allowTintChange?: boolean; } /** Palette editor inside a ListItem. */ -const PaletteListItem: React.FC = ({ label, palette, onChange, resetKey }) => typeof palette === 'string' ? null : ( +const PaletteListItem: React.FC = ({ label, palette, onChange, resetKey, allowTintChange }) => typeof palette === 'string' ? null : ( {label}
}> - + );