Skip to content

Commit 4458fc7

Browse files
committed
Turn ColorMode into an interface and update comment
- Interfaces support declaration merging, and thus are superior in this case. An user can add his own color names. The index signature might be removed some day for "strict mode". - The comment is outdated. - Smaller types in tooltips lead to more readable type errors.
1 parent 4ff2eb1 commit 4458fc7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/css/src/types.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -489,18 +489,10 @@ type ObjectOrArray<T> = T[] | { [K: string]: T | ObjectOrArray<T> }
489489
export type TLengthStyledSystem = string | 0 | number
490490

491491
/**
492-
* To use Theme UI color modes, color scales should include at least a text
493-
* and background color. These values are used in the ColorMode component to
494-
* set body foreground and background colors. Color modes should be defined as
495-
* nested objects within a theme.colors.modes object. Each key in this object
496-
* should correspond to a color mode name, where the name can be anything, but
497-
* typically light and dark are used for applications with a dark mode. The
498-
* initialColorModeName key is required to enable color modes and will be used as
499-
* the name for the root color palette.
492+
* Color modes can be used to create a user-configurable dark mode
493+
* or any number of other color modes.
500494
*/
501-
export type ColorMode = {
502-
[k: string]: CSS.ColorProperty | ObjectOrArray<CSS.ColorProperty>
503-
} & {
495+
export interface ColorMode {
504496
/**
505497
* Body background color
506498
*/
@@ -531,6 +523,8 @@ export type ColorMode = {
531523
* A contrast color for emphasizing UI
532524
*/
533525
accent?: CSS.ColorProperty
526+
527+
[k: string]: CSS.ColorProperty | ObjectOrArray<CSS.ColorProperty>
534528
}
535529

536530
export interface Theme {

0 commit comments

Comments
 (0)