@@ -88,13 +88,7 @@ const bestColors = {
8888 } ,
8989}
9090export type StandardColors = ( typeof bestColors ) [ 'standardBlue' ]
91-
92- export const feature = '#cb166e'
93- export const custom = '#e35508'
94- export const info = '#15a9c0'
95- export const success = '#259740'
96- export const warning = '#c49a1c'
97- export const danger = '#a92a37'
91+ export type StandardColorPreset = Partial < StandardColors >
9892
9993export interface DeltaToneColors {
10094 canvas : number
@@ -143,16 +137,22 @@ export function createToneColors(
143137 }
144138}
145139
146- export function getStandardColors ( presets ?: readonly string [ ] ) : StandardColors {
147- let colors : StandardColors | undefined
140+ export function getStandardColors (
141+ presets ?: readonly string [ ] | StandardColorPreset ,
142+ ) : StandardColors {
148143 const defaultColors = bestColors . standardBlue
149- for ( const preset of presets ?? [ ] ) {
144+ if ( ! presets ) return defaultColors
145+ if ( ! Array . isArray ( presets ) ) {
146+ return merge ( defaultColors , presets )
147+ }
148+ let colors : StandardColors = defaultColors
149+ for ( const preset of presets ) {
150150 colors = merge (
151151 defaultColors ,
152152 bestColors [ preset as keyof typeof bestColors ] ?? defaultColors ,
153153 )
154154 }
155- return colors ?? defaultColors
155+ return colors
156156}
157157
158158function applyDeltaPresets (
@@ -172,13 +172,13 @@ function createStandardDarkCore(
172172 applyDeltaPresets ( presets , delta )
173173 const accentScale = createColorScale ( colors . accent , mode )
174174 const neutralScale = createColorScale ( colors . neutral , mode )
175- const featureScale = createColorScale ( feature , mode )
175+ const featureScale = createColorScale ( colors . feature , mode )
176176 const secondaryScale = createColorScale ( colors . secondary , mode )
177- const customScale = createColorScale ( custom , mode )
178- const infoScale = createColorScale ( info , mode )
179- const successScale = createColorScale ( success , mode )
180- const warningScale = createColorScale ( warning , mode )
181- const dangerScale = createColorScale ( danger , mode )
177+ const customScale = createColorScale ( colors . custom , mode )
178+ const infoScale = createColorScale ( colors . info , mode )
179+ const successScale = createColorScale ( colors . success , mode )
180+ const warningScale = createColorScale ( colors . warning , mode )
181+ const dangerScale = createColorScale ( colors . danger , mode )
182182
183183 return {
184184 neutral : createToneColors ( neutralScale [ toneIndex ] , neutralScale , delta ) ,
@@ -198,11 +198,16 @@ function createStandardDarkCore(
198198 }
199199}
200200
201- export function createStandardDark ( presets ?: readonly string [ ] ) {
201+ export function createStandardDark (
202+ presets ?: readonly string [ ] | StandardColorPreset ,
203+ ) {
202204 const colors = getStandardColors ( presets )
203205 return createStandardPalette ( {
204206 mode : 'dark' ,
205- core : createStandardDarkCore ( colors , presets ) ,
207+ core : createStandardDarkCore (
208+ colors ,
209+ Array . isArray ( presets ) ? presets : undefined ,
210+ ) ,
206211 accent : colors . accent ,
207212 chromeLighting : 0.33 ,
208213 borderAlpha : 0.66 ,
0 commit comments