@cdc/markup-include 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.
@@ -14,7 +14,8 @@ import Icon from '@cdc/core/components/ui/Icon'
14
14
  import Tooltip from '@cdc/core/components/ui/Tooltip'
15
15
  import MarkupVariablesEditor from '@cdc/core/components/EditorPanel/components/MarkupVariablesEditor'
16
16
  import FootnotesEditor from '@cdc/core/components/EditorPanel/FootnotesEditor'
17
- import { VisualSection } from '@cdc/core/components/EditorPanel/sections/VisualSection'
17
+ import StyleTreatmentSection from '@cdc/core/components/EditorPanel/sections/StyleTreatmentSection'
18
+ import { HeaderThemeSelector } from '@cdc/core/components/HeaderThemeSelector'
18
19
  import { Datasets } from '@cdc/core/types/DataSet'
19
20
 
20
21
  // styles
@@ -26,9 +27,24 @@ type MarkupIncludeEditorPanelProps = {
26
27
 
27
28
  const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
28
29
  const { config, data, isDashboard, loading, setParentConfig, updateConfig } = useContext(ConfigContext)
29
- const { contentEditor, theme, visual } = config
30
+ const { contentEditor, theme, visual } = config || {}
30
31
  const { inlineHTML, srcUrl, title, useInlineHTML } = contentEditor || {}
31
32
  const updateField = updateFieldFactory(config, updateConfig, true)
33
+ const styleTreatment = visual?.tp5Treatment ? 'tp5' : 'legacy'
34
+
35
+ const handleStyleTreatmentChange = (value: string) => {
36
+ const useTp5Treatment = value === 'tp5'
37
+ updateConfig({
38
+ ...config,
39
+ visual: {
40
+ ...config.visual,
41
+ tp5Treatment: useTp5Treatment,
42
+ border: useTp5Treatment ? false : config.visual?.border,
43
+ borderColorTheme: useTp5Treatment ? false : config.visual?.borderColorTheme,
44
+ accent: useTp5Treatment ? false : config.visual?.accent
45
+ }
46
+ })
47
+ }
32
48
 
33
49
  const textAreaInEditorContainer = useRef(null)
34
50
 
@@ -67,7 +83,7 @@ const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
67
83
  updateField={updateField}
68
84
  />
69
85
  <Select
70
- value={contentEditor.titleStyle || 'small'}
86
+ value={contentEditor?.titleStyle || 'small'}
71
87
  section='contentEditor'
72
88
  fieldName='titleStyle'
73
89
  label='Title Style'
@@ -92,6 +108,29 @@ const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
92
108
  </Tooltip>
93
109
  }
94
110
  />
111
+ <Select
112
+ value={config.locale}
113
+ fieldName='locale'
114
+ label='Language for dates and numbers'
115
+ updateField={updateField}
116
+ options={[
117
+ { value: 'en-US', label: 'English (en-US)' },
118
+ { value: 'es-MX', label: 'Spanish (es-MX)' }
119
+ ]}
120
+ tooltip={
121
+ <Tooltip style={{ textTransform: 'none' }}>
122
+ <Tooltip.Target>
123
+ <Icon display='question' style={{ marginLeft: '0.5rem' }} />
124
+ </Tooltip.Target>
125
+ <Tooltip.Content>
126
+ <p>
127
+ Change the language (locale) for this visualization to alter the way dates and numbers are
128
+ formatted.
129
+ </p>
130
+ </Tooltip.Content>
131
+ </Tooltip>
132
+ }
133
+ />
95
134
  </Accordion.Section>
96
135
  <Accordion.Section title='Content Editor'>
97
136
  <span className='divider-heading'>Enter Markup</span>
@@ -131,7 +170,23 @@ const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
131
170
  </div>
132
171
  </Accordion.Section>
133
172
  <Accordion.Section title='Visual'>
134
- <VisualSection config={config} updateField={updateField} updateConfig={updateConfig} />
173
+ <HeaderThemeSelector
174
+ selectedTheme={config.theme}
175
+ onThemeSelect={theme => updateConfig({ ...config, theme })}
176
+ />
177
+ <StyleTreatmentSection
178
+ styleTreatment={styleTreatment}
179
+ onStyleTreatmentChange={handleStyleTreatmentChange}
180
+ showStyleTreatment={false}
181
+ border={config.visual?.border}
182
+ borderColorTheme={config.visual?.borderColorTheme}
183
+ accent={config.visual?.accent}
184
+ background={config.visual?.background}
185
+ hideBackgroundColor={config.visual?.hideBackgroundColor}
186
+ showBackground
187
+ showHideBackgroundColor
188
+ updateField={updateField}
189
+ />
135
190
  </Accordion.Section>
136
191
  {isDashboard && (
137
192
  <Accordion.Section title='Footnotes'>
@@ -147,6 +202,7 @@ const EditorPanel: React.FC<MarkupIncludeEditorPanelProps> = ({ datasets }) => {
147
202
  onChange={handleMarkupVariablesChange}
148
203
  enableMarkupVariables={config.enableMarkupVariables || false}
149
204
  onToggleEnable={handleToggleEnable}
205
+ dataMetadata={config.dataMetadata}
150
206
  />
151
207
  </Accordion.Section>
152
208
  </Accordion>
@@ -1,19 +1,21 @@
1
1
  export default {
2
2
  contentEditor: {
3
- inlineHTML: '<h2>Inline HTML</h2>',
3
+ inlineHTML: '<strong>Inline HTML</strong>',
4
4
  showHeader: true,
5
5
  srcUrl: '#example',
6
6
  title: '',
7
7
  titleStyle: 'small',
8
- useInlineHTML: false,
8
+ useInlineHTML: true,
9
9
  showNoDataMessage: false,
10
10
  noDataMessageText: 'No Data Available'
11
11
  },
12
12
  data: [],
13
13
  legend: {},
14
14
  newViz: true,
15
+ showEditorPanel: true,
15
16
  theme: 'theme-blue',
16
17
  type: 'markup-include',
18
+ visualizationType: 'markup-include',
17
19
  runtime: null,
18
20
  visual: {
19
21
  border: false,
@@ -1,16 +1,12 @@
1
- .markup-include {
2
- .cove-component__content-wrap {
3
- padding: 0;
1
+ @import '@cdc/core/styles/layout/wrapper-padding';
4
2
 
5
- &.has-top-padding {
6
- padding-top: 1rem;
7
- padding-bottom: 1rem;
8
- }
3
+ .cove-visualization.type-markup-include {
4
+ .cove-visualization__body {
5
+ @include cove-visualization-body-padding;
6
+ }
9
7
 
10
- &.has-side-padding {
11
- padding-left: 1rem;
12
- padding-right: 1rem;
13
- }
8
+ .cove-visualization__body-wrap {
9
+ @include cove-visualization-body-wrap-inline-padding;
14
10
 
15
11
  h1,
16
12
  h2,
@@ -22,9 +18,16 @@
22
18
  margin-top: auto;
23
19
  margin-bottom: auto;
24
20
  }
21
+
22
+ // keep markup include images inlines on dashboards
23
+ // e.g. requested to help here: https://www.cdc.gov/fluview/surveillance/2026-week-10.html
24
+ // needed for backwards compatibility with existing dashboards, but also to prevent any future issues with images in markup include visualizations being forced to display as blocks
25
+ span>img {
26
+ display: inline;
27
+ }
25
28
  }
26
29
 
27
- .cove-component__content.component--hideBackgroundColor {
30
+ .cove-visualization__body.component--hide-background-color {
28
31
  background: transparent;
29
32
  }
30
33
 
@@ -47,7 +50,8 @@
47
50
  float: left;
48
51
  }
49
52
  }
53
+
50
54
  .cove-editor .cove-editor__content {
51
55
  padding-left: 350px;
52
56
  display: flex;
53
- }
57
+ }
@@ -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('Markup Include', () => {
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
  })