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