@cdc/core 4.25.7 → 4.25.10

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.
Files changed (128) hide show
  1. package/components/AdvancedEditor/AdvancedEditor.tsx +29 -8
  2. package/components/DataTable/DataTable.tsx +63 -11
  3. package/components/DataTable/DataTableStandAlone.tsx +4 -1
  4. package/components/DataTable/components/ChartHeader.tsx +58 -9
  5. package/components/DataTable/components/ExpandCollapse.tsx +21 -1
  6. package/components/DataTable/components/MapHeader.tsx +35 -7
  7. package/components/DataTable/data-table.css +6 -0
  8. package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
  9. package/components/DataTable/helpers/mapCellMatrix.tsx +19 -1
  10. package/components/DownloadButton.tsx +42 -13
  11. package/components/EditorPanel/DataTableEditor.tsx +10 -1
  12. package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
  13. package/components/EditorPanel/components/MarkupVariablesEditor.tsx +411 -0
  14. package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
  15. package/components/ErrorBoundary.jsx +3 -1
  16. package/components/Filters/Filters.tsx +35 -11
  17. package/components/Filters/components/Tabs.tsx +1 -0
  18. package/components/Footnotes/FootnotesStandAlone.tsx +2 -1
  19. package/components/Legend/Legend.Gradient.tsx +3 -6
  20. package/components/LegendShape.tsx +121 -3
  21. package/components/{MediaControls.jsx → MediaControls.tsx} +80 -16
  22. package/components/PaletteConversionModal.tsx +87 -0
  23. package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
  24. package/components/PaletteSelector/PaletteSelector.css +51 -0
  25. package/components/PaletteSelector/PaletteSelector.tsx +112 -0
  26. package/components/PaletteSelector/index.ts +2 -0
  27. package/components/RichTooltip/RichTooltip.tsx +1 -0
  28. package/components/Table/Table.tsx +3 -1
  29. package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
  30. package/components/_stories/DataTable.stories.tsx +1 -1
  31. package/components/_stories/Filters.stories.tsx +1 -1
  32. package/components/_stories/Footnotes.stories.tsx +1 -1
  33. package/components/_stories/Inputs.stories.tsx +1 -1
  34. package/components/_stories/MultiSelect.stories.tsx +3 -3
  35. package/components/_stories/NestedDropdown.stories.tsx +1 -1
  36. package/components/_stories/Table.stories.tsx +1 -1
  37. package/components/elements/_stories/Button.stories.tsx +1 -1
  38. package/components/elements/_stories/Card.stories.tsx +1 -1
  39. package/components/inputs/InputToggle.tsx +2 -0
  40. package/components/managers/DataDesigner.tsx +10 -9
  41. package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
  42. package/components/ui/Tooltip.tsx +2 -1
  43. package/components/ui/_stories/Accordion.stories.tsx +1 -1
  44. package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
  45. package/components/ui/_stories/Colors.stories.tsx +330 -0
  46. package/components/ui/_stories/IconGallery.stories.tsx +316 -0
  47. package/components/ui/_stories/Title.stories.tsx +1 -1
  48. package/contexts/EditorContext.ts +18 -0
  49. package/contexts/editor.actions.ts +28 -0
  50. package/contexts/editor.reducer.ts +94 -0
  51. package/data/chartColorPalettes.ts +118 -0
  52. package/data/colorPalettes.ts +9 -0
  53. package/data/mapColorPalettes.ts +45 -0
  54. package/data/sharedPalettes.ts +50 -0
  55. package/dist/cove-main.css +14 -13
  56. package/dist/cove-main.css.map +1 -1
  57. package/generateViteConfig.js +80 -0
  58. package/helpers/addValuesToFilters.ts +2 -3
  59. package/helpers/cloneConfig.ts +31 -0
  60. package/helpers/configDataHelpers.ts +128 -0
  61. package/helpers/configHelpers.ts +27 -0
  62. package/helpers/constants.ts +5 -2
  63. package/helpers/cove/number.ts +6 -2
  64. package/helpers/coveUpdateWorker.ts +15 -3
  65. package/helpers/events.ts +32 -0
  66. package/helpers/filterColorPalettes.ts +152 -0
  67. package/helpers/generateColorsArray.ts +13 -0
  68. package/helpers/getColorPaletteVersion.ts +33 -0
  69. package/helpers/getPaletteAccessor.ts +18 -0
  70. package/helpers/markupProcessor.ts +205 -0
  71. package/helpers/metrics/helpers.ts +75 -0
  72. package/helpers/metrics/types.ts +82 -0
  73. package/helpers/metrics/utils.ts +34 -0
  74. package/helpers/palettes/colorDistributions.ts +56 -0
  75. package/helpers/palettes/migratePaletteName.ts +150 -0
  76. package/helpers/palettes/standardizePaletteNames.ts +77 -0
  77. package/helpers/palettes/utils.ts +267 -0
  78. package/helpers/queryStringUtils.ts +13 -0
  79. package/helpers/testing.ts +345 -0
  80. package/helpers/tests/addValuesToFilters.test.ts +1 -2
  81. package/helpers/tests/generateColorsArray.test.ts +24 -0
  82. package/helpers/tests/markupProcessor.test.ts +538 -0
  83. package/helpers/tests/testStandaloneBuild.ts +44 -0
  84. package/helpers/useMarkupVariables.ts +31 -0
  85. package/helpers/vegaConfig.ts +0 -1
  86. package/helpers/ver/4.24.10.ts +2 -1
  87. package/helpers/ver/4.24.11.ts +2 -1
  88. package/helpers/ver/4.24.3.ts +2 -1
  89. package/helpers/ver/4.24.4.ts +2 -1
  90. package/helpers/ver/4.24.5.ts +2 -1
  91. package/helpers/ver/4.24.7.ts +2 -1
  92. package/helpers/ver/4.24.9.ts +2 -1
  93. package/helpers/ver/4.25.1.ts +2 -1
  94. package/helpers/ver/4.25.10.ts +36 -0
  95. package/helpers/ver/4.25.3.ts +2 -1
  96. package/helpers/ver/4.25.4.ts +2 -1
  97. package/helpers/ver/4.25.6.ts +2 -1
  98. package/helpers/ver/4.25.7.ts +2 -1
  99. package/helpers/ver/4.25.8.ts +62 -0
  100. package/helpers/ver/4.25.9.ts +293 -0
  101. package/helpers/ver/tests/4.25.10.test.ts +204 -0
  102. package/helpers/ver/tests/4.25.8.test.ts +86 -0
  103. package/helpers/ver/tests/4.25.9.test.ts +51 -0
  104. package/helpers/viewports.ts +2 -0
  105. package/hooks/useColorPalette.ts +79 -0
  106. package/package.json +12 -4
  107. package/styles/_button-section.scss +0 -2
  108. package/styles/_global.scss +7 -5
  109. package/styles/base.scss +8 -5
  110. package/styles/v2/components/button.scss +4 -3
  111. package/styles/v2/components/editor.scss +2 -1
  112. package/styles/v2/layout/_data-table.scss +3 -2
  113. package/styles/v2/themes/_color-definitions.scss +18 -17
  114. package/testBuild.js +0 -0
  115. package/testing-setup.js +32 -0
  116. package/types/ForecastingSeriesKey.ts +0 -1
  117. package/types/MarkupInclude.ts +6 -1
  118. package/types/MarkupVariable.ts +19 -0
  119. package/types/Series.ts +4 -0
  120. package/types/Table.ts +1 -0
  121. package/types/VizFilter.ts +1 -0
  122. package/vitest.config.ts +16 -0
  123. package/components/ui/_stories/Colors.stories.mdx +0 -220
  124. package/components/ui/_stories/IconGallery.stories.mdx +0 -14
  125. package/data/colorPalettes.js +0 -171
  126. package/helpers/events.js +0 -14
  127. package/helpers/formatConfigBeforeSave.ts +0 -135
  128. package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
@@ -0,0 +1,275 @@
1
+ import { Meta, ColorPalette, ColorItem } from '@storybook/blocks'
2
+ import { mapColorPalettesV1, mapColorPalettesV2 } from '@cdc/core/data/colorPalettes'
3
+
4
+ <Meta title="Design Systems/Color Palette Migration" />
5
+
6
+ # Color Palette Migration: V1 to V2
7
+
8
+ This story shows the evolution from v1 to v2 color palettes side by side. This comparison helps visualize how each v1 palette translates to the new v2 palette.
9
+
10
+ ## Blue Palettes
11
+
12
+ ### Sequential Blue Extended → Sequential Blue
13
+ <ColorPalette>
14
+ <ColorItem
15
+ title="V1: Sequential Blue Extended"
16
+ colors={mapColorPalettesV1.sequential_blue_extended}
17
+ />
18
+ <ColorItem
19
+ title="V2: Sequential Blue"
20
+ colors={mapColorPalettesV2.sequential_blue}
21
+ />
22
+ </ColorPalette>
23
+
24
+ ### Sequential Blue Green → Sequential Blue
25
+ <ColorPalette>
26
+ <ColorItem
27
+ title="V1: Sequential Blue Green"
28
+ colors={mapColorPalettesV1.sequential_blue_green}
29
+ />
30
+ <ColorItem
31
+ title="V2: Sequential Blue"
32
+ colors={mapColorPalettesV2.sequential_blue}
33
+ />
34
+ </ColorPalette>
35
+
36
+ ### Sequential Green Blue → Sequential Teal
37
+ <ColorPalette>
38
+ <ColorItem
39
+ title="V1: Sequential Green Blue"
40
+ colors={mapColorPalettesV1.sequential_green_blue}
41
+ />
42
+ <ColorItem
43
+ title="V2: Sequential Teal"
44
+ colors={mapColorPalettesV2.sequential_teal}
45
+ />
46
+ </ColorPalette>
47
+
48
+ ## Green Palettes
49
+
50
+ ### New V2: Sequential Green
51
+ <ColorPalette>
52
+ <ColorItem
53
+ title="V2: Sequential Green (New)"
54
+ colors={mapColorPalettesV2.sequential_green}
55
+ />
56
+ </ColorPalette>
57
+
58
+ ## Purple Palettes
59
+
60
+ ### Sequential Pink Purple → Sequential Purple
61
+ <ColorPalette>
62
+ <ColorItem
63
+ title="V1: Sequential Pink Purple"
64
+ colors={mapColorPalettesV1.sequential_pink_purple}
65
+ />
66
+ <ColorItem
67
+ title="V2: Sequential Purple"
68
+ colors={mapColorPalettesV2.sequential_purple}
69
+ />
70
+ </ColorPalette>
71
+
72
+ ### Sequential Red → Sequential Purple
73
+ <ColorPalette>
74
+ <ColorItem
75
+ title="V1: Sequential Red"
76
+ colors={mapColorPalettesV1.sequential_red}
77
+ />
78
+ <ColorItem
79
+ title="V2: Sequential Purple"
80
+ colors={mapColorPalettesV2.sequential_purple}
81
+ />
82
+ </ColorPalette>
83
+
84
+ ### Divergent Yellow Purple → Sequential Purple
85
+ <ColorPalette>
86
+ <ColorItem
87
+ title="V1: Divergent Yellow Purple"
88
+ colors={mapColorPalettesV1.divergent_yellow_purple}
89
+ />
90
+ <ColorItem
91
+ title="V2: Sequential Purple"
92
+ colors={mapColorPalettesV2.sequential_purple}
93
+ />
94
+ </ColorPalette>
95
+
96
+ ## Orange Palettes
97
+
98
+ ### Sequential Yellow Orange Red → Sequential Orange
99
+ <ColorPalette>
100
+ <ColorItem
101
+ title="V1: Sequential Yellow Orange Red"
102
+ colors={mapColorPalettesV1.sequential_yellow_orange_red}
103
+ />
104
+ <ColorItem
105
+ title="V2: Sequential Orange"
106
+ colors={mapColorPalettesV2.sequential_orange}
107
+ />
108
+ </ColorPalette>
109
+
110
+ ### Sequential Yellow Orange Brown → Sequential Orange
111
+ <ColorPalette>
112
+ <ColorItem
113
+ title="V1: Sequential Yellow Orange Brown"
114
+ colors={mapColorPalettesV1.sequential_yellow_orange_brown}
115
+ />
116
+ <ColorItem
117
+ title="V2: Sequential Orange"
118
+ colors={mapColorPalettesV2.sequential_orange}
119
+ />
120
+ </ColorPalette>
121
+
122
+ ### Sequential Orange Red → Sequential Orange
123
+ <ColorPalette>
124
+ <ColorItem
125
+ title="V1: Sequential Orange Red"
126
+ colors={mapColorPalettesV1.sequential_orange_red}
127
+ />
128
+ <ColorItem
129
+ title="V2: Sequential Orange"
130
+ colors={mapColorPalettesV2.sequential_orange}
131
+ />
132
+ </ColorPalette>
133
+
134
+ ### Sequential Orange Extended → Sequential Orange
135
+ <ColorPalette>
136
+ <ColorItem
137
+ title="V1: Sequential Orange Extended"
138
+ colors={mapColorPalettesV1.sequential_orange_extended}
139
+ />
140
+ <ColorItem
141
+ title="V2: Sequential Orange"
142
+ colors={mapColorPalettesV2.sequential_orange}
143
+ />
144
+ </ColorPalette>
145
+
146
+ ## Diverging/Special Palettes
147
+
148
+ ### New V2 Diverging and Special Palettes
149
+ <ColorPalette>
150
+ <ColorItem
151
+ title="V2: Divergent Blue Cyan (New)"
152
+ colors={mapColorPalettesV2.divergent_blue_cyan}
153
+ />
154
+ <ColorItem
155
+ title="V2: Divergent Blue Purple (New)"
156
+ colors={mapColorPalettesV2.divergent_blue_purple}
157
+ />
158
+ <ColorItem
159
+ title="V2: Divergent Green Orange (New)"
160
+ colors={mapColorPalettesV2.divergent_green_orange}
161
+ />
162
+ <ColorItem
163
+ title="V2: Divergent Blue Orange (New)"
164
+ colors={mapColorPalettesV2.divergent_blue_orange}
165
+ />
166
+ </ColorPalette>
167
+
168
+ ## Categorical/Qualitative Palettes
169
+
170
+ ### Qualitative 1 → Qualitative
171
+ <ColorPalette>
172
+ <ColorItem
173
+ title="V1: Qualitative 1"
174
+ colors={mapColorPalettesV1.qualitative1}
175
+ />
176
+ <ColorItem
177
+ title="V2: Qualitative"
178
+ colors={mapColorPalettesV2.qualitative}
179
+ />
180
+ </ColorPalette>
181
+
182
+ ### Qualitative 2 → Qualitative
183
+ <ColorPalette>
184
+ <ColorItem
185
+ title="V1: Qualitative 2"
186
+ colors={mapColorPalettesV1.qualitative2}
187
+ />
188
+ <ColorItem
189
+ title="V2: Qualitative"
190
+ colors={mapColorPalettesV2.qualitative}
191
+ />
192
+ </ColorPalette>
193
+
194
+ ### Qualitative 3 → Qualitative
195
+ <ColorPalette>
196
+ <ColorItem
197
+ title="V1: Qualitative 3"
198
+ colors={mapColorPalettesV1.qualitative3}
199
+ />
200
+ <ColorItem
201
+ title="V2: Qualitative"
202
+ colors={mapColorPalettesV2.qualitative}
203
+ />
204
+ </ColorPalette>
205
+
206
+ ### Qualitative 4 → Qualitative
207
+ <ColorPalette>
208
+ <ColorItem
209
+ title="V1: Qualitative 4"
210
+ colors={mapColorPalettesV1.qualitative4}
211
+ />
212
+ <ColorItem
213
+ title="V2: Qualitative"
214
+ colors={mapColorPalettesV2.qualitative}
215
+ />
216
+ </ColorPalette>
217
+
218
+ ### Qualitative Earth Tones → Qualitative
219
+ <ColorPalette>
220
+ <ColorItem
221
+ title="V1: Qualitative Earth Tones"
222
+ colors={mapColorPalettesV1.qualitative_earth_tones}
223
+ />
224
+ <ColorItem
225
+ title="V2: Qualitative"
226
+ colors={mapColorPalettesV2.qualitative}
227
+ />
228
+ </ColorPalette>
229
+
230
+ ### Colorblind Safe → Qualitative
231
+ <ColorPalette>
232
+ <ColorItem
233
+ title="V1: Colorblind Safe"
234
+ colors={mapColorPalettesV1.colorblindsafe}
235
+ />
236
+ <ColorItem
237
+ title="V2: Qualitative (Colorblind-friendly)"
238
+ colors={mapColorPalettesV2.qualitative}
239
+ />
240
+ </ColorPalette>
241
+
242
+ ## New V2 Palettes
243
+
244
+ These are new palettes introduced in V2 that don't have direct V1 equivalents:
245
+
246
+ <ColorPalette>
247
+ <ColorItem
248
+ title="V2: Sequential Green"
249
+ colors={mapColorPalettesV2.sequential_green}
250
+ />
251
+ <ColorItem
252
+ title="V2: Divergent Blue Cyan"
253
+ colors={mapColorPalettesV2.divergent_blue_cyan}
254
+ />
255
+ <ColorItem
256
+ title="V2: Divergent Blue Purple"
257
+ colors={mapColorPalettesV2.divergent_blue_purple}
258
+ />
259
+ <ColorItem
260
+ title="V2: Divergent Green Orange"
261
+ colors={mapColorPalettesV2.divergent_green_orange}
262
+ />
263
+ <ColorItem
264
+ title="V2: Divergent Blue Orange"
265
+ colors={mapColorPalettesV2.divergent_blue_orange}
266
+ />
267
+ </ColorPalette>
268
+
269
+ ## Migration Notes
270
+
271
+ - **Sequential palettes**: V1 had many specific sequential palettes that map to broader single-hue categories in V2
272
+ - **Qualitative palettes**: V1 had 4 different qualitative sets that all map to a single, refined qualitative palette in V2
273
+ - **Divergent palettes**: V2 introduces new divergent palettes for better data representation
274
+ - **Heat maps**: V2 adds a dedicated heat map palette for specialized visualizations
275
+ - **Colorblind accessibility**: Both versions maintain colorblind-safe options
@@ -0,0 +1,330 @@
1
+ import type { Meta } from '@storybook/react'
2
+ import { mapColorPalettesV2, colorPalettesChartV2, twoColorPalette, sequentialPalettes } from '../../../data/colorPalettes'
3
+
4
+ // Get the v2 palettes for consistency
5
+ const twoColorPaletteV2 = twoColorPalette.v2
6
+
7
+ const meta: Meta = {
8
+ title: 'Components/Atoms/Colors',
9
+ parameters: {
10
+ docs: {
11
+ page: () => (
12
+ <div style={{ padding: '20px' }}>
13
+ <h1>Color Palettes</h1>
14
+ <p>This guide showcases all available color palettes in the CDC Open Viz system.</p>
15
+
16
+ <h2>Qualitative Palettes</h2>
17
+ <p>These palettes are designed for categorical data where each color represents a different category.</p>
18
+
19
+ <h3>Chart Palettes</h3>
20
+ {Object.entries(colorPalettesChartV2).map(([name, colors]) => (
21
+ <div key={name} style={{ marginBottom: '20px' }}>
22
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/-/g, ' ')}</h4>
23
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
24
+ <div style={{ display: 'flex' }}>
25
+ {colors.map((color, index) => (
26
+ <div
27
+ key={index}
28
+ style={{
29
+ width: '40px',
30
+ height: '40px',
31
+ backgroundColor: color,
32
+ border: '1px solid #ccc',
33
+ display: 'flex',
34
+ alignItems: 'center',
35
+ justifyContent: 'center',
36
+ fontSize: '10px',
37
+ color: index < 3 ? '#000' : '#fff'
38
+ }}
39
+ title={color}
40
+ />
41
+ ))}
42
+ </div>
43
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
44
+ {colors.join(', ')}
45
+ </code>
46
+ </div>
47
+ </div>
48
+ ))}
49
+
50
+ <h3>Sequential Palettes</h3>
51
+ <p>These palettes are designed for ordered data that progresses from low to high values.</p>
52
+ {Object.entries(sequentialPalettes).map(([name, colors]) => (
53
+ <div key={name} style={{ marginBottom: '20px' }}>
54
+ <h4 style={{ marginBottom: '10px' }}>{name}</h4>
55
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
56
+ <div style={{ display: 'flex' }}>
57
+ {colors.map((color, index) => (
58
+ <div
59
+ key={index}
60
+ style={{
61
+ width: '40px',
62
+ height: '40px',
63
+ backgroundColor: color,
64
+ border: '1px solid #ccc',
65
+ display: 'flex',
66
+ alignItems: 'center',
67
+ justifyContent: 'center',
68
+ fontSize: '10px',
69
+ color: index < colors.length / 2 ? '#000' : '#fff'
70
+ }}
71
+ title={color}
72
+ />
73
+ ))}
74
+ </div>
75
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
76
+ {colors.join(', ')}
77
+ </code>
78
+ </div>
79
+ </div>
80
+ ))}
81
+
82
+ <h3>Two-Color Palettes</h3>
83
+ <p>These palettes are designed for paired comparisons and side-by-side visualizations.</p>
84
+ {Object.entries(twoColorPaletteV2).map(([name, colors]) => (
85
+ <div key={name} style={{ marginBottom: '20px' }}>
86
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/-/g, ' ')}</h4>
87
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
88
+ <div style={{ display: 'flex' }}>
89
+ {colors.map((color, index) => (
90
+ <div
91
+ key={index}
92
+ style={{
93
+ width: '60px',
94
+ height: '40px',
95
+ backgroundColor: color,
96
+ border: '1px solid #ccc',
97
+ display: 'flex',
98
+ alignItems: 'center',
99
+ justifyContent: 'center',
100
+ fontSize: '10px',
101
+ color: '#fff',
102
+ textShadow: '1px 1px 1px rgba(0,0,0,0.7)'
103
+ }}
104
+ title={color}
105
+ />
106
+ ))}
107
+ </div>
108
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
109
+ {colors.join(', ')}
110
+ </code>
111
+ </div>
112
+ </div>
113
+ ))}
114
+
115
+ <h2>Map Palettes</h2>
116
+ <p>These palettes are primarily used for geographic visualizations and maps.</p>
117
+ {Object.entries(mapColorPalettesV2).map(([name, colors]) => (
118
+ <div key={name} style={{ marginBottom: '20px' }}>
119
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase()}</h4>
120
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
121
+ <div style={{ display: 'flex' }}>
122
+ {colors.map((color, index) => (
123
+ <div
124
+ key={index}
125
+ style={{
126
+ width: '30px',
127
+ height: '40px',
128
+ backgroundColor: color,
129
+ border: '1px solid #ccc',
130
+ display: 'flex',
131
+ alignItems: 'center',
132
+ justifyContent: 'center',
133
+ fontSize: '8px',
134
+ color: index < colors.length / 2 ? '#000' : '#fff'
135
+ }}
136
+ title={color}
137
+ />
138
+ ))}
139
+ </div>
140
+ <code style={{ marginLeft: '10px', fontSize: '11px', color: '#666' }}>
141
+ [{colors.slice(0, 3).join(', ')}...] ({colors.length} colors)
142
+ </code>
143
+ </div>
144
+ </div>
145
+ ))}
146
+
147
+ <h2>Usage Guidelines</h2>
148
+ <ul>
149
+ <li><strong>Accessibility</strong>: All palettes are designed to meet WCAG accessibility guidelines</li>
150
+ <li><strong>Color Blind Friendly</strong>: The "colorblindsafe" palette is specifically designed for color blind users</li>
151
+ <li><strong>Sequential Data</strong>: Use sequential palettes for ordered data (low to high values)</li>
152
+ <li><strong>Categorical Data</strong>: Use qualitative palettes for distinct categories</li>
153
+ <li><strong>Comparisons</strong>: Use two-color palettes for side-by-side comparisons</li>
154
+ <li><strong>Geographic Data</strong>: Use map palettes for choropleth and geographic visualizations</li>
155
+ </ul>
156
+
157
+ <h2>Implementation</h2>
158
+ <p>Import color palettes in your components:</p>
159
+ <pre><code>{`import { mapColorPalettesV2, colorPalettesChartV2, twoColorPalette, sequentialPalettes } from '@cdc/core/data/colorPalettes'
160
+
161
+ // Use in your visualization
162
+ const colors = colorPalettesChartV2['qualitative-bold']
163
+ const twoColors = twoColorPalette.v2['divergent-blue-orange']
164
+ const mapColors = mapColorPalettesV2.sequential_blue`}</code></pre>
165
+ </div>
166
+ )
167
+ }
168
+ }
169
+ }
170
+
171
+ export default meta
172
+
173
+ export const Guide = {
174
+ render: () => (
175
+ <div style={{ padding: '20px' }}>
176
+ <h1>Color Palettes</h1>
177
+ <p>This guide showcases all available color palettes in the CDC Open Viz system.</p>
178
+
179
+ <h2>Qualitative Palettes</h2>
180
+ <p>These palettes are designed for categorical data where each color represents a different category.</p>
181
+
182
+ <h3>Chart Palettes</h3>
183
+ {Object.entries(colorPalettesChartV2).map(([name, colors]) => (
184
+ <div key={name} style={{ marginBottom: '20px' }}>
185
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/-/g, ' ')}</h4>
186
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
187
+ <div style={{ display: 'flex' }}>
188
+ {colors.map((color, index) => (
189
+ <div
190
+ key={index}
191
+ style={{
192
+ width: '40px',
193
+ height: '40px',
194
+ backgroundColor: color,
195
+ border: '1px solid #ccc',
196
+ display: 'flex',
197
+ alignItems: 'center',
198
+ justifyContent: 'center',
199
+ fontSize: '10px',
200
+ color: index < 3 ? '#000' : '#fff'
201
+ }}
202
+ title={color}
203
+ />
204
+ ))}
205
+ </div>
206
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
207
+ {colors.join(', ')}
208
+ </code>
209
+ </div>
210
+ </div>
211
+ ))}
212
+
213
+ <h3>Sequential Palettes</h3>
214
+ <p>These palettes are designed for ordered data that progresses from low to high values.</p>
215
+ {Object.entries(sequentialPalettes).map(([name, colors]) => (
216
+ <div key={name} style={{ marginBottom: '20px' }}>
217
+ <h4 style={{ marginBottom: '10px' }}>{name}</h4>
218
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
219
+ <div style={{ display: 'flex' }}>
220
+ {colors.map((color, index) => (
221
+ <div
222
+ key={index}
223
+ style={{
224
+ width: '40px',
225
+ height: '40px',
226
+ backgroundColor: color,
227
+ border: '1px solid #ccc',
228
+ display: 'flex',
229
+ alignItems: 'center',
230
+ justifyContent: 'center',
231
+ fontSize: '10px',
232
+ color: index < colors.length / 2 ? '#000' : '#fff'
233
+ }}
234
+ title={color}
235
+ />
236
+ ))}
237
+ </div>
238
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
239
+ {colors.join(', ')}
240
+ </code>
241
+ </div>
242
+ </div>
243
+ ))}
244
+
245
+ <h3>Two-Color Palettes</h3>
246
+ <p>These palettes are designed for paired comparisons and side-by-side visualizations.</p>
247
+ {Object.entries(twoColorPaletteV2).map(([name, colors]) => (
248
+ <div key={name} style={{ marginBottom: '20px' }}>
249
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/-/g, ' ')}</h4>
250
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
251
+ <div style={{ display: 'flex' }}>
252
+ {colors.map((color, index) => (
253
+ <div
254
+ key={index}
255
+ style={{
256
+ width: '60px',
257
+ height: '40px',
258
+ backgroundColor: color,
259
+ border: '1px solid #ccc',
260
+ display: 'flex',
261
+ alignItems: 'center',
262
+ justifyContent: 'center',
263
+ fontSize: '10px',
264
+ color: '#fff',
265
+ textShadow: '1px 1px 1px rgba(0,0,0,0.7)'
266
+ }}
267
+ title={color}
268
+ />
269
+ ))}
270
+ </div>
271
+ <code style={{ marginLeft: '10px', fontSize: '12px', color: '#666' }}>
272
+ {colors.join(', ')}
273
+ </code>
274
+ </div>
275
+ </div>
276
+ ))}
277
+
278
+ <h2>Map Palettes</h2>
279
+ <p>These palettes are primarily used for geographic visualizations and maps.</p>
280
+ {Object.entries(mapColorPalettesV2).map(([name, colors]) => (
281
+ <div key={name} style={{ marginBottom: '20px' }}>
282
+ <h4 style={{ textTransform: 'capitalize', marginBottom: '10px' }}>{name.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase()}</h4>
283
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
284
+ <div style={{ display: 'flex' }}>
285
+ {colors.map((color, index) => (
286
+ <div
287
+ key={index}
288
+ style={{
289
+ width: '30px',
290
+ height: '40px',
291
+ backgroundColor: color,
292
+ border: '1px solid #ccc',
293
+ display: 'flex',
294
+ alignItems: 'center',
295
+ justifyContent: 'center',
296
+ fontSize: '8px',
297
+ color: index < colors.length / 2 ? '#000' : '#fff'
298
+ }}
299
+ title={color}
300
+ />
301
+ ))}
302
+ </div>
303
+ <code style={{ marginLeft: '10px', fontSize: '11px', color: '#666' }}>
304
+ [{colors.slice(0, 3).join(', ')}...] ({colors.length} colors)
305
+ </code>
306
+ </div>
307
+ </div>
308
+ ))}
309
+
310
+ <h2>Usage Guidelines</h2>
311
+ <ul>
312
+ <li><strong>Accessibility</strong>: All palettes are designed to meet WCAG accessibility guidelines</li>
313
+ <li><strong>Color Blind Friendly</strong>: The "colorblindsafe" palette is specifically designed for color blind users</li>
314
+ <li><strong>Sequential Data</strong>: Use sequential palettes for ordered data (low to high values)</li>
315
+ <li><strong>Categorical Data</strong>: Use qualitative palettes for distinct categories</li>
316
+ <li><strong>Comparisons</strong>: Use two-color palettes for side-by-side comparisons</li>
317
+ <li><strong>Geographic Data</strong>: Use map palettes for choropleth and geographic visualizations</li>
318
+ </ul>
319
+
320
+ <h2>Implementation</h2>
321
+ <p>Import color palettes in your components:</p>
322
+ <pre><code>{`import { mapColorPalettesV2, colorPalettesChartV2, twoColorPalette, sequentialPalettes } from '@cdc/core/data/colorPalettes'
323
+
324
+ // Use in your visualization
325
+ const colors = colorPalettesChartV2['qualitative-bold']
326
+ const twoColors = twoColorPalette.v2['divergent-blue-orange']
327
+ const mapColors = mapColorPalettesV2.sequential_blue`}</code></pre>
328
+ </div>
329
+ )
330
+ }