@cdc/core 4.25.8 → 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.
- package/components/AdvancedEditor/AdvancedEditor.tsx +29 -8
- package/components/DataTable/DataTable.tsx +56 -38
- package/components/DataTable/components/ChartHeader.tsx +44 -14
- package/components/DataTable/components/ExpandCollapse.tsx +10 -1
- package/components/DataTable/components/MapHeader.tsx +24 -13
- package/components/DataTable/data-table.css +6 -0
- package/components/DataTable/helpers/chartCellMatrix.tsx +11 -8
- package/components/DataTable/helpers/mapCellMatrix.tsx +19 -1
- package/components/DownloadButton.tsx +40 -14
- package/components/EditorPanel/components/MarkupHighlightedTextField.tsx +227 -0
- package/components/EditorPanel/components/MarkupVariablesEditor.tsx +411 -0
- package/components/EditorPanel/components/PanelMarkup.tsx +59 -0
- package/components/ErrorBoundary.jsx +3 -1
- package/components/Filters/Filters.tsx +27 -20
- package/components/Filters/components/Tabs.tsx +1 -0
- package/components/Legend/Legend.Gradient.tsx +3 -6
- package/components/LegendShape.tsx +121 -3
- package/components/MediaControls.tsx +51 -3
- package/components/PaletteConversionModal.tsx +87 -0
- package/components/PaletteSelector/DeveloperPaletteRollback.tsx +114 -0
- package/components/PaletteSelector/PaletteSelector.css +51 -0
- package/components/PaletteSelector/PaletteSelector.tsx +112 -0
- package/components/PaletteSelector/index.ts +2 -0
- package/components/RichTooltip/RichTooltip.tsx +1 -0
- package/components/Table/Table.tsx +3 -1
- package/components/_stories/BlurStrokeTest.stories.tsx +1 -1
- package/components/_stories/DataTable.stories.tsx +1 -1
- package/components/_stories/Filters.stories.tsx +1 -1
- package/components/_stories/Footnotes.stories.tsx +1 -1
- package/components/_stories/Inputs.stories.tsx +1 -1
- package/components/_stories/MultiSelect.stories.tsx +3 -3
- package/components/_stories/NestedDropdown.stories.tsx +1 -1
- package/components/_stories/Table.stories.tsx +1 -1
- package/components/elements/_stories/Button.stories.tsx +1 -1
- package/components/elements/_stories/Card.stories.tsx +1 -1
- package/components/inputs/InputToggle.tsx +2 -0
- package/components/managers/DataDesigner.tsx +10 -9
- package/components/managers/_stories/DataDesigner.stories.tsx +1 -1
- package/components/ui/Tooltip.tsx +2 -1
- package/components/ui/_stories/Accordion.stories.tsx +1 -1
- package/components/ui/_stories/ColorPaletteMigration.stories.mdx +275 -0
- package/components/ui/_stories/Colors.stories.tsx +330 -0
- package/components/ui/_stories/IconGallery.stories.tsx +316 -0
- package/components/ui/_stories/Title.stories.tsx +1 -1
- package/contexts/EditorContext.ts +18 -0
- package/contexts/editor.actions.ts +28 -0
- package/contexts/editor.reducer.ts +94 -0
- package/data/chartColorPalettes.ts +118 -0
- package/data/colorPalettes.ts +9 -0
- package/data/mapColorPalettes.ts +45 -0
- package/data/sharedPalettes.ts +50 -0
- package/dist/cove-main.css +14 -11
- package/dist/cove-main.css.map +1 -1
- package/generateViteConfig.js +80 -0
- package/helpers/addValuesToFilters.ts +2 -3
- package/helpers/cloneConfig.ts +31 -0
- package/helpers/configDataHelpers.ts +128 -0
- package/helpers/configHelpers.ts +27 -0
- package/helpers/constants.ts +5 -2
- package/helpers/coveUpdateWorker.ts +13 -3
- package/helpers/filterColorPalettes.ts +152 -0
- package/helpers/generateColorsArray.ts +13 -0
- package/helpers/getColorPaletteVersion.ts +33 -0
- package/helpers/getPaletteAccessor.ts +18 -0
- package/helpers/markupProcessor.ts +205 -0
- package/helpers/metrics/helpers.ts +42 -19
- package/helpers/metrics/types.ts +48 -9
- package/helpers/metrics/utils.ts +34 -0
- package/helpers/palettes/colorDistributions.ts +56 -0
- package/helpers/palettes/migratePaletteName.ts +150 -0
- package/helpers/palettes/standardizePaletteNames.ts +77 -0
- package/helpers/palettes/utils.ts +267 -0
- package/helpers/queryStringUtils.ts +13 -0
- package/helpers/testing.ts +345 -0
- package/helpers/tests/addValuesToFilters.test.ts +1 -2
- package/helpers/tests/generateColorsArray.test.ts +24 -0
- package/helpers/tests/markupProcessor.test.ts +538 -0
- package/helpers/tests/testStandaloneBuild.ts +44 -0
- package/helpers/useMarkupVariables.ts +31 -0
- package/helpers/vegaConfig.ts +0 -1
- package/helpers/ver/4.24.10.ts +2 -1
- package/helpers/ver/4.24.11.ts +2 -1
- package/helpers/ver/4.24.3.ts +2 -1
- package/helpers/ver/4.24.4.ts +2 -1
- package/helpers/ver/4.24.5.ts +2 -1
- package/helpers/ver/4.24.7.ts +2 -1
- package/helpers/ver/4.24.9.ts +2 -1
- package/helpers/ver/4.25.1.ts +2 -1
- package/helpers/ver/4.25.10.ts +36 -0
- package/helpers/ver/4.25.3.ts +2 -1
- package/helpers/ver/4.25.4.ts +2 -1
- package/helpers/ver/4.25.6.ts +2 -1
- package/helpers/ver/4.25.7.ts +2 -1
- package/helpers/ver/4.25.8.ts +2 -1
- package/helpers/ver/4.25.9.ts +293 -0
- package/helpers/ver/tests/4.25.10.test.ts +204 -0
- package/helpers/ver/tests/4.25.8.test.ts +1 -1
- package/helpers/ver/tests/4.25.9.test.ts +51 -0
- package/hooks/useColorPalette.ts +79 -0
- package/package.json +12 -4
- package/styles/_global.scss +7 -5
- package/styles/base.scss +8 -5
- package/styles/v2/components/button.scss +4 -3
- package/styles/v2/components/editor.scss +2 -1
- package/styles/v2/layout/_data-table.scss +3 -2
- package/styles/v2/themes/_color-definitions.scss +18 -17
- package/testBuild.js +0 -0
- package/testing-setup.js +32 -0
- package/types/MarkupInclude.ts +6 -1
- package/types/MarkupVariable.ts +19 -0
- package/types/VizFilter.ts +1 -0
- package/vitest.config.ts +16 -0
- package/components/ui/_stories/Colors.stories.mdx +0 -220
- package/components/ui/_stories/IconGallery.stories.mdx +0 -14
- package/data/colorPalettes.js +0 -171
- package/helpers/formatConfigBeforeSave.ts +0 -135
- package/helpers/tests/formatConfigBeforeSave.test.ts +0 -68
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { changeSingleStateMapNoDataMessage } from '../4.25.9'
|
|
2
|
+
import { expect, describe, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('changeSingleStateMapNoDataMessage', () => {
|
|
5
|
+
it('should set noDataMessage to "No State Selected" if the message is default', () => {
|
|
6
|
+
const config: any = {
|
|
7
|
+
type: 'map',
|
|
8
|
+
general: { noStateFoundMessage: 'Map Unavailable' },
|
|
9
|
+
runtime: {}
|
|
10
|
+
}
|
|
11
|
+
changeSingleStateMapNoDataMessage(config)
|
|
12
|
+
expect(config.general.noDataMessage).toBe('No State Selected')
|
|
13
|
+
expect(config.general.noStateFoundMessage).toBeUndefined()
|
|
14
|
+
expect(config.runtime.noStateFoundMessage).toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('should preserve custom noStateFoundMessage', () => {
|
|
18
|
+
const config: any = {
|
|
19
|
+
type: 'map',
|
|
20
|
+
general: { noStateFoundMessage: 'Custom Message' },
|
|
21
|
+
runtime: {}
|
|
22
|
+
}
|
|
23
|
+
changeSingleStateMapNoDataMessage(config)
|
|
24
|
+
expect(config.general.noDataMessage).toBe('Custom Message')
|
|
25
|
+
expect(config.general.noStateFoundMessage).toBeUndefined()
|
|
26
|
+
expect(config.runtime.noStateFoundMessage).toBeUndefined()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should work for dashboard configs with map visualizations', () => {
|
|
30
|
+
const dashboardConfig: any = {
|
|
31
|
+
type: 'dashboard',
|
|
32
|
+
visualizations: {
|
|
33
|
+
map1: {
|
|
34
|
+
type: 'map',
|
|
35
|
+
general: { noStateFoundMessage: 'Map Unavailable' },
|
|
36
|
+
runtime: {}
|
|
37
|
+
},
|
|
38
|
+
chart1: {
|
|
39
|
+
type: 'chart',
|
|
40
|
+
general: {},
|
|
41
|
+
runtime: {}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
changeSingleStateMapNoDataMessage(dashboardConfig)
|
|
46
|
+
expect(dashboardConfig.visualizations.map1.general.noDataMessage).toBe('No State Selected')
|
|
47
|
+
expect(dashboardConfig.visualizations.map1.general.noStateFoundMessage).toBeUndefined()
|
|
48
|
+
expect(dashboardConfig.visualizations.map1.runtime.noStateFoundMessage).toBeUndefined()
|
|
49
|
+
expect(dashboardConfig.visualizations.chart1.general.noDataMessage).toBeUndefined()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react'
|
|
2
|
+
import { filterColorPalettes } from '../helpers/filterColorPalettes'
|
|
3
|
+
import { twoColorPalette, chartColorPalettes } from '../data/colorPalettes'
|
|
4
|
+
|
|
5
|
+
export interface UseColorPaletteResult {
|
|
6
|
+
sequential: string[]
|
|
7
|
+
nonSequential: string[]
|
|
8
|
+
accessibleColors: string[]
|
|
9
|
+
twoColorPalettes: string[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* React hook for filtering color palettes based on config and visualization type
|
|
14
|
+
* Provides filtered palettes for chart visualization components
|
|
15
|
+
*/
|
|
16
|
+
export const useColorPalette = (config: any, updateConfig?: (newConfig: any) => void): UseColorPaletteResult => {
|
|
17
|
+
// Get filtered palettes using the core filtering logic
|
|
18
|
+
const filteredPalettes = useMemo(() => {
|
|
19
|
+
const isReversed = config.general?.palette?.isReversed
|
|
20
|
+
const visualizationType = config.visualizationType
|
|
21
|
+
|
|
22
|
+
const result = filterColorPalettes({
|
|
23
|
+
config,
|
|
24
|
+
isReversed,
|
|
25
|
+
colorPalettes: chartColorPalettes,
|
|
26
|
+
visualizationType
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Handle two-color palettes specially for chart components
|
|
30
|
+
let twoColorPalettes: string[] = []
|
|
31
|
+
if (visualizationType === 'Paired Bar' || visualizationType === 'Deviation Bar') {
|
|
32
|
+
const isTwoColorReversed = config.twoColor?.isPaletteReversed
|
|
33
|
+
twoColorPalettes = Object.keys(twoColorPalette).filter(name =>
|
|
34
|
+
isTwoColorReversed ? name.endsWith('reverse') : !name.endsWith('reverse')
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
sequential: result.sequential,
|
|
40
|
+
nonSequential: result.nonSequential,
|
|
41
|
+
accessibleColors: result.accessibleColors,
|
|
42
|
+
twoColorPalettes: result.twoColorPalettes || twoColorPalettes
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
config.visualizationType,
|
|
46
|
+
config.general?.palette?.isReversed,
|
|
47
|
+
config.general?.palette?.version,
|
|
48
|
+
config.twoColor?.isPaletteReversed
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
// Update twoColor palette based on isPaletteReversed
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!updateConfig || !config.twoColor) return
|
|
54
|
+
|
|
55
|
+
const { isPaletteReversed, palette } = config.twoColor
|
|
56
|
+
let newPalette = ''
|
|
57
|
+
|
|
58
|
+
if (isPaletteReversed && !palette.endsWith('reverse')) {
|
|
59
|
+
newPalette = palette + 'reverse'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isPaletteReversed && palette.endsWith('reverse')) {
|
|
63
|
+
newPalette = palette.slice(0, -7)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (newPalette && newPalette !== palette) {
|
|
67
|
+
updateConfig({
|
|
68
|
+
...config,
|
|
69
|
+
twoColor: {
|
|
70
|
+
...config.twoColor,
|
|
71
|
+
palette: newPalette
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}, [config.twoColor?.isPaletteReversed, updateConfig])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
return filteredPalettes
|
|
79
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/core",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.10",
|
|
4
4
|
"description": "Core components, styles, hooks, and helpers, for the CDC Open Visualization project",
|
|
5
5
|
"moduleName": "CdcCore",
|
|
6
6
|
"main": "dist/cdccore",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"test": "vitest run --environment jsdom --reporter verbose",
|
|
9
10
|
"test-watch": "vitest watch --reporter verbose",
|
|
@@ -21,14 +22,16 @@
|
|
|
21
22
|
},
|
|
22
23
|
"license": "Apache-2.0",
|
|
23
24
|
"dependencies": {
|
|
25
|
+
"chroma-js": "3.1.2",
|
|
24
26
|
"dompurify": "^3.2.4",
|
|
25
27
|
"html2canvas": "^1.4.1",
|
|
26
28
|
"json-edit-react": "^1.27.0",
|
|
29
|
+
"papaparse": "5.5.2",
|
|
27
30
|
"prop-types": "^15.8.1",
|
|
28
31
|
"react-accessible-accordion": "^5.0.1",
|
|
29
32
|
"react-select": "^5.3.1",
|
|
30
33
|
"react-tooltip": "5.8.2-beta.3",
|
|
31
|
-
"
|
|
34
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
32
35
|
"use-debounce": "^10.0.5",
|
|
33
36
|
"vega": "^6.1.0",
|
|
34
37
|
"vega-lite": "^6.1.0"
|
|
@@ -37,8 +40,13 @@
|
|
|
37
40
|
"react": "^18.2.0",
|
|
38
41
|
"react-dom": "^18.2.0"
|
|
39
42
|
},
|
|
40
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "c2db758e74ab9b9ca1667a6f9cb41dd0dccf985d",
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"
|
|
45
|
+
"@rollup/plugin-dsv": "^3.0.2",
|
|
46
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
47
|
+
"sass": "^1.89.2",
|
|
48
|
+
"vite": "^4.4.11",
|
|
49
|
+
"vite-plugin-css-injected-by-js": "^2.4.0",
|
|
50
|
+
"vite-plugin-svgr": "^2.4.0"
|
|
43
51
|
}
|
|
44
52
|
}
|
package/styles/_global.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
|
|
1
3
|
strong {
|
|
2
4
|
font-weight: 600;
|
|
3
5
|
}
|
|
@@ -42,11 +44,11 @@ strong {
|
|
|
42
44
|
.inline-icon {
|
|
43
45
|
width: 1em !important;
|
|
44
46
|
height: auto !important;
|
|
47
|
+
font-size: 1rem;
|
|
48
|
+
color: inherit;
|
|
45
49
|
@media all and (-ms-high-contrast: none) {
|
|
46
50
|
height: 30px !important;
|
|
47
51
|
}
|
|
48
|
-
font-size: 1rem;
|
|
49
|
-
color: inherit;
|
|
50
52
|
path {
|
|
51
53
|
fill: currentColor;
|
|
52
54
|
}
|
|
@@ -76,7 +78,7 @@ strong {
|
|
|
76
78
|
font-size: 0.8 em;
|
|
77
79
|
color: #fff;
|
|
78
80
|
&:hover {
|
|
79
|
-
background-color:
|
|
81
|
+
background-color: color.adjust($red, $lightness: -5%);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -168,8 +170,8 @@ section.footnotes {
|
|
|
168
170
|
background-color: $blue;
|
|
169
171
|
border-color: $blue;
|
|
170
172
|
&:hover:not([disabled]) {
|
|
171
|
-
background-color:
|
|
172
|
-
border-color:
|
|
173
|
+
background-color: color.adjust($blue, $lightness: -5%);
|
|
174
|
+
border-color: color.adjust($blue, $lightness: -5%);
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
|
package/styles/base.scss
CHANGED
|
@@ -66,6 +66,11 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
66
66
|
.cdc-open-viz-module {
|
|
67
67
|
position: relative;
|
|
68
68
|
line-height: 1.4;
|
|
69
|
+
// Force printing chart images
|
|
70
|
+
-webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
|
|
71
|
+
color-adjust: exact !important; /* Firefox 48 – 96 */
|
|
72
|
+
print-color-adjust: exact !important; /* Firefox 97+, Safari 15.4+ */
|
|
73
|
+
|
|
69
74
|
@import 'global';
|
|
70
75
|
@import 'button-section';
|
|
71
76
|
@import 'series-list';
|
|
@@ -75,11 +80,6 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
75
80
|
appearance: auto !important;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
// Force printing chart images
|
|
79
|
-
-webkit-print-color-adjust: exact !important; /* Chrome, Safari 6 – 15.3, Edge */
|
|
80
|
-
color-adjust: exact !important; /* Firefox 48 – 96 */
|
|
81
|
-
print-color-adjust: exact !important; /* Firefox 97+, Safari 15.4+ */
|
|
82
|
-
|
|
83
83
|
$theme: (
|
|
84
84
|
'amber': (
|
|
85
85
|
'#fbab18',
|
|
@@ -234,4 +234,7 @@ body.post-type-cdc_visualization .cdc-editor .configure .editor-panel {
|
|
|
234
234
|
.ps-auto {
|
|
235
235
|
padding-left: auto !important;
|
|
236
236
|
}
|
|
237
|
+
.fw-bold {
|
|
238
|
+
font-weight: 700 !important;
|
|
239
|
+
}
|
|
237
240
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
1
2
|
@import '../utils/variables';
|
|
2
3
|
@import '../themes/index';
|
|
3
4
|
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
background-color: #44aa41;
|
|
111
112
|
|
|
112
113
|
&:hover {
|
|
113
|
-
background-color:
|
|
114
|
+
background-color: color.adjust(#44aa41, $lightness: 5%);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -118,7 +119,7 @@
|
|
|
118
119
|
background-color: #d73636;
|
|
119
120
|
|
|
120
121
|
&:hover {
|
|
121
|
-
background-color:
|
|
122
|
+
background-color: color.adjust(#d73636, $lightness: -5%);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -126,7 +127,7 @@
|
|
|
126
127
|
background-color: #a0a0a0;
|
|
127
128
|
|
|
128
129
|
&:hover {
|
|
129
|
-
background-color:
|
|
130
|
+
background-color: color.adjust(#a0a0a0, $lightness: -5%);
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
@import '../themes/index';
|
|
3
3
|
|
|
4
4
|
.cove-editor {
|
|
5
|
-
@import './../base/reset';
|
|
6
5
|
display: grid;
|
|
7
6
|
grid-template-columns: auto 1fr;
|
|
8
7
|
grid-template-areas: 'panel content';
|
|
9
8
|
height: 100vh;
|
|
10
9
|
|
|
10
|
+
@import './../base/reset';
|
|
11
|
+
|
|
11
12
|
.cove-editor__panel {
|
|
12
13
|
grid-area: panel;
|
|
13
14
|
width: $editorWidth;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
|
|
1
3
|
.cove-data-table {
|
|
2
4
|
position: relative;
|
|
3
5
|
}
|
|
@@ -144,7 +146,7 @@
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
.sort {
|
|
147
|
-
background-color:
|
|
149
|
+
background-color: color.adjust($mediumGray, $lightness: -10%);
|
|
148
150
|
background-repeat: no-repeat;
|
|
149
151
|
background-position: right 0.5em center;
|
|
150
152
|
background-size: 10px 5px;
|
|
@@ -161,7 +163,6 @@
|
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
|
|
165
166
|
.cove-data-table__footer {
|
|
166
167
|
margin-top: 1rem;
|
|
167
168
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use 'sass:string';
|
|
2
|
+
@use 'sass:list';
|
|
2
3
|
@import './../../variables';
|
|
3
4
|
|
|
4
5
|
$theme: (
|
|
@@ -82,8 +83,8 @@ $theme: (
|
|
|
82
83
|
@each $theme-name, $theme-colors in $theme {
|
|
83
84
|
// Header
|
|
84
85
|
.theme-#{$theme-name} {
|
|
85
|
-
background-color: string.unquote(nth($theme-colors, 1));
|
|
86
|
-
border-color: string.unquote(nth($theme-colors, 2));
|
|
86
|
+
background-color: string.unquote(list.nth($theme-colors, 1));
|
|
87
|
+
border-color: string.unquote(list.nth($theme-colors, 2));
|
|
87
88
|
border-bottom-style: solid;
|
|
88
89
|
border-bottom-width: 4px;
|
|
89
90
|
}
|
|
@@ -95,7 +96,7 @@ $theme: (
|
|
|
95
96
|
&:not(.no-borders) {
|
|
96
97
|
/// borders are the theme color
|
|
97
98
|
&.component--has-borderColorTheme {
|
|
98
|
-
border: 1px solid string.unquote(nth($theme-colors, 1));
|
|
99
|
+
border: 1px solid string.unquote(list.nth($theme-colors, 1));
|
|
99
100
|
}
|
|
100
101
|
/// using default border color to draw borders
|
|
101
102
|
&:not(.component--has-borderColorTheme) {
|
|
@@ -108,23 +109,23 @@ $theme: (
|
|
|
108
109
|
|
|
109
110
|
/// left accent bar
|
|
110
111
|
&.component--has-accent {
|
|
111
|
-
border-left: 0.5rem solid string.unquote(nth($theme-colors, 1)) !important;
|
|
112
|
+
border-left: 0.5rem solid string.unquote(list.nth($theme-colors, 1)) !important;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/// Apply a background color
|
|
115
116
|
&.component--has-background:not(.component--hideBackgroundColor) {
|
|
116
|
-
background: string.unquote(nth($theme-colors, 3));
|
|
117
|
+
background: string.unquote(list.nth($theme-colors, 3));
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
.cove-component__header {
|
|
121
|
-
border-color: string.unquote(nth($theme-colors, 2));
|
|
122
|
+
border-color: string.unquote(list.nth($theme-colors, 2));
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
&.theme-#{$theme-name} {
|
|
126
127
|
.cove-component__header {
|
|
127
|
-
border-color: string.unquote(nth($theme-colors, 2));
|
|
128
|
+
border-color: string.unquote(list.nth($theme-colors, 2));
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
}
|
|
@@ -135,42 +136,42 @@ $theme: (
|
|
|
135
136
|
@each $theme-name, $theme-colors in $theme {
|
|
136
137
|
&.theme-#{$theme-name} {
|
|
137
138
|
.single-filters--tab .tab--active:not(.tab--simple) {
|
|
138
|
-
border: 1px solid string.unquote(nth($theme-colors, 1));
|
|
139
|
-
border-top: 3px solid string.unquote(nth($theme-colors, 1));
|
|
139
|
+
border: 1px solid string.unquote(list.nth($theme-colors, 1));
|
|
140
|
+
border-top: 3px solid string.unquote(list.nth($theme-colors, 1));
|
|
140
141
|
border-bottom: none;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
.single-filters--tab .tab:not(.tab--active):not(.tab--simple) {
|
|
144
|
-
border-bottom: 1px solid string.unquote(nth($theme-colors, 1));
|
|
145
|
+
border-bottom: 1px solid string.unquote(list.nth($theme-colors, 1));
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
.single-filters--pill .pill--active {
|
|
148
|
-
background-color: string.unquote(nth($theme-colors, 1));
|
|
149
|
+
background-color: string.unquote(list.nth($theme-colors, 1));
|
|
149
150
|
color: #fff;
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
.theme-#{$theme-name} {
|
|
154
155
|
.single-filters--tab .tab--active:not(.tab--simple) {
|
|
155
|
-
border: 1px solid string.unquote(nth($theme-colors, 1));
|
|
156
|
-
border-top: 3px solid string.unquote(nth($theme-colors, 1));
|
|
156
|
+
border: 1px solid string.unquote(list.nth($theme-colors, 1));
|
|
157
|
+
border-top: 3px solid string.unquote(list.nth($theme-colors, 1));
|
|
157
158
|
border-bottom: none;
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
.single-filters--tab .tab:not(.tab--active):not(.tab--simple) {
|
|
161
|
-
border-bottom: 1px solid string.unquote(nth($theme-colors, 1));
|
|
162
|
+
border-bottom: 1px solid string.unquote(list.nth($theme-colors, 1));
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
.single-filters--pill .pill--active {
|
|
165
|
-
background-color: string.unquote(nth($theme-colors, 1));
|
|
166
|
+
background-color: string.unquote(list.nth($theme-colors, 1));
|
|
166
167
|
color: #fff;
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
.button__tab-bar--active {
|
|
170
|
-
outline: 2px solid string.unquote(nth($theme-colors, 1));
|
|
171
|
+
outline: 2px solid string.unquote(list.nth($theme-colors, 1));
|
|
171
172
|
}
|
|
172
173
|
.apply:not([disabled]) {
|
|
173
|
-
background-color: string.unquote(nth($theme-colors, 1));
|
|
174
|
+
background-color: string.unquote(list.nth($theme-colors, 1));
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
}
|
package/testBuild.js
ADDED
|
File without changes
|
package/testing-setup.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { expect, afterEach, describe, it } from 'vitest'
|
|
2
|
+
import { cleanup } from '@testing-library/react'
|
|
3
|
+
import matchers from '@testing-library/jest-dom/matchers'
|
|
4
|
+
import '@testing-library/jest-dom'
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect'
|
|
6
|
+
|
|
7
|
+
// extends Vitest's expect method with methods from react-testing-library
|
|
8
|
+
expect.extend(matchers)
|
|
9
|
+
|
|
10
|
+
// Needed for globals
|
|
11
|
+
window.URL.createObjectURL = function () {}
|
|
12
|
+
|
|
13
|
+
// needed to get past watchMedia error.
|
|
14
|
+
// https://github.com/vitest-dev/vitest/issues/821
|
|
15
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
16
|
+
writable: true,
|
|
17
|
+
value: vi.fn().mockImplementation(query => ({
|
|
18
|
+
matches: false,
|
|
19
|
+
media: query,
|
|
20
|
+
onchange: null,
|
|
21
|
+
addListener: vi.fn(), // deprecated
|
|
22
|
+
removeListener: vi.fn(), // deprecated
|
|
23
|
+
addEventListener: vi.fn(),
|
|
24
|
+
removeEventListener: vi.fn(),
|
|
25
|
+
dispatchEvent: vi.fn()
|
|
26
|
+
}))
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// runs a cleanup after each test case (e.g. clearing jsdom)
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
cleanup()
|
|
32
|
+
})
|
package/types/MarkupInclude.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Runtime } from '@cdc/core/types/Runtime'
|
|
2
2
|
import { Variable } from '@cdc/markup-include/src/types/Variable'
|
|
3
3
|
import { Visualization } from './Visualization'
|
|
4
|
+
import { VizFilter } from './VizFilter'
|
|
4
5
|
|
|
5
6
|
export type MarkupIncludeConfig = Visualization & {
|
|
6
7
|
contentEditor: {
|
|
7
8
|
// Changing the base config object creates an infinite loop, nesting it is a workaround
|
|
8
9
|
allowHideSection?: boolean
|
|
9
10
|
inlineHTML: string
|
|
10
|
-
markupVariables
|
|
11
|
+
markupVariables?: Variable[]
|
|
11
12
|
showHeader: boolean
|
|
13
|
+
showNoDataMessage?: boolean
|
|
14
|
+
noDataMessageText?: string
|
|
12
15
|
srcUrl: string
|
|
13
16
|
title: string
|
|
14
17
|
useInlineHTML: boolean
|
|
15
18
|
}
|
|
16
19
|
data?: Object[]
|
|
20
|
+
filters?: VizFilter[]
|
|
17
21
|
formattedData: {}
|
|
22
|
+
markupVariables?: Variable[] // Support markupVariables at root level for backwards compatibility
|
|
18
23
|
newViz?: boolean
|
|
19
24
|
runtime?: Runtime
|
|
20
25
|
visual: {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type MarkupCondition = {
|
|
2
|
+
columnName: string
|
|
3
|
+
isOrIsNotEqualTo: 'is' | 'is not'
|
|
4
|
+
value: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type MarkupVariable = {
|
|
8
|
+
columnName: string
|
|
9
|
+
conditions: MarkupCondition[]
|
|
10
|
+
name: string
|
|
11
|
+
tag: string
|
|
12
|
+
addCommas?: boolean
|
|
13
|
+
hideOnNull?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type MarkupConfig = {
|
|
17
|
+
markupVariables?: MarkupVariable[]
|
|
18
|
+
enableMarkupVariables?: boolean
|
|
19
|
+
}
|
package/types/VizFilter.ts
CHANGED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: 'jsdom',
|
|
6
|
+
globals: true,
|
|
7
|
+
setupFiles: ['../../vitest.setup.ts'],
|
|
8
|
+
exclude: [
|
|
9
|
+
'**/node_modules/**',
|
|
10
|
+
'**/dist/**',
|
|
11
|
+
'**/.storybook/**',
|
|
12
|
+
'**/*.stories.*',
|
|
13
|
+
'**/storybook-static/**'
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
})
|