material-theme-builder 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,191 @@
1
+ import { CustomColor, TonalPalette } from '@material/material-color-utilities';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ type HexCustomColor = Omit<CustomColor, "value"> & {
5
+ hex: string;
6
+ };
7
+ type McuConfig = {
8
+ /** Source color in hex format (e.g., "#6750A4") used to generate the color scheme */
9
+ source: string;
10
+ /** Color scheme variant. Default: "tonalSpot" */
11
+ scheme?: SchemeName;
12
+ /** Contrast level from -1.0 (reduced) to 1.0 (increased). Default: 0 (standard) */
13
+ contrast?: number;
14
+ /** Primary color - the main brand color. Overrides the default palette generation. */
15
+ primary?: string;
16
+ /** Secondary color - accent color. Overrides the default palette generation. */
17
+ secondary?: string;
18
+ /** Tertiary color - additional accent color. Overrides the default palette generation. */
19
+ tertiary?: string;
20
+ /** Neutral color - used for surfaces. Overrides the default palette generation. */
21
+ neutral?: string;
22
+ /** Neutral variant color - used for surfaces with slight tint. Overrides the default palette generation. */
23
+ neutralVariant?: string;
24
+ /** Error color - used for error states. Overrides the default palette generation. */
25
+ error?: string;
26
+ /**
27
+ * Color match mode for core colors.
28
+ * When true, stays true to input colors without harmonization.
29
+ * When false (default), colors may be adjusted for better harmonization.
30
+ * Corresponds to "Color match - Stay true to my color inputs" in Material Theme Builder.
31
+ *
32
+ * @deprecated Not yet implemented. This prop is currently ignored.
33
+ */
34
+ colorMatch?: boolean;
35
+ /**
36
+ * Array of custom colors to include in the generated palette.
37
+ * Each custom color can be blended with the source color for harmonization.
38
+ */
39
+ customColors?: HexCustomColor[];
40
+ /**
41
+ * Prefix for generated CSS custom properties and Figma token css.variable extensions.
42
+ * Scheme tokens use `--{prefix}-sys-color-*`, palette tones use `--{prefix}-ref-palette-*`.
43
+ * Default: "md" (Material Design convention).
44
+ */
45
+ prefix?: string;
46
+ };
47
+ declare const schemeNames: readonly ["tonalSpot", "monochrome", "neutral", "vibrant", "expressive", "fidelity", "content"];
48
+ type SchemeName = (typeof schemeNames)[number];
49
+ declare const tokenDescriptions: {
50
+ readonly background: "Default background color for screens and large surfaces.";
51
+ readonly error: "Color for error states, used on elements like error text and icons.";
52
+ readonly errorContainer: "Fill color for error container elements like error banners.";
53
+ readonly inverseOnSurface: "Color for text and icons on inverse surface backgrounds.";
54
+ readonly inversePrimary: "Primary color used on inverse surface, e.g. buttons on snackbars.";
55
+ readonly inverseSurface: "Background for elements that require reverse contrast, such as snackbars.";
56
+ readonly onBackground: "Color for text and icons displayed on the background.";
57
+ readonly onError: "Color for text and icons on error-colored elements.";
58
+ readonly onErrorContainer: "Color for text and icons on error container elements.";
59
+ readonly onPrimary: "Color for text and icons on primary-colored elements like filled buttons.";
60
+ readonly onPrimaryContainer: "Color for text and icons on primary container elements like tonal buttons.";
61
+ readonly onPrimaryFixed: "Color for text and icons on primary fixed elements, constant across themes.";
62
+ readonly onPrimaryFixedVariant: "Lower-emphasis color for text and icons on primary fixed elements.";
63
+ readonly onSecondary: "Color for text and icons on secondary-colored elements.";
64
+ readonly onSecondaryContainer: "Color for text and icons on secondary container elements.";
65
+ readonly onSecondaryFixed: "Color for text and icons on secondary fixed elements, constant across themes.";
66
+ readonly onSecondaryFixedVariant: "Lower-emphasis color for text and icons on secondary fixed elements.";
67
+ readonly onSurface: "High-emphasis color for text and icons on surface backgrounds.";
68
+ readonly onSurfaceVariant: "Medium-emphasis color for text and icons on surface variant backgrounds.";
69
+ readonly onTertiary: "Color for text and icons on tertiary-colored elements.";
70
+ readonly onTertiaryContainer: "Color for text and icons on tertiary container elements.";
71
+ readonly onTertiaryFixed: "Color for text and icons on tertiary fixed elements, constant across themes.";
72
+ readonly onTertiaryFixedVariant: "Lower-emphasis color for text and icons on tertiary fixed elements.";
73
+ readonly outline: "Subtle color for borders and dividers to create visual separation.";
74
+ readonly outlineVariant: "Lower-emphasis border color used for decorative dividers.";
75
+ readonly primary: "Main brand color, used for key components like filled buttons and active states.";
76
+ readonly primaryContainer: "Fill color for large primary elements like cards and tonal buttons.";
77
+ readonly primaryFixed: "Fixed primary color that stays the same in light and dark themes.";
78
+ readonly primaryFixedDim: "Dimmed variant of the fixed primary color for lower emphasis.";
79
+ readonly scrim: "Color overlay for modals and dialogs to obscure background content.";
80
+ readonly secondary: "Accent color for less prominent elements like filter chips and selections.";
81
+ readonly secondaryContainer: "Fill color for secondary container elements like tonal buttons and input fields.";
82
+ readonly secondaryFixed: "Fixed secondary color that stays the same in light and dark themes.";
83
+ readonly secondaryFixedDim: "Dimmed variant of the fixed secondary color for lower emphasis.";
84
+ readonly shadow: "Color for elevation shadows applied to surfaces and components.";
85
+ readonly surface: "Default surface color for cards, sheets, and dialogs.";
86
+ readonly surfaceBright: "Brightest surface variant, used for elevated surfaces in dark themes.";
87
+ readonly surfaceContainer: "Middle-emphasis container color for grouping related content.";
88
+ readonly surfaceContainerHigh: "Higher-emphasis container color for elements like cards.";
89
+ readonly surfaceContainerHighest: "Highest-emphasis container color for text fields and other input areas.";
90
+ readonly surfaceContainerLow: "Lower-emphasis container color for subtle surface groupings.";
91
+ readonly surfaceContainerLowest: "Lowest-emphasis container, typically the lightest surface in light theme.";
92
+ readonly surfaceDim: "Dimmest surface variant, used for recessed areas or dark theme backgrounds.";
93
+ readonly surfaceTint: "Tint color applied to surfaces for subtle primary color elevation overlay.";
94
+ readonly surfaceVariant: "Alternative surface color for differentiated areas like sidebar backgrounds.";
95
+ readonly tertiary: "Third accent color for complementary elements that balance primary and secondary.";
96
+ readonly tertiaryContainer: "Fill color for tertiary container elements like complementary cards.";
97
+ readonly tertiaryFixed: "Fixed tertiary color that stays the same in light and dark themes.";
98
+ readonly tertiaryFixedDim: "Dimmed variant of the fixed tertiary color for lower emphasis.";
99
+ };
100
+ type TokenName = keyof typeof tokenDescriptions;
101
+ declare function builder(hexSource: McuConfig["source"], { scheme, contrast, primary, secondary, tertiary, neutral, neutralVariant, error, customColors: hexCustomColors, prefix, }?: Omit<McuConfig, "source">): {
102
+ toCss(): string;
103
+ toJson(): {
104
+ seed: string;
105
+ coreColors: Record<string, string>;
106
+ extendedColors: {
107
+ name: string;
108
+ color: string;
109
+ description: string;
110
+ harmonized: boolean;
111
+ }[];
112
+ schemes: Record<string, Record<string, string>>;
113
+ palettes: Record<string, Record<string, string>>;
114
+ };
115
+ toFigmaTokens(): {
116
+ "Light.tokens.json": {
117
+ ref: {
118
+ palette: Record<string, Record<string, {
119
+ $type: "color";
120
+ $value: {
121
+ colorSpace: "srgb";
122
+ components: number[];
123
+ alpha: number;
124
+ hex: string;
125
+ };
126
+ $extensions: {
127
+ "com.figma.scopes": string[];
128
+ "com.figma.isOverride": boolean;
129
+ };
130
+ }>>;
131
+ };
132
+ sys: {
133
+ color: Record<string, unknown>;
134
+ };
135
+ $extensions: {
136
+ "com.figma.modeName": string;
137
+ };
138
+ };
139
+ "Dark.tokens.json": {
140
+ ref: {
141
+ palette: Record<string, Record<string, {
142
+ $type: "color";
143
+ $value: {
144
+ colorSpace: "srgb";
145
+ components: number[];
146
+ alpha: number;
147
+ hex: string;
148
+ };
149
+ $extensions: {
150
+ "com.figma.scopes": string[];
151
+ "com.figma.isOverride": boolean;
152
+ };
153
+ }>>;
154
+ };
155
+ sys: {
156
+ color: Record<string, unknown>;
157
+ };
158
+ $extensions: {
159
+ "com.figma.modeName": string;
160
+ };
161
+ };
162
+ };
163
+ mergedColorsLight: {
164
+ [x: string]: number;
165
+ };
166
+ mergedColorsDark: {
167
+ [x: string]: number;
168
+ };
169
+ allPalettes: {
170
+ primary: TonalPalette;
171
+ secondary: TonalPalette;
172
+ tertiary: TonalPalette;
173
+ error: TonalPalette;
174
+ neutral: TonalPalette;
175
+ "neutral-variant": TonalPalette;
176
+ };
177
+ };
178
+
179
+ declare function Mcu({ source, scheme, contrast, primary, secondary, tertiary, neutral, neutralVariant, error, colorMatch, customColors, prefix, children, }: McuConfig & {
180
+ children?: React.ReactNode;
181
+ }): react_jsx_runtime.JSX.Element;
182
+
183
+ type Api = {
184
+ initials: McuConfig;
185
+ setMcuConfig: (config: McuConfig) => void;
186
+ getMcuColor: (colorName: TokenName, theme?: string) => string;
187
+ allPalettes: Record<string, TonalPalette>;
188
+ };
189
+ declare const useMcu: () => Api;
190
+
191
+ export { Mcu, builder, useMcu };