@cdc/data-bite 4.26.2 → 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.
@@ -5,15 +5,17 @@ export const KPIComponent = ({ label, value }) => {
5
5
  return (
6
6
  <div className='cove-component__content kpi-container'>
7
7
  <div className='kpi-content'>
8
- <div className='label-container'>
9
- <span className='label'>
10
- <strong>{label}</strong>
11
- </span>
12
- </div>
13
- <div className='value-container'>
14
- <span className='value'>
15
- <strong>{value}</strong>
16
- </span>
8
+ <div className='kpi-main'>
9
+ <div className='label-container'>
10
+ <span className='label'>
11
+ <strong>{label}</strong>
12
+ </span>
13
+ </div>
14
+ <div className='value-container'>
15
+ <span className='value'>
16
+ <strong>{value}</strong>
17
+ </span>
18
+ </div>
17
19
  </div>
18
20
  </div>
19
21
  </div>
@@ -27,12 +27,13 @@ export default {
27
27
  theme: 'theme-blue',
28
28
  shadow: false,
29
29
  visual: {
30
- border: false,
30
+ border: true,
31
31
  accent: false,
32
32
  background: false,
33
33
  hideBackgroundColor: false,
34
34
  borderColorTheme: false,
35
- showTitle: true
35
+ showTitle: true,
36
+ useWrap: false
36
37
  },
37
38
  general: {
38
39
  isCompactStyle: false
@@ -1,3 +1,5 @@
1
+ @import '@cdc/core/styles/layout/wrapper-padding';
2
+
1
3
  &.theme-blue {
2
4
  .bite-value {
3
5
  color: var(--primary);
@@ -67,32 +69,69 @@
67
69
  // TODO after v2 refactor remove header reference colors
68
70
  // Use .font-color/.bg-color, etc. in color definitions or something similar
69
71
  // Remove box shadows if we're no longer using them
70
- &.cdc-open-viz-module.isEditor .sidebar + .cove-component__content {
72
+ &.cove-visualization.is-editor .sidebar+.cove-visualization__body {
71
73
  margin: 3em auto 0 !important;
72
74
  max-width: 35em !important;
73
- background-color: initial;
75
+ background-color: var(--lightestGray);
74
76
  height: fit-content;
75
77
  }
76
78
 
77
- .sidebar + .cove-component__content .bite-content-container:not(.component--hide-background-color) {
78
- background-color: white;
79
+ .sidebar+.cove-visualization__body .bite-content-container:not(.component--hide-background-color) {
80
+ background-color: var(--lightestGray);
79
81
  }
80
82
 
81
- .cove-component__content {
82
- padding: 0;
83
- // Visual: Shadow
84
- &.shadow {
85
- box-shadow: rgba(0, 0, 0, 0.2) 0 3px 10px;
83
+ .cove-visualization__body {
84
+ @include cove-visualization-body-padding;
85
+ background: var(--lightestGray);
86
+
87
+ &.component--hide-background-color {
88
+ background: transparent;
86
89
  }
87
90
 
88
- .cove-component__inner {
89
- padding: 1rem !important;
91
+
92
+ &.bite__style--gradient {
93
+ background: transparent !important;
90
94
  }
91
95
 
96
+ >.cove-visualization__body-wrap {
97
+ @include cove-visualization-body-wrap-inline-padding;
98
+ }
99
+
100
+
92
101
  // General: Bite Style > Graphic
93
102
  &.bite__style--graphic {
103
+ .bite-content-container {
104
+ display: flex;
105
+ align-items: flex-start;
106
+ gap: 0;
107
+ }
108
+
94
109
  .bite-content {
95
110
  flex: 1;
111
+ min-width: 0;
112
+ justify-content: space-between;
113
+ gap: 0;
114
+ align-self: stretch;
115
+ }
116
+
117
+ .bite-content__text-wrap {
118
+ flex: 0 0 auto;
119
+ }
120
+
121
+ .bite-subtext {
122
+ align-self: flex-end;
123
+ width: 100%;
124
+ line-height: var(--visualization-body-line-height);
125
+ }
126
+
127
+ .bite-right .bite-content-container,
128
+ .bite-bottom .bite-content-container {
129
+ flex-direction: row-reverse;
130
+ }
131
+
132
+ .callout {
133
+ width: 33%;
134
+ margin: 0;
96
135
  }
97
136
  }
98
137
 
@@ -106,11 +145,13 @@
106
145
  .bite-content {
107
146
  flex-direction: row !important;
108
147
  }
148
+
109
149
  .bite-value {
110
150
  flex-basis: 25%;
111
151
  align-self: center;
112
152
  text-align: center;
113
153
  }
154
+
114
155
  .bite-content__text-wrap {
115
156
  flex: 75% !important;
116
157
  }
@@ -118,15 +159,17 @@
118
159
 
119
160
  // TP5 Style (default: callout with blue background)
120
161
  &.bite__style--tp5 {
121
- padding: 0 !important;
122
162
  border: none !important;
123
- height: 100%; // Allow height to fill parent container
163
+ padding: 0 !important;
124
164
  background: none !important;
125
165
  container-type: inline-size;
126
166
 
167
+ >.cove-visualization__body-wrap {
168
+ padding: 0 !important;
169
+ }
170
+
127
171
  .cdc-callout {
128
172
  gap: 0.7rem;
129
- box-shadow: 0 2px 4px rgb(159 159 159 / 10%);
130
173
  border: 1px solid #dff2f6 !important;
131
174
  margin: 0 !important;
132
175
  padding: 1.25rem;
@@ -155,6 +198,15 @@
155
198
  }
156
199
  }
157
200
 
201
+ &.use-wrap .cdc-callout__body {
202
+ flex-wrap: wrap;
203
+
204
+ .cdc-callout__databite,
205
+ .cdc-callout__content {
206
+ flex-basis: 100%;
207
+ }
208
+ }
209
+
158
210
  .cdc-callout__databite {
159
211
  padding-top: 2px;
160
212
  width: auto;
@@ -171,49 +223,50 @@
171
223
  height: auto;
172
224
  }
173
225
 
226
+
174
227
  .cdc-callout__content {
175
- font-size: 1rem;
228
+ row-gap: var(--cove-visualization-section-gap, 1.5rem);
176
229
  }
177
230
 
178
231
  .bite-subtext {
179
- margin-top: auto; // Push to bottom on desktop
180
232
  font-style: italic;
233
+ line-height: var(--visualization-body-line-height);
181
234
  }
182
235
 
183
236
  // White background variant (when "Use White Background Style" is checked)
184
237
  &.white-background-style {
238
+ padding: 0 !important;
185
239
  background: white;
186
240
 
241
+ >.cove-visualization__body-wrap {
242
+ padding: 0 !important;
243
+ }
244
+
187
245
  .cdc-callout {
188
246
  border: 1px solid #009ec1 !important;
189
247
  background: transparent;
190
- box-shadow: 0 2px 4px rgb(159 159 159 / 10%);
191
248
  }
192
249
  }
193
250
 
194
- // White background with border (when both white background and Display Border are checked)
195
- &.white-background-style.display-border {
196
- .cdc-callout {
197
- box-shadow: 0 2px 4px rgb(159 159 159 / 10%);
198
- }
199
- }
251
+ }
252
+
253
+ &.component--hide-background-color .bite .bite-content-container {
254
+ background: transparent;
200
255
  }
201
256
 
202
257
  // General: Compact View
203
- &.bite--isCompactStyle .bite .cove-component__content .bite-content {
258
+ &.bite--is-compact-style .bite .bite-content-container .bite-content {
204
259
  align-items: center;
260
+
205
261
  p.bite-text {
206
262
  margin-bottom: 0;
207
263
  }
208
264
  }
209
265
 
210
- &.bite--isCompactStyle .bite .cove-component__content {
266
+ &.bite--is-compact-style .bite .bite-content-container {
211
267
  align-items: center;
212
268
  }
213
269
 
214
- .cove-component__header + .bite {
215
- border-top: 0;
216
- }
217
270
  .bite {
218
271
  position: relative;
219
272
  overflow: hidden;
@@ -225,9 +278,6 @@
225
278
  border-top-left-radius: 3px;
226
279
  border-top-right-radius: 3px;
227
280
  }
228
- .bite-content-container.component--hideBackgroundColor {
229
- background: transparent;
230
- }
231
281
 
232
282
  &.no-borders {
233
283
  border: none;
@@ -238,6 +288,7 @@
238
288
  display: flex;
239
289
  flex-wrap: wrap;
240
290
  width: 100%;
291
+ row-gap: var(--cove-visualization-section-gap, 1.5rem);
241
292
  }
242
293
 
243
294
  &.theme-blue {
@@ -318,10 +369,8 @@
318
369
  border-radius: 0.3em;
319
370
  }
320
371
 
321
- .cove-component__content {
372
+ .bite-content-container {
322
373
  display: flex;
323
- padding: 1em !important;
324
- justify-content: space-between;
325
374
 
326
375
  .bite-content {
327
376
  display: flex;
@@ -339,12 +388,10 @@
339
388
  }
340
389
 
341
390
  .bite-text {
342
- margin-bottom: 15px;
343
391
  color: #222;
344
392
  }
345
393
 
346
394
  .bite-subtext {
347
- font-size: 0.9em;
348
395
  font-style: italic;
349
396
  flex-basis: 100%;
350
397
  width: 100%;
@@ -367,13 +414,14 @@
367
414
  width: 33%;
368
415
  margin-left: 1.5em;
369
416
  }
370
- .cove-component__content {
417
+
418
+ .bite-content-container {
371
419
  flex-direction: row-reverse;
372
420
  }
373
421
  }
374
422
 
375
423
  &.bite-top {
376
- .cove-component__content {
424
+ .bite-content-container {
377
425
  flex-direction: column;
378
426
 
379
427
  .bite-image {
@@ -392,7 +440,7 @@
392
440
  }
393
441
 
394
442
  &.bite-bottom {
395
- .cove-component__content {
443
+ .bite-content-container {
396
444
  flex-direction: column;
397
445
 
398
446
  .bite-image {
@@ -411,7 +459,7 @@
411
459
  }
412
460
 
413
461
  &.bite-back {
414
- .cove-component__content {
462
+ .bite-content-container {
415
463
  .bite-image {
416
464
  border-radius: 0 0 0.3em 0.3em;
417
465
  position: absolute;
@@ -423,29 +471,25 @@
423
471
  }
424
472
 
425
473
  // General: Compact View
426
- &.bite--isCompactStyle .bite .cove-component__content .bite-content {
474
+ &.bite--is-compact-style .bite-content-container .bite-content {
427
475
  align-items: center;
476
+
428
477
  p.bite-text {
429
478
  margin-bottom: 0;
430
479
  }
431
480
  }
432
481
 
433
- &.bite--isCompactStyle .bite .cove-component__content {
482
+ &.bite--is-compact-style .bite-content-container {
434
483
  align-items: center;
435
484
  }
436
485
 
437
- .cove-component__header + .bite {
438
- border-top: 0;
439
- }
440
486
  }
441
487
  }
442
488
 
443
- .cove-component__content {
444
- background: var(--lightestGray);
445
-
489
+ .cove-visualization__body {
446
490
  &:not(.no-borders) {
447
491
  border-color: var(--lightGray);
448
492
  border-width: 1px;
449
493
  border-style: solid;
450
494
  }
451
- }
495
+ }
package/src/scss/kpi.scss CHANGED
@@ -2,10 +2,9 @@
2
2
  border-radius: 10px;
3
3
  border: 1px solid rgba(0, 0, 0, 0.25) !important;
4
4
  box-sizing: border-box;
5
- box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
6
5
  display: flex;
7
6
  padding: 5px !important;
8
- height: 70px;
7
+ min-height: 70px;
9
8
  width: 100%;
10
9
  position: relative;
11
10
  display: flex;
@@ -15,9 +14,15 @@
15
14
  background: linear-gradient(90deg, rgba(8, 132, 136, 1) 19%, rgba(255, 255, 255, 1) 74%);
16
15
  border-radius: 10px;
17
16
  display: flex;
17
+ flex-direction: column;
18
18
  flex: 1;
19
19
  }
20
20
 
21
+ .kpi-main {
22
+ display: flex;
23
+ min-height: 70px;
24
+ }
25
+
21
26
  .label-container,
22
27
  .value-container {
23
28
  display: flex;
@@ -44,6 +49,12 @@
44
49
  font-size: 24px;
45
50
  }
46
51
 
52
+ .kpi-subtext {
53
+ padding: 0 1rem 1rem 30px;
54
+ font-size: 0.9em;
55
+ font-style: italic;
56
+ }
57
+
47
58
  //small
48
59
  @media only screen and (min-width: 768px) and (max-width: 991px) {
49
60
  .label {
@@ -65,4 +76,8 @@
65
76
  .value {
66
77
  font-size: 14px;
67
78
  }
79
+
80
+ .kpi-subtext {
81
+ padding-left: 10px;
82
+ }
68
83
  }
@@ -1,4 +1,4 @@
1
- .cdc-open-viz-module.type-data-bite {
1
+ .cove-visualization.type-data-bite {
2
2
  @import 'bite';
3
3
  @import 'editor-panel';
4
4
 
@@ -1,11 +1,32 @@
1
- import path from 'path'
1
+ import path from 'node:path'
2
+ import React from 'react'
3
+ import { render, screen } from '@testing-library/react'
2
4
  import { testStandaloneBuild } from '@cdc/core/helpers/tests/testStandaloneBuild.ts'
3
5
  import { describe, it, expect } from 'vitest'
6
+ import CdcDataBite from '../CdcDataBite'
4
7
 
5
8
  describe('Data Bite', () => {
6
9
  it('Can be built in isolation', async () => {
7
10
  const pkgDir = path.join(__dirname, '..')
8
- const result = testStandaloneBuild(pkgDir)
11
+ const result = await testStandaloneBuild(pkgDir)
9
12
  expect(result).toBe(true)
10
13
  }, 300000)
14
+
15
+ it('renders when config.general is omitted', async () => {
16
+ render(
17
+ <CdcDataBite
18
+ config={{
19
+ type: 'data-bite',
20
+ theme: 'theme-blue',
21
+ title: 'Test title',
22
+ biteBody: 'Test body',
23
+ subtext: 'Test subtext',
24
+ data: []
25
+ }}
26
+ />
27
+ )
28
+
29
+ expect(await screen.findByText('Test body')).toBeInTheDocument()
30
+ expect(screen.getByText('Test subtext')).toBeInTheDocument()
31
+ })
11
32
  })
@@ -5,6 +5,7 @@ import { VizFilter } from '@cdc/core/types/VizFilter'
5
5
  export type Config = {
6
6
  type: string
7
7
  data: Object[]
8
+ dataMetadata?: Record<string, string>
8
9
  dataBite: string
9
10
  dataFunction: string
10
11
  dataColumn: string
@@ -29,6 +30,7 @@ export type Config = {
29
30
  subtext: string
30
31
  title: string
31
32
  theme: string
33
+ /** @deprecated shadows have been removed from data bites */
32
34
  shadow: boolean
33
35
  visual: {
34
36
  border: boolean
@@ -38,9 +40,11 @@ export type Config = {
38
40
  borderColorTheme: boolean
39
41
  showTitle: boolean
40
42
  whiteBackground: boolean
43
+ useWrap?: boolean
41
44
  }
42
45
  general: {
43
46
  isCompactStyle: boolean
44
47
  }
45
48
  version: Version
49
+ locale: string
46
50
  } & MarkupConfig
@@ -0,0 +1,35 @@
1
+ {
2
+ "type": "data-bite",
3
+ "dataUrl": "/packages/data-bite/tests/fixtures/data-with-metadata.json",
4
+ "dataBite": "",
5
+ "dataFunction": "Mean (Average)",
6
+ "dataColumn": "Insured Rate",
7
+ "bitePosition": "Left",
8
+ "biteFontSize": "24",
9
+ "imageData": {
10
+ "display": "none",
11
+ "url": "",
12
+ "options": []
13
+ },
14
+ "biteBody": "Test data bite body text",
15
+ "dataFormat": {
16
+ "roundToPlace": 0,
17
+ "commas": true,
18
+ "prefix": "",
19
+ "suffix": "%"
20
+ },
21
+ "filters": [],
22
+ "biteStyle": "graphic",
23
+ "enableMarkupVariables": true,
24
+ "markupVariables": [
25
+ {
26
+ "name": "Last Updated",
27
+ "tag": "{{lastUpdated}}",
28
+ "metadataKey": "lastUpdated",
29
+ "conditions": []
30
+ }
31
+ ],
32
+ "subtext": "Data last updated {{lastUpdated}}",
33
+ "title": "Insurance Coverage Rate",
34
+ "theme": "theme-blue"
35
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "lastUpdated": "January 15, 2026",
3
+ "source": "CDC NREVSS",
4
+ "data": [
5
+ {
6
+ "Insured Rate": "43",
7
+ "Coverage Status": "Insured",
8
+ "state": "Alabama",
9
+ "Year (Good filter option)": "2010"
10
+ },
11
+ {
12
+ "Insured Rate": "72.7",
13
+ "Coverage Status": "Insured",
14
+ "state": "Arizona",
15
+ "Year (Good filter option)": "2010"
16
+ },
17
+ {
18
+ "Insured Rate": "37.2",
19
+ "Coverage Status": "Insured",
20
+ "state": "California",
21
+ "Year (Good filter option)": "2010"
22
+ },
23
+ {
24
+ "Insured Rate": "50.6",
25
+ "Coverage Status": "Insured",
26
+ "state": "Colorado",
27
+ "Year (Good filter option)": "2010"
28
+ }
29
+ ]
30
+ }
@@ -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>