@cdc/waffle-chart 4.26.1 → 4.26.3

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.
@@ -1,15 +1,20 @@
1
- // Remove custom theme mixin - use core styles instead
2
-
3
- .type-dashboard .type-waffle-chart .cove-component__content {
4
- padding-top: 0;
5
- }
1
+ @import '@cdc/core/styles/layout/wrapper-padding';
6
2
 
7
3
  // Let core styles handle color palette
8
4
 
9
- .cove {
5
+ .cove-visualization.type-waffle-chart {
6
+
7
+ .cove-waffle-chart__subtext.subtext,
8
+ .cove-waffle-chart__subtext.subtext.fst-italic {
9
+ line-height: var(--visualization-body-line-height);
10
+ }
11
+
12
+ .cove-visualization__body {
13
+ @include cove-visualization-body-padding;
14
+ }
15
+
10
16
  .cove-gauge-chart {
11
17
  &__chart {
12
- width: 85%;
13
18
  margin: 0 auto;
14
19
  margin-left: auto;
15
20
  height: auto;
@@ -18,14 +23,14 @@
18
23
  justify-items: center;
19
24
  align-items: flex-start;
20
25
 
21
- & > svg {
26
+ &>svg {
22
27
  margin: 0.7em 0;
23
28
  }
24
29
  }
25
30
 
26
31
  &__subtext {
27
32
  font-style: italic;
28
- font-size: 0.9em !important;
33
+ line-height: var(--visualization-body-line-height);
29
34
  }
30
35
 
31
36
  &__text {
@@ -37,7 +42,6 @@
37
42
  .cove-waffle-chart {
38
43
  display: flex;
39
44
  flex-wrap: wrap;
40
- padding: 1em 1em 0;
41
45
  justify-content: flex-start;
42
46
 
43
47
  &.cove-waffle-chart--verical {
@@ -52,14 +56,12 @@
52
56
 
53
57
  .cove-waffle-chart__chart {
54
58
  padding-right: 1rem;
55
- margin-bottom: 1rem;
56
59
  box-sizing: content-box;
57
60
  }
58
61
 
59
62
  .cove-waffle-chart__data {
60
63
  flex: 1 1 0;
61
64
  min-width: 175px;
62
- margin-bottom: 1rem;
63
65
  }
64
66
 
65
67
  .cove-waffle-chart__data {
@@ -67,8 +69,6 @@
67
69
  flex-wrap: wrap;
68
70
  align-content: space-between;
69
71
 
70
- font-size: 14px;
71
-
72
72
  .cove-waffle-chart__data--primary {
73
73
  font-size: 70px;
74
74
  font-weight: 400;
@@ -96,6 +96,7 @@
96
96
  }
97
97
 
98
98
  @at-root {
99
+
99
100
  .cove-waffle-chart.font-small,
100
101
  .cove-gauge-chart.font-small #{&} {
101
102
  .cove-waffle-chart__data--primary {
@@ -133,8 +134,19 @@
133
134
  // TP5 Style for Waffle Chart
134
135
  .type-waffle-chart {
135
136
  &.waffle__style--tp5 {
136
- .cove-component__content {
137
+
138
+ .cove-visualization__body,
139
+ .cove-visualization__body.component--has-legacy-border,
140
+ .cove-visualization__body.component--has-border-color-theme,
141
+ .cove-visualization__body.component--has-background,
142
+ .cove-visualization__body.component--has-accent {
143
+ padding: 0 !important;
137
144
  background: none !important;
145
+ container-type: inline-size;
146
+
147
+ >.cove-visualization__body-wrap {
148
+ padding: 0 !important;
149
+ }
138
150
  }
139
151
 
140
152
  .cdc-callout {
@@ -142,7 +154,7 @@
142
154
  margin: 0 !important;
143
155
  padding: 1.5rem;
144
156
  background-color: var(--colors-cyan-10, #eff9fa);
145
- border: 1px solid var(--colors-cyan-15, #dff2f6);
157
+ border: 1px solid #dff2f6 !important;
146
158
  position: relative;
147
159
  border-radius: 0.25rem;
148
160
  flex-wrap: wrap;
@@ -167,8 +179,21 @@
167
179
  }
168
180
 
169
181
  .cove-waffle-chart {
182
+ align-items: flex-start;
170
183
  padding: 0;
171
184
  row-gap: 1rem;
185
+ flex-wrap: nowrap;
186
+ }
187
+
188
+ // Container query: wrap when width is less than 576px
189
+ @container (max-width: 576px) {
190
+ .cove-waffle-chart {
191
+ flex-wrap: wrap;
192
+
193
+ .cove-waffle-chart__chart {
194
+ width: 100% !important;
195
+ }
196
+ }
172
197
  }
173
198
 
174
199
  .cove-waffle-chart__chart {
@@ -178,6 +203,18 @@
178
203
  .cove-waffle-chart__data {
179
204
  margin-bottom: 0;
180
205
  align-content: flex-start;
206
+
207
+ .cove-waffle-chart__data--primary {
208
+ font-size: 2rem;
209
+ color: var(--colors-cyan-60v);
210
+ font-weight: 400;
211
+ }
212
+
213
+ .cove-waffle-chart__data--text {
214
+ margin-top: 0.5rem;
215
+ font-size: 1rem;
216
+ line-height: 1.5rem;
217
+ }
181
218
  }
182
219
 
183
220
  .cdc-callout__heading {
@@ -186,23 +223,152 @@
186
223
  font-size: 1.1rem;
187
224
  }
188
225
 
189
- .cove-waffle-chart__data--text {
190
- margin-top: 0.5rem;
191
- font-size: 1rem;
192
- }
193
226
  .cove-waffle-chart__subtext {
227
+ margin-top: 1rem;
228
+ }
229
+
230
+ // White background variant (when "Use White Background Style" is checked)
231
+ &.white-background-style {
232
+
233
+ .cove-visualization__body,
234
+ .cove-visualization__body.component--has-legacy-border,
235
+ .cove-visualization__body.component--has-border-color-theme,
236
+ .cove-visualization__body.component--has-background,
237
+ .cove-visualization__body.component--has-accent {
238
+ padding: 0 !important;
239
+ background: white !important;
240
+
241
+ >.cove-visualization__body-wrap {
242
+ padding: 0 !important;
243
+ }
244
+ }
245
+
246
+ .cdc-callout {
247
+ background: transparent !important;
248
+ border: 1px solid #009ec1 !important;
249
+ box-shadow: 0 2px 4px rgb(159 159 159 / 10%);
250
+ }
251
+ }
252
+ }
253
+
254
+ // TP5 Style for Gauge Chart
255
+ &.gauge__style--tp5 {
256
+
257
+ .cove-visualization__body,
258
+ .cove-visualization__body.component--has-legacy-border,
259
+ .cove-visualization__body.component--has-border-color-theme,
260
+ .cove-visualization__body.component--has-background,
261
+ .cove-visualization__body.component--has-accent {
262
+ padding: 0 !important;
263
+ background: none !important;
264
+ container-type: inline-size;
265
+
266
+ >.cove-visualization__body-wrap {
267
+ padding: 0 !important;
268
+ }
269
+ }
270
+
271
+ .cdc-callout {
272
+ box-shadow: 0 2px 4px rgb(159 159 159 / 10%);
273
+ margin: 0 !important;
274
+ padding: 1.5rem;
275
+ background-color: var(--colors-cyan-10, #eff9fa);
276
+ border: 1px solid var(--colors-cyan-15, #dff2f6);
277
+ position: relative;
278
+ border-radius: 0.25rem;
279
+ gap: 0.5rem;
280
+ }
281
+
282
+ .cdc-callout__flag {
283
+ position: absolute;
284
+ top: -0.25rem;
285
+ right: 1.08rem;
286
+ width: 1.85rem;
287
+ height: auto;
288
+ }
289
+
290
+ .cdc-callout__heading {
291
+ font-family: var(--fonts-nunito) !important;
292
+ width: 100%;
293
+ font-size: 1.1rem;
294
+ }
295
+
296
+ .cove-gauge-chart {
297
+ padding: 0;
298
+ }
299
+
300
+ .cove-gauge-chart__chart {
301
+ width: 100%;
302
+ }
303
+
304
+ .cove-gauge-chart__chart>svg {
305
+ display: block;
306
+ width: 100%;
307
+ }
308
+
309
+ .cove-gauge-chart__body {
310
+ flex-wrap: nowrap;
311
+ gap: 1rem;
312
+ row-gap: 0.5rem;
313
+ margin-bottom: 0.5rem;
314
+ align-items: flex-start; // Align to top instead of center when content varies
315
+ }
316
+
317
+ // Container query: wrap when width is less than 576px
318
+ @container (max-width: 576px) {
319
+ .cove-gauge-chart__body {
320
+ flex-wrap: wrap;
321
+
322
+ .cove-gauge-chart__value-section {
323
+ width: 100%;
324
+ }
325
+ }
326
+ }
327
+
328
+ .cove-gauge-chart__value-section {
329
+ width: auto;
330
+ padding-top: 1px;
331
+ display: flex;
332
+ flex-direction: column;
333
+ justify-content: flex-start;
334
+ }
335
+
336
+ .cove-gauge-chart__content {
194
337
  font-size: 1rem;
338
+ min-height: 1rem; // Ensure minimum height even when empty
195
339
  }
340
+
196
341
  .cove-waffle-chart__data--primary {
197
342
  font-size: 2rem;
198
343
  color: var(--colors-cyan-60v);
199
344
  font-weight: 400;
345
+ line-height: 1;
346
+ }
347
+
348
+ .cove-waffle-chart__data--text {
349
+ margin-top: 0;
350
+ font-size: 1rem;
351
+ }
352
+
353
+ .cove-waffle-chart__subtext {
354
+ line-height: var(--visualization-body-line-height);
355
+ margin-top: auto;
200
356
  }
201
357
 
202
358
  // White background variant (when "Use White Background Style" is checked)
203
359
  &.white-background-style {
204
- .cove-component__content {
360
+
361
+ .cove-visualization__body,
362
+ .cove-visualization__body.component--has-legacy-border,
363
+ .cove-visualization__body.component--has-border-color-theme,
364
+ .cove-visualization__body.component--has-background,
365
+ .cove-visualization__body.component--has-accent {
366
+ padding: 0 !important;
205
367
  background: white !important;
368
+
369
+ >.cove-visualization__body-wrap {
370
+ padding: 0 !important;
371
+ }
206
372
  }
207
373
 
208
374
  .cdc-callout {
@@ -213,3 +379,11 @@
213
379
  }
214
380
  }
215
381
  }
382
+
383
+ // Center gauge value when there's no message (standalone only, not in dashboard rows)
384
+ .type-waffle-chart.gauge__style--tp5:not(.row *) {
385
+ .cove-gauge-chart__body.d-flex.justify-content-center {
386
+ justify-content: center;
387
+ width: 100%;
388
+ }
389
+ }
@@ -3,7 +3,7 @@ import ChartActions from './chart.actions'
3
3
 
4
4
  type ChartState = {
5
5
  config?: Config
6
- container: any
6
+ container: HTMLElement | null
7
7
  coveLoadedHasRan: boolean
8
8
  loading: boolean
9
9
  preview: boolean
@@ -1,11 +1,11 @@
1
- import path from 'path'
1
+ import path from 'node:path'
2
2
  import { testStandaloneBuild } from '@cdc/core/helpers/tests/testStandaloneBuild.ts'
3
3
  import { describe, it, expect } from 'vitest'
4
4
 
5
5
  describe('Waffle Chart', () => {
6
6
  it('Can be built in isolation', async () => {
7
7
  const pkgDir = path.join(__dirname, '..')
8
- const result = testStandaloneBuild(pkgDir)
8
+ const result = await testStandaloneBuild(pkgDir)
9
9
  expect(result).toBe(true)
10
10
  }, 300000)
11
11
  })
@@ -16,6 +16,7 @@ export type Config = {
16
16
  dataDenomFunction: string
17
17
  dataFunction: string
18
18
  dataUrl?: string
19
+ dataMetadata?: any
19
20
  filters: any[]
20
21
  // data point font size (main number)
21
22
  fontSize: string
@@ -40,6 +41,9 @@ export type Config = {
40
41
  whiteBackground?: boolean
41
42
  }
42
43
  visualizationSubType: 'linear' | ''
43
- visualizationType: 'Gauge' | 'Waffle' | 'TP5 Waffle'
44
+ visualizationType: 'Gauge' | 'Waffle' | 'TP5 Waffle' | 'TP5 Gauge'
44
45
  version: Version
46
+ locale: string
47
+ markupVariables?: any[]
48
+ enableMarkupVariables?: boolean
45
49
  }
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
3
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="481.000000pt" height="563.000000pt" viewBox="0 0 481.000000 563.000000" preserveAspectRatio="xMidYMid meet">
4
- <g transform="translate(0.000000,563.000000) scale(0.100000,-0.100000)" fill="#2c7a99" stroke="none">
5
- <path d="M890 5514 c-161 -43 -308 -201 -354 -381 -14 -55 -16 -314 -16 -2527 0 -2015 2 -2466 13 -2466 7 0 51 14 97 30 47 17 92 33 100 35 8 2 16 4 18 5 1 2 7 4 12 5 6 1 11 3 13 4 1 2 13 4 26 7 14 2 30 9 38 15 7 6 13 8 13 4 0 -4 7 -2 15 5 8 7 15 10 15 6 0 -3 17 1 38 10 49 21 856 293 905 305 21 5 45 13 55 19 9 5 40 16 67 24 28 8 162 52 299 99 l249 85 151 -53 c83 -29 253 -90 379 -134 264 -94 556 -198 974 -346 164 -58 308 -110 321 -115 13 -6 27 -10 33 -10 11 0 8 4951 -4 4994 -22 80 -84 183 -152 252 -75 76 -141 114 -233 133 -38 8 -477 11 -1535 10 -1268 0 -1490 -3 -1537 -15z m2687 -1570 c49 -31 82 -134 64 -201 -10 -37 -41 -64 -422 -369 -227 -181 -430 -341 -452 -356 -43 -30 -84 -35 -136 -17 -17 6 -156 107 -309 224 l-277 213 -40 -31 c-50 -39 -318 -259 -325 -267 -3 -3 -27 -24 -55 -45 -27 -22 -55 -44 -61 -50 -86 -77 -253 -202 -277 -207 -20 -4 -53 -1 -84 8 -69 19 -105 64 -111 140 -6 70 8 100 69 149 105 84 134 107 168 133 19 15 92 74 164 132 71 58 144 116 162 130 86 68 114 90 187 150 124 102 156 120 206 120 23 0 57 -7 75 -16 18 -9 145 -103 282 -209 283 -217 293 -224 303 -210 4 6 42 39 86 74 43 35 88 71 100 81 31 27 153 127 231 190 37 30 111 91 164 135 142 119 217 145 288 99z m-1431 -983 c60 -44 59 -29 62 -601 3 -596 4 -589 -70 -638 -76 -49 -171 -29 -228 50 l-30 41 0 526 c0 591 -3 569 75 623 35 25 48 28 100 25 44 -2 69 -9 91 -26z m1252 15 c37 -19 67 -55 81 -95 8 -25 10 -183 9 -555 -3 -579 -1 -555 -71 -603 -67 -45 -144 -35 -211 27 l-41 39 -3 543 -2 544 23 35 c46 68 149 99 215 65z m-610 -343 c71 -57 71 -57 71 -448 0 -322 -1 -353 -19 -392 -27 -60 -83 -95 -155 -95 -63 -1 -95 16 -132 72 -23 33 -23 36 -23 407 0 406 -1 401 57 455 34 32 54 38 116 34 35 -2 57 -11 85 -33z m-1313 -142 c54 -24 92 -71 100 -124 4 -23 5 -159 3 -302 -3 -293 -3 -293 -82 -343 -66 -41 -160 -30 -207 24 -34 40 -39 84 -39 361 0 303 3 322 61 366 53 39 105 45 164 18z"/>
6
- </g>
7
- </svg>