Improve color suggestions (#304)

* Add palettes for each type of color picker.

* Add white canvas background and black element stroke.

* Add white for element background.
This commit is contained in:
Enzo Ferey 2020-01-11 23:58:44 +01:00 committed by Christopher Chedeau
parent 6399b1f318
commit c6accd9fc7
4 changed files with 51 additions and 13 deletions

View File

@ -11,6 +11,7 @@ export const actionChangeViewBackgroundColor: Action = {
<> <>
<h5>Canvas Background Color</h5> <h5>Canvas Background Color</h5>
<ColorPicker <ColorPicker
type="canvasBackground"
color={appState.viewBackgroundColor} color={appState.viewBackgroundColor}
onChange={color => updateData(color)} onChange={color => updateData(color)}
/> />

View File

@ -32,6 +32,7 @@ export const actionChangeStrokeColor: Action = {
PanelComponent: ({ elements, appState, updateData }) => ( PanelComponent: ({ elements, appState, updateData }) => (
<PanelColor <PanelColor
title="Stroke Color" title="Stroke Color"
colorType="elementStroke"
onColorChange={(color: string) => { onColorChange={(color: string) => {
updateData(color); updateData(color);
}} }}
@ -57,6 +58,7 @@ export const actionChangeBackgroundColor: Action = {
PanelComponent: ({ elements, updateData }) => ( PanelComponent: ({ elements, updateData }) => (
<PanelColor <PanelColor
title="Background Color" title="Background Color"
colorType="elementBackground"
onColorChange={(color: string) => { onColorChange={(color: string) => {
updateData(color); updateData(color);
}} }}

View File

@ -8,9 +8,11 @@ const TwitterPicker = lazy(() =>
); );
export function ColorPicker({ export function ColorPicker({
type,
color, color,
onChange onChange
}: { }: {
type: "canvasBackground" | "elementBackground" | "elementStroke";
color: string | null; color: string | null;
onChange: (color: string) => void; onChange: (color: string) => void;
}) { }) {
@ -26,19 +28,7 @@ export function ColorPicker({
{isActive ? ( {isActive ? (
<Popover onCloseRequest={() => setActive(false)}> <Popover onCloseRequest={() => setActive(false)}>
<TwitterPicker <TwitterPicker
colors={[ colors={colors[type]}
"#000000",
"#ABB8C3",
"#FFFFFF",
"#FF6900",
"#FCB900",
"#00D084",
"#8ED1FC",
"#0693E3",
"#EB144C",
"#F78DA7",
"#9900EF"
]}
width="205px" width="205px"
color={color || undefined} color={color || undefined}
onChange={changedColor => { onChange={changedColor => {
@ -58,3 +48,45 @@ export function ColorPicker({
</div> </div>
); );
} }
const colors = {
canvasBackground: [
"#DEE6EF",
"#FCEAD8",
"#F9E0E0",
"#E6F1F1",
"#E0EDDF",
"#FBF5DD",
"#F0E6ED",
"#FFEDEF",
"#EDE5E1",
"#F2F0EF",
"#FFFFFF"
],
elementBackground: [
"#4E79A7",
"#F28E2C",
"#E15759",
"#76B7B2",
"#59A14F",
"#EDC949",
"#AF7AA1",
"#FF9DA7",
"#9C755F",
"#BAB0AB",
"#FFFFFF"
],
elementStroke: [
"#324E6B",
"#9B5B1D",
"#903839",
"#4C7572",
"#396733",
"#AD9336",
"#805976",
"#BA737A",
"#725646",
"#88817D",
"#000000"
]
};

View File

@ -3,12 +3,14 @@ import { ColorPicker } from "../ColorPicker";
interface PanelColorProps { interface PanelColorProps {
title: string; title: string;
colorType: "canvasBackground" | "elementBackground" | "elementStroke";
colorValue: string | null; colorValue: string | null;
onColorChange: (value: string) => void; onColorChange: (value: string) => void;
} }
export const PanelColor: React.FC<PanelColorProps> = ({ export const PanelColor: React.FC<PanelColorProps> = ({
title, title,
colorType,
onColorChange, onColorChange,
colorValue colorValue
}) => { }) => {
@ -16,6 +18,7 @@ export const PanelColor: React.FC<PanelColorProps> = ({
<> <>
<h5>{title}</h5> <h5>{title}</h5>
<ColorPicker <ColorPicker
type={colorType}
color={colorValue} color={colorValue}
onChange={color => onColorChange(color)} onChange={color => onColorChange(color)}
/> />