material-theme-builder 2.1.2 → 2.2.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.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,57 @@
1
1
  import { CustomColor, TonalPalette } from '@material/material-color-utilities';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ export { ExportButton, Mcu, useMcu } from './react.js';
3
3
 
4
+ /** DTCG color value (direct, non-alias) */
5
+ type DtcgColorValue = {
6
+ colorSpace: string;
7
+ components: number[];
8
+ alpha: number;
9
+ hex: string;
10
+ };
11
+ /** A single DTCG color token */
12
+ type DtcgColorToken = {
13
+ $type: "color";
14
+ $value: string | DtcgColorValue;
15
+ $description?: string;
16
+ $extensions: Record<string, unknown>;
17
+ };
18
+ /** A palette group: tone number → token */
19
+ type DtcgPaletteGroup = Record<string, DtcgColorToken>;
20
+ /** Direct RGBA color value for a Figma variable */
21
+ type FigmaVariableColor = {
22
+ r: number;
23
+ g: number;
24
+ b: number;
25
+ a: number;
26
+ };
27
+ /** Alias reference to another Figma variable by path */
28
+ type FigmaVariableAlias = {
29
+ alias: string;
30
+ };
31
+ /** A per-mode value: either a direct color or an alias */
32
+ type FigmaVariableValue = FigmaVariableColor | FigmaVariableAlias;
33
+ /** A flat variable descriptor ready for the Figma Variables API */
34
+ type FigmaVariable = {
35
+ path: string;
36
+ description?: string;
37
+ scopes?: string[];
38
+ values: Record<string, FigmaVariableValue>;
39
+ };
40
+
41
+ /** Options for the Tailwind CSS exporter. */
42
+ type TailwindOptions = {
43
+ /** When true, append a shadcn CSS variable block after the Tailwind theme. */
44
+ shadcn?: boolean;
45
+ };
46
+
47
+ /** A custom color defined with a hex string instead of an ARGB integer. */
4
48
  type HexCustomColor = Omit<CustomColor, "value"> & {
5
49
  hex: string;
6
50
  };
51
+ /** Available Material You color scheme variants. */
52
+ declare const schemeNames: readonly ["tonalSpot", "monochrome", "neutral", "vibrant", "expressive", "fidelity", "content"];
53
+ type SchemeName = (typeof schemeNames)[number];
54
+ /** Configuration for the Material Color Utilities builder. */
7
55
  type McuConfig = {
8
56
  /** Source color in hex format (e.g., "#6750A4") used to generate the color scheme */
9
57
  source: string;
@@ -44,63 +92,22 @@ type McuConfig = {
44
92
  */
45
93
  prefix?: string;
46
94
  };
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;
95
+ /**
96
+ * Build a Material You color theme from a hex source color.
97
+ *
98
+ * Returns an object with lazy accessors for CSS, JSON, Figma variables,
99
+ * and Figma DTCG tokens.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const theme = builder("#6750A4");
104
+ * const css = theme.toCss();
105
+ * const json = theme.toJson();
106
+ * ```
107
+ */
101
108
  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(): {
109
+ toCss: () => string;
110
+ toJson: () => {
104
111
  seed: string;
105
112
  coreColors: Record<string, string>;
106
113
  extendedColors: {
@@ -112,54 +119,33 @@ declare function builder(hexSource: McuConfig["source"], { scheme, contrast, pri
112
119
  schemes: Record<string, Record<string, string>>;
113
120
  palettes: Record<string, Record<string, string>>;
114
121
  };
115
- toFigmaTokens(): {
122
+ toFigmaVariables: () => FigmaVariable[];
123
+ toFigmaTokens: () => {
116
124
  "Light.tokens.json": {
125
+ $extensions: {
126
+ "com.figma.modeName": string;
127
+ };
117
128
  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
- }>>;
129
+ palette: Record<string, DtcgPaletteGroup>;
131
130
  };
132
131
  sys: {
133
- color: Record<string, unknown>;
132
+ color: Record<string, DtcgColorToken>;
134
133
  };
134
+ };
135
+ "Dark.tokens.json": {
135
136
  $extensions: {
136
137
  "com.figma.modeName": string;
137
138
  };
138
- };
139
- "Dark.tokens.json": {
140
139
  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
- }>>;
140
+ palette: Record<string, DtcgPaletteGroup>;
154
141
  };
155
142
  sys: {
156
- color: Record<string, unknown>;
157
- };
158
- $extensions: {
159
- "com.figma.modeName": string;
143
+ color: Record<string, DtcgColorToken>;
160
144
  };
161
145
  };
162
146
  };
147
+ toTailwind: (options?: TailwindOptions) => string;
148
+ toFlutter: () => string;
163
149
  mergedColorsLight: {
164
150
  [x: string]: number;
165
151
  };
@@ -176,16 +162,4 @@ declare function builder(hexSource: McuConfig["source"], { scheme, contrast, pri
176
162
  };
177
163
  };
178
164
 
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 };
165
+ export { builder };