@trishchuk/coolors-mcp 1.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/.claude/settings.local.json +39 -0
- package/.env +2 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +73 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +71 -0
- package/.github/pull_request_template.md +97 -0
- package/.github/workflows/ci.yml +127 -0
- package/.github/workflows/deploy-docs.yml +56 -0
- package/.github/workflows/release.yml +99 -0
- package/.mcp.json +12 -0
- package/.prettierignore +1 -0
- package/CLAUDE.md +201 -0
- package/DOCUMENTATION.md +274 -0
- package/GEMINI.md +54 -0
- package/LICENSE +21 -0
- package/README.md +401 -0
- package/demo/content_based_color.png +0 -0
- package/demo/music-player.html +621 -0
- package/demo/podcast-player.html +903 -0
- package/dist/bin/coolors-mcp.d.ts +1 -0
- package/dist/bin/coolors-mcp.js +154 -0
- package/dist/bin/coolors-mcp.js.map +1 -0
- package/dist/bin/server.d.ts +1 -0
- package/dist/bin/server.js +3292 -0
- package/dist/bin/server.js.map +1 -0
- package/dist/chunk-IQ7NN26V.js +114 -0
- package/dist/chunk-IQ7NN26V.js.map +1 -0
- package/dist/chunk-P3ARRKLS.js +1214 -0
- package/dist/chunk-P3ARRKLS.js.map +1 -0
- package/dist/color/index.d.ts +716 -0
- package/dist/color/index.js +153 -0
- package/dist/color/index.js.map +1 -0
- package/dist/coolors-mcp.d.ts +136 -0
- package/dist/coolors-mcp.js +7 -0
- package/dist/coolors-mcp.js.map +1 -0
- package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js +93 -0
- package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js.map +7 -0
- package/docs/.vitepress/cache/deps/_metadata.json +127 -0
- package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js +9 -0
- package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js +12683 -0
- package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js.map +7 -0
- package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js +9719 -0
- package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js.map +7 -0
- package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js +4710 -0
- package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js.map +7 -0
- package/docs/.vitepress/cache/deps/cytoscape.js +30278 -0
- package/docs/.vitepress/cache/deps/cytoscape.js.map +7 -0
- package/docs/.vitepress/cache/deps/dayjs.js +285 -0
- package/docs/.vitepress/cache/deps/dayjs.js.map +7 -0
- package/docs/.vitepress/cache/deps/debug.js +468 -0
- package/docs/.vitepress/cache/deps/debug.js.map +7 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/prismjs.js +1466 -0
- package/docs/.vitepress/cache/deps/prismjs.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js +228 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js +142 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js +27 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js +65 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js +53 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js.map +7 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js +73 -0
- package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4507 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +584 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +1146 -0
- package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +1667 -0
- package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js.map +7 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js +1814 -0
- package/docs/.vitepress/cache/deps/vitepress___minisearch.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +344 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/components/ClientGrid.vue +125 -0
- package/docs/.vitepress/components/CodeBlock.vue +231 -0
- package/docs/.vitepress/components/ConfigModal.vue +477 -0
- package/docs/.vitepress/components/DiagramModal.vue +528 -0
- package/docs/.vitepress/components/TroubleshootingModal.vue +472 -0
- package/docs/.vitepress/config.js +162 -0
- package/docs/.vitepress/theme/FundingLayout.vue +251 -0
- package/docs/.vitepress/theme/Layout.vue +134 -0
- package/docs/.vitepress/theme/components/AdBanner.vue +317 -0
- package/docs/.vitepress/theme/components/AdPlaceholder.vue +78 -0
- package/docs/.vitepress/theme/components/FundingEffects.vue +322 -0
- package/docs/.vitepress/theme/components/FundingHero.vue +345 -0
- package/docs/.vitepress/theme/components/SupportSection.vue +511 -0
- package/docs/.vitepress/theme/custom-app.css +339 -0
- package/docs/.vitepress/theme/custom.css +699 -0
- package/docs/.vitepress/theme/index.js +25 -0
- package/docs/README.md +198 -0
- package/docs/concepts/accessibility.md +473 -0
- package/docs/concepts/color-spaces.md +222 -0
- package/docs/concepts/distance-metrics.md +384 -0
- package/docs/concepts/hct.md +261 -0
- package/docs/concepts/image-analysis.md +396 -0
- package/docs/concepts/material-design.md +306 -0
- package/docs/concepts/theme-matching.md +399 -0
- package/docs/examples/basic-colors.md +490 -0
- package/docs/examples/creating-themes.md +898 -0
- package/docs/examples/css-refactoring.md +824 -0
- package/docs/examples/image-extraction.md +882 -0
- package/docs/getting-started.md +366 -0
- package/docs/index.md +190 -0
- package/docs/installation.md +157 -0
- package/docs/tools/README.md +234 -0
- package/docs/tools/accessibility.md +614 -0
- package/docs/tools/color-operations.md +374 -0
- package/docs/tools/image-extraction.md +624 -0
- package/docs/tools/material-design.md +347 -0
- package/docs/tools/theme-matching.md +552 -0
- package/eslint.config.ts +14 -0
- package/examples/theme-matching.md +113 -0
- package/jsr.json +7 -0
- package/mcp-config.json +8 -0
- package/note.md +35 -0
- package/package.json +122 -0
- package/research_results.md +53 -0
- package/src/bin/coolors-mcp.ts +194 -0
- package/src/bin/server.ts +61 -0
- package/src/color/__tests__/conversions-argb.test.ts +198 -0
- package/src/color/__tests__/extract-colors.test.ts +360 -0
- package/src/color/__tests__/image-utils.test.ts +242 -0
- package/src/color/__tests__/reference-colors.test.ts +278 -0
- package/src/color/__tests__/round-trip.test.ts +197 -0
- package/src/color/conversions.test.ts +402 -0
- package/src/color/conversions.ts +393 -0
- package/src/color/dislike/__tests__/dislike-analyzer.test.ts +248 -0
- package/src/color/dislike/dislike-analyzer.ts +114 -0
- package/src/color/extract-colors.ts +228 -0
- package/src/color/hct/__tests__/hct-class.test.ts +232 -0
- package/src/color/hct/harmonization.ts +204 -0
- package/src/color/hct/hct-class.ts +109 -0
- package/src/color/hct/hct-solver.ts +168 -0
- package/src/color/hct/index.ts +39 -0
- package/src/color/hct/tonal-palette.ts +211 -0
- package/src/color/hct/types.ts +88 -0
- package/src/color/image-utils.ts +79 -0
- package/src/color/index.ts +87 -0
- package/src/color/material-theme.ts +157 -0
- package/src/color/metrics.test.ts +276 -0
- package/src/color/metrics.ts +281 -0
- package/src/color/quantize/__tests__/quantizer_celebi.test.ts +195 -0
- package/src/color/quantize/lab_point_provider.ts +55 -0
- package/src/color/quantize/point_provider.ts +27 -0
- package/src/color/quantize/quantizer_celebi.ts +51 -0
- package/src/color/quantize/quantizer_celebi_test.ts +71 -0
- package/src/color/quantize/quantizer_map.ts +47 -0
- package/src/color/quantize/quantizer_wsmeans.ts +232 -0
- package/src/color/quantize/quantizer_wu.ts +472 -0
- package/src/color/score/__tests__/score.test.ts +224 -0
- package/src/color/score/score.ts +175 -0
- package/src/color/types.ts +151 -0
- package/src/color/utils/color_utils.ts +292 -0
- package/src/color/utils/math_utils.ts +145 -0
- package/src/color/utils.test.ts +403 -0
- package/src/color/utils.ts +315 -0
- package/src/constants.ts +5 -0
- package/src/coolors-mcp.ts +37 -0
- package/src/examples/addition.ts +333 -0
- package/src/examples/color-demo.ts +125 -0
- package/src/examples/custom-logger.ts +201 -0
- package/src/examples/oauth-server.ts +113 -0
- package/src/examples/session-context.ts +269 -0
- package/src/session.ts +116 -0
- package/src/theme/__tests__/matcher.test.ts +180 -0
- package/src/theme/__tests__/parser.test.ts +148 -0
- package/src/theme/__tests__/refactor.test.ts +224 -0
- package/src/theme/index.ts +34 -0
- package/src/theme/matcher.ts +395 -0
- package/src/theme/parser.ts +392 -0
- package/src/theme/refactor.ts +360 -0
- package/src/theme/types.ts +152 -0
- package/src/tools/__tests__/gradient-generator.test.ts +206 -0
- package/src/tools/__tests__/palette-with-locks.test.ts +109 -0
- package/src/tools/color-conversion.tool.ts +54 -0
- package/src/tools/color-distance.tool.ts +41 -0
- package/src/tools/colors.ts +31 -0
- package/src/tools/contrast-checker.tool.ts +37 -0
- package/src/tools/dislike-analyzer.tool.ts +247 -0
- package/src/tools/gradient-generator.tool.ts +250 -0
- package/src/tools/image-extraction.tools.ts +289 -0
- package/src/tools/index.ts +39 -0
- package/src/tools/material-theme.tools.ts +250 -0
- package/src/tools/palette-generator.tool.ts +135 -0
- package/src/tools/palette-with-locks.tool.ts +221 -0
- package/src/tools/registry.ts +142 -0
- package/src/tools/simple-tools.ts +37 -0
- package/src/tools/theme-matching.tools.ts +334 -0
- package/src/types.ts +182 -0
- package/src/utils.ts +22 -0
- package/tsconfig.json +8 -0
- package/vitest.config.js +15 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# Material Design Tools
|
|
2
|
+
|
|
3
|
+
Tools for generating Material Design 3 themes, tonal palettes, and color harmonization.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### `generate_material_theme`
|
|
8
|
+
|
|
9
|
+
Generate a complete Material Design 3 color theme from a source color.
|
|
10
|
+
|
|
11
|
+
#### Parameters
|
|
12
|
+
|
|
13
|
+
| Parameter | Type | Required | Default | Description |
|
|
14
|
+
| --------------------- | ------- | -------- | ------- | ------------------------------- |
|
|
15
|
+
| `sourceColor` | string | Yes | - | Base color for theme generation |
|
|
16
|
+
| `includeCustomColors` | boolean | No | false | Include custom color palettes |
|
|
17
|
+
|
|
18
|
+
#### Returns
|
|
19
|
+
|
|
20
|
+
Complete theme object with light and dark schemes:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
{
|
|
24
|
+
"schemes": {
|
|
25
|
+
"light": {
|
|
26
|
+
"primary": "#6750a4",
|
|
27
|
+
"onPrimary": "#ffffff",
|
|
28
|
+
"primaryContainer": "#e9ddff",
|
|
29
|
+
"onPrimaryContainer": "#22005d",
|
|
30
|
+
"secondary": "#625b71",
|
|
31
|
+
"onSecondary": "#ffffff",
|
|
32
|
+
"secondaryContainer": "#e8def8",
|
|
33
|
+
"onSecondaryContainer": "#1e192b",
|
|
34
|
+
"tertiary": "#7e5260",
|
|
35
|
+
"onTertiary": "#ffffff",
|
|
36
|
+
"tertiaryContainer": "#ffd9e3",
|
|
37
|
+
"onTertiaryContainer": "#31101d",
|
|
38
|
+
"error": "#ba1a1a",
|
|
39
|
+
"onError": "#ffffff",
|
|
40
|
+
"errorContainer": "#ffdad6",
|
|
41
|
+
"onErrorContainer": "#410002",
|
|
42
|
+
"background": "#fffbff",
|
|
43
|
+
"onBackground": "#1c1b1e",
|
|
44
|
+
"surface": "#fffbff",
|
|
45
|
+
"onSurface": "#1c1b1e",
|
|
46
|
+
"surfaceVariant": "#e7e0eb",
|
|
47
|
+
"onSurfaceVariant": "#49454e",
|
|
48
|
+
"outline": "#7a757f"
|
|
49
|
+
},
|
|
50
|
+
"dark": {
|
|
51
|
+
// Dark theme colors...
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"sourceColor": "#6750a4"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Color Roles Explained
|
|
59
|
+
|
|
60
|
+
| Role | Purpose | Light Theme | Dark Theme |
|
|
61
|
+
| ------------------ | --------------------- | ----------- | ---------- |
|
|
62
|
+
| `primary` | Main brand color | Tone 40 | Tone 80 |
|
|
63
|
+
| `onPrimary` | Text on primary | Tone 100 | Tone 20 |
|
|
64
|
+
| `primaryContainer` | Primary surface | Tone 90 | Tone 30 |
|
|
65
|
+
| `secondary` | Supporting color | Tone 40 | Tone 80 |
|
|
66
|
+
| `tertiary` | Accent color | Tone 40 | Tone 80 |
|
|
67
|
+
| `error` | Error states | #ba1a1a | #ffb4ab |
|
|
68
|
+
| `surface` | Card/sheet background | Tone 99 | Tone 10 |
|
|
69
|
+
| `background` | App background | Tone 99 | Tone 10 |
|
|
70
|
+
| `outline` | Borders/dividers | Tone 50 | Tone 60 |
|
|
71
|
+
|
|
72
|
+
#### Examples
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Generate theme from brand color
|
|
76
|
+
{
|
|
77
|
+
"sourceColor": "#6750a4"
|
|
78
|
+
}
|
|
79
|
+
// Returns complete Material Design 3 theme
|
|
80
|
+
|
|
81
|
+
// Include custom colors
|
|
82
|
+
{
|
|
83
|
+
"sourceColor": "#00695c",
|
|
84
|
+
"includeCustomColors": true
|
|
85
|
+
}
|
|
86
|
+
// Returns theme with additional custom palettes
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Use Cases
|
|
90
|
+
|
|
91
|
+
- Creating consistent app themes
|
|
92
|
+
- Implementing Material Design 3
|
|
93
|
+
- Generating light/dark mode variants
|
|
94
|
+
- Ensuring accessible color combinations
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### `generate_tonal_palette`
|
|
99
|
+
|
|
100
|
+
Generate Material Design tonal palette from a color.
|
|
101
|
+
|
|
102
|
+
#### Parameters
|
|
103
|
+
|
|
104
|
+
| Parameter | Type | Required | Default | Description |
|
|
105
|
+
| --------- | -------- | -------- | ---------------------------------------- | ----------------------- |
|
|
106
|
+
| `color` | string | Yes | - | Base color for palette |
|
|
107
|
+
| `tones` | number[] | No | [0,10,20,30,40,50,60,70,80,90,95,99,100] | Tone values to generate |
|
|
108
|
+
|
|
109
|
+
#### Returns
|
|
110
|
+
|
|
111
|
+
Object mapping tone values to colors:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
{
|
|
115
|
+
"0": "#000000",
|
|
116
|
+
"10": "#22005d",
|
|
117
|
+
"20": "#381e72",
|
|
118
|
+
"30": "#4f378a",
|
|
119
|
+
"40": "#6750a4",
|
|
120
|
+
"50": "#8069bf",
|
|
121
|
+
"60": "#9a83db",
|
|
122
|
+
"70": "#b59df7",
|
|
123
|
+
"80": "#cfbcff",
|
|
124
|
+
"90": "#e9ddff",
|
|
125
|
+
"95": "#f6edff",
|
|
126
|
+
"99": "#fffbff",
|
|
127
|
+
"100": "#ffffff"
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Tone Values
|
|
132
|
+
|
|
133
|
+
Material Design 3 standard tones:
|
|
134
|
+
|
|
135
|
+
- **0**: Pure black
|
|
136
|
+
- **10**: Very dark
|
|
137
|
+
- **20-40**: Dark tones (primary colors in light theme)
|
|
138
|
+
- **50**: Mid-tone
|
|
139
|
+
- **60-80**: Light tones (primary colors in dark theme)
|
|
140
|
+
- **90-95**: Very light (containers in light theme)
|
|
141
|
+
- **99**: Near white (surfaces)
|
|
142
|
+
- **100**: Pure white
|
|
143
|
+
|
|
144
|
+
#### Examples
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Standard Material tones
|
|
148
|
+
{
|
|
149
|
+
"color": "#6750a4"
|
|
150
|
+
}
|
|
151
|
+
// Returns 13 standard tones
|
|
152
|
+
|
|
153
|
+
// Custom tone values
|
|
154
|
+
{
|
|
155
|
+
"color": "#00695c",
|
|
156
|
+
"tones": [0, 25, 50, 75, 100]
|
|
157
|
+
}
|
|
158
|
+
// Returns 5 custom tones
|
|
159
|
+
|
|
160
|
+
// Extended tones for granular control
|
|
161
|
+
{
|
|
162
|
+
"color": "#e91e63",
|
|
163
|
+
"tones": [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 92, 94, 96, 98, 99, 100]
|
|
164
|
+
}
|
|
165
|
+
// Returns 25 tones
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Use Cases
|
|
169
|
+
|
|
170
|
+
- Creating component state variations
|
|
171
|
+
- Building custom Material palettes
|
|
172
|
+
- Generating accessible color ramps
|
|
173
|
+
- Ensuring consistent tone progression
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### `harmonize_colors`
|
|
178
|
+
|
|
179
|
+
Harmonize multiple colors to work better together.
|
|
180
|
+
|
|
181
|
+
#### Parameters
|
|
182
|
+
|
|
183
|
+
| Parameter | Type | Required | Default | Description |
|
|
184
|
+
| --------- | -------- | -------- | ----------- | ------------------------------------------- |
|
|
185
|
+
| `colors` | string[] | Yes | - | Array of colors to harmonize |
|
|
186
|
+
| `method` | enum | No | "harmonize" | Method: "blend", "harmonize", "temperature" |
|
|
187
|
+
| `factor` | number | No | 0.5 | Harmonization strength (0-1) |
|
|
188
|
+
|
|
189
|
+
#### Returns
|
|
190
|
+
|
|
191
|
+
Array of harmonized colors in hex format.
|
|
192
|
+
|
|
193
|
+
#### Harmonization Methods
|
|
194
|
+
|
|
195
|
+
- **blend**: Mix colors together for consistency
|
|
196
|
+
- **harmonize**: Shift hues toward a common direction
|
|
197
|
+
- **temperature**: Adjust color temperature uniformly
|
|
198
|
+
|
|
199
|
+
#### Factor Values
|
|
200
|
+
|
|
201
|
+
- **0.0**: No change (original colors)
|
|
202
|
+
- **0.5**: Moderate harmonization (default)
|
|
203
|
+
- **1.0**: Maximum harmonization
|
|
204
|
+
|
|
205
|
+
#### Examples
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Harmonize brand colors
|
|
209
|
+
{
|
|
210
|
+
"colors": ["#ff6b6b", "#4ecdc4", "#45b7d1"],
|
|
211
|
+
"method": "harmonize",
|
|
212
|
+
"factor": 0.5
|
|
213
|
+
}
|
|
214
|
+
// Returns colors shifted toward common hue
|
|
215
|
+
|
|
216
|
+
// Blend for consistency
|
|
217
|
+
{
|
|
218
|
+
"colors": ["#e91e63", "#9c27b0", "#673ab7"],
|
|
219
|
+
"method": "blend",
|
|
220
|
+
"factor": 0.3
|
|
221
|
+
}
|
|
222
|
+
// Returns slightly blended colors
|
|
223
|
+
|
|
224
|
+
// Temperature adjustment
|
|
225
|
+
{
|
|
226
|
+
"colors": ["#ff5722", "#ff9800", "#ffc107"],
|
|
227
|
+
"method": "temperature",
|
|
228
|
+
"factor": 0.7
|
|
229
|
+
}
|
|
230
|
+
// Returns temperature-adjusted colors
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Use Cases
|
|
234
|
+
|
|
235
|
+
- Unifying colors from different sources
|
|
236
|
+
- Creating cohesive color schemes
|
|
237
|
+
- Fixing clashing color combinations
|
|
238
|
+
- Adapting external colors to design system
|
|
239
|
+
|
|
240
|
+
## Material Design 3 Concepts
|
|
241
|
+
|
|
242
|
+
### Dynamic Color
|
|
243
|
+
|
|
244
|
+
Material Design 3 uses dynamic color to create personalized experiences:
|
|
245
|
+
|
|
246
|
+
1. Extract source color (from image, brand, or user preference)
|
|
247
|
+
2. Generate tonal palettes for each color role
|
|
248
|
+
3. Apply appropriate tones for light/dark themes
|
|
249
|
+
4. Ensure accessibility through tone relationships
|
|
250
|
+
|
|
251
|
+
### Tonal Relationships
|
|
252
|
+
|
|
253
|
+
Contrast is guaranteed by tone differences:
|
|
254
|
+
|
|
255
|
+
- **3:1 contrast**: 40 tone difference
|
|
256
|
+
- **4.5:1 contrast**: 50 tone difference
|
|
257
|
+
- **7:1 contrast**: 60 tone difference
|
|
258
|
+
|
|
259
|
+
### Color Roles
|
|
260
|
+
|
|
261
|
+
Each role serves a specific purpose:
|
|
262
|
+
|
|
263
|
+
- **Primary**: Main actions and key components
|
|
264
|
+
- **Secondary**: Less prominent components
|
|
265
|
+
- **Tertiary**: Contrasting accents
|
|
266
|
+
- **Error**: Error states and validation
|
|
267
|
+
- **Neutral**: Surfaces and backgrounds
|
|
268
|
+
- **Neutral Variant**: Medium emphasis elements
|
|
269
|
+
|
|
270
|
+
## Common Patterns
|
|
271
|
+
|
|
272
|
+
### Theme Generation Workflow
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
// 1. Start with brand color
|
|
276
|
+
const sourceColor = "#6750a4";
|
|
277
|
+
|
|
278
|
+
// 2. Generate complete theme
|
|
279
|
+
const theme = await generateMaterialTheme({ sourceColor });
|
|
280
|
+
|
|
281
|
+
// 3. Extract specific palettes if needed
|
|
282
|
+
const primaryPalette = await generateTonalPalette({
|
|
283
|
+
color: sourceColor,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// 4. Harmonize with existing colors
|
|
287
|
+
const harmonized = await harmonizeColors({
|
|
288
|
+
colors: [sourceColor, "#00695c", "#e91e63"],
|
|
289
|
+
method: "harmonize",
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Creating Custom Palettes
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// Generate primary palette
|
|
297
|
+
const primary = await generateTonalPalette({
|
|
298
|
+
color: "#6750a4",
|
|
299
|
+
tones: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100],
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Generate secondary with reduced chroma
|
|
303
|
+
const secondary = await generateTonalPalette({
|
|
304
|
+
color: "#625b71",
|
|
305
|
+
tones: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100],
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// Generate tertiary with hue shift
|
|
309
|
+
const tertiary = await generateTonalPalette({
|
|
310
|
+
color: "#7e5260",
|
|
311
|
+
tones: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100],
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Ensuring Accessibility
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// Light theme combinations
|
|
319
|
+
const lightCombos = [
|
|
320
|
+
{ bg: theme.light.surface, fg: theme.light.onSurface }, // 15:1
|
|
321
|
+
{ bg: theme.light.primary, fg: theme.light.onPrimary }, // 15:1
|
|
322
|
+
{ bg: theme.light.primaryContainer, fg: theme.light.onPrimaryContainer }, // 11:1
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
// All combinations meet WCAG AAA standards
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Best Practices
|
|
329
|
+
|
|
330
|
+
1. **Start with meaningful source colors** that represent your brand
|
|
331
|
+
2. **Use standard tones** for consistency with Material Design
|
|
332
|
+
3. **Test both light and dark themes** for accessibility
|
|
333
|
+
4. **Harmonize imported colors** before using in themes
|
|
334
|
+
5. **Maintain tone relationships** for guaranteed contrast
|
|
335
|
+
|
|
336
|
+
## Performance Considerations
|
|
337
|
+
|
|
338
|
+
- Theme generation: ~10ms for complete theme
|
|
339
|
+
- Tonal palette: ~2ms per palette
|
|
340
|
+
- Harmonization: ~5ms for 10 colors
|
|
341
|
+
|
|
342
|
+
## Related Documentation
|
|
343
|
+
|
|
344
|
+
- [Material Design 3 Concepts](../concepts/material-design-3.md)
|
|
345
|
+
- [HCT Color Space](../concepts/hct-color-space.md)
|
|
346
|
+
- [Dynamic Theming Example](../examples/dynamic-theming.md)
|
|
347
|
+
- [API Reference](../api/README.md#material-design)
|