11import oc from "open-color" ;
22
3+ import {
4+ COLOR_WHITE ,
5+ COLOR_CHARCOAL_BLACK ,
6+ COLOR_TRANSPARENT ,
7+ } from "./constants" ;
8+
39import type { Merge } from "./utility-types" ;
410
511export const COLOR_OUTLINE_CONTRAST_THRESHOLD = 240 ;
@@ -18,13 +24,18 @@ const pick = <R extends Record<string, any>, K extends readonly (keyof R)[]>(
1824} ;
1925
2026export type ColorPickerColor =
21- | Exclude < keyof oc , "indigo" | "lime" >
27+ | Exclude < keyof oc , "indigo" | "lime" | "black" >
2228 | "transparent"
29+ | "charcoal"
2330 | "bronze" ;
2431export type ColorTuple = readonly [ string , string , string , string , string ] ;
2532export type ColorPalette = Merge <
2633 Record < ColorPickerColor , ColorTuple > ,
27- { black : "#1e1e1e" ; white : "#ffffff" ; transparent : "transparent" }
34+ {
35+ charcoal : typeof COLOR_CHARCOAL_BLACK ;
36+ white : typeof COLOR_WHITE ;
37+ transparent : typeof COLOR_TRANSPARENT ;
38+ }
2839> ;
2940
3041// used general type instead of specific type (ColorPalette) to support custom colors
@@ -44,17 +55,17 @@ export const CANVAS_PALETTE_SHADE_INDEXES = [0, 1, 2, 3, 4] as const;
4455export const getSpecificColorShades = (
4556 color : Exclude <
4657 ColorPickerColor ,
47- "transparent" | "white " | "black" | "bronze"
58+ "transparent" | "charcoal " | "black" | "white " | "bronze"
4859 > ,
4960 indexArr : Readonly < ColorShadesIndexes > ,
5061) => {
5162 return indexArr . map ( ( index ) => oc [ color ] [ index ] ) as any as ColorTuple ;
5263} ;
5364
5465export const COLOR_PALETTE = {
55- transparent : "transparent" ,
56- black : "#1e1e1e" ,
57- white : "#ffffff" ,
66+ transparent : COLOR_TRANSPARENT ,
67+ charcoal : COLOR_CHARCOAL_BLACK ,
68+ white : COLOR_WHITE ,
5869 // open-colors
5970 gray : getSpecificColorShades ( "gray" , ELEMENTS_PALETTE_SHADE_INDEXES ) ,
6071 red : getSpecificColorShades ( "red" , ELEMENTS_PALETTE_SHADE_INDEXES ) ,
@@ -90,7 +101,7 @@ const COMMON_ELEMENT_SHADES = pick(COLOR_PALETTE, [
90101
91102// ORDER matters for positioning in quick picker
92103export const DEFAULT_ELEMENT_STROKE_PICKS = [
93- COLOR_PALETTE . black ,
104+ COLOR_PALETTE . charcoal ,
94105 COLOR_PALETTE . red [ DEFAULT_ELEMENT_STROKE_COLOR_INDEX ] ,
95106 COLOR_PALETTE . green [ DEFAULT_ELEMENT_STROKE_COLOR_INDEX ] ,
96107 COLOR_PALETTE . blue [ DEFAULT_ELEMENT_STROKE_COLOR_INDEX ] ,
@@ -128,7 +139,7 @@ export const DEFAULT_ELEMENT_STROKE_COLOR_PALETTE = {
128139 transparent : COLOR_PALETTE . transparent ,
129140 white : COLOR_PALETTE . white ,
130141 gray : COLOR_PALETTE . gray ,
131- black : COLOR_PALETTE . black ,
142+ charcoal : COLOR_PALETTE . charcoal ,
132143 bronze : COLOR_PALETTE . bronze ,
133144 // rest
134145 ...COMMON_ELEMENT_SHADES ,
@@ -139,7 +150,7 @@ export const DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE = {
139150 transparent : COLOR_PALETTE . transparent ,
140151 white : COLOR_PALETTE . white ,
141152 gray : COLOR_PALETTE . gray ,
142- black : COLOR_PALETTE . black ,
153+ charcoal : COLOR_PALETTE . charcoal ,
143154 bronze : COLOR_PALETTE . bronze ,
144155
145156 ...COMMON_ELEMENT_SHADES ,
0 commit comments