@cdc/markup-include 4.24.4 → 4.24.5
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/dist/cdcmarkupinclude.js +8652 -8437
- package/index.html +3 -5
- package/package.json +3 -3
- package/src/CdcMarkupInclude.tsx +79 -65
- package/src/ConfigContext.ts +16 -0
- package/src/_stories/MarkupInclude.stories.tsx +44 -5
- package/src/_stories/_mock/button-and-text.json +69 -0
- package/{examples/test.json → src/_stories/_mock/icon-no-text.json} +32 -34
- package/src/_stories/_mock/image-with-text.json +59 -0
- package/src/_stories/_mock/no-conditions.json +61 -0
- package/src/_stories/_mock/primary.json +23 -0
- package/src/_stories/_mock/with-conditions.json +49 -0
- package/src/cdcMarkupInclude.style.css +39 -0
- package/src/components/Conditions.tsx +99 -0
- package/src/components/EditorPanel.tsx +201 -0
- package/src/components/Variables.tsx +171 -0
- package/src/components/editorPanel.style.css +17 -0
- package/src/data/initial-state.js +13 -4
- package/src/scss/main.scss +0 -1
- package/src/store/{mi.actions.ts → markupInclude.actions.ts} +2 -2
- package/src/store/{mi.reducer.ts → markupInclude.reducer.ts} +3 -3
- package/src/types/Condition.ts +5 -0
- package/src/types/Config.ts +18 -6
- package/src/types/Variable.ts +7 -0
- package/examples/example-config.json +0 -11
- package/examples/gallery/button-and-text.json +0 -31
- package/examples/gallery/icon-no-text.json +0 -31
- package/examples/gallery/image-with-text.json +0 -31
- package/src/ConfigContext.jsx +0 -5
- package/src/components/EditorPanel.jsx +0 -159
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "",
|
|
3
|
-
"showHeader": false,
|
|
4
|
-
"type": "markup-include",
|
|
5
|
-
"srcUrl": "https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/Markup-Include-Button-and-Text.html",
|
|
6
|
-
"theme": "theme-blue",
|
|
7
|
-
"data": [
|
|
8
|
-
{
|
|
9
|
-
"Race": "Hispanic or Latino",
|
|
10
|
-
"Age-adjusted rate": "644.2"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"Race": "Non-Hispanic American Indian",
|
|
14
|
-
"Age-adjusted rate": "636.1"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"Race": "Non-Hispanic Black",
|
|
18
|
-
"Age-adjusted rate": "563.7"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"Race": "Non-Hispanic Asian or Pacific Islander",
|
|
22
|
-
"Age-adjusted rate": "202.5"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"Race": "Non-Hispanic White",
|
|
26
|
-
"Age-adjusted rate": "183.6"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"dataFileName": "valid-data-chart.csv",
|
|
30
|
-
"dataFileSourceType": "file"
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "",
|
|
3
|
-
"showHeader": false,
|
|
4
|
-
"type": "markup-include",
|
|
5
|
-
"srcUrl": "https://www.cdc.gov/wcms/4.0/cdc-wp/data-presentation/examples/SSI-Example-Markup-Include.html",
|
|
6
|
-
"theme": "theme-blue",
|
|
7
|
-
"data": [
|
|
8
|
-
{
|
|
9
|
-
"Race": "Hispanic or Latino",
|
|
10
|
-
"Age-adjusted rate": "644.2"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"Race": "Non-Hispanic American Indian",
|
|
14
|
-
"Age-adjusted rate": "636.1"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"Race": "Non-Hispanic Black",
|
|
18
|
-
"Age-adjusted rate": "563.7"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"Race": "Non-Hispanic Asian or Pacific Islander",
|
|
22
|
-
"Age-adjusted rate": "202.5"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"Race": "Non-Hispanic White",
|
|
26
|
-
"Age-adjusted rate": "183.6"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"dataFileName": "valid-data-chart.csv",
|
|
30
|
-
"dataFileSourceType": "file"
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "<strong>Markup Include</strong> - Image with Text",
|
|
3
|
-
"showHeader": false,
|
|
4
|
-
"type": "markup-include",
|
|
5
|
-
"srcUrl": "/wcms/4.0/cdc-wp/data-presentation/examples/SSI-Image-With-Text.html",
|
|
6
|
-
"theme": "theme-slate",
|
|
7
|
-
"data": [
|
|
8
|
-
{
|
|
9
|
-
"Race": "Hispanic or Latino",
|
|
10
|
-
"Age-adjusted rate": "644.2"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"Race": "Non-Hispanic American Indian",
|
|
14
|
-
"Age-adjusted rate": "636.1"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"Race": "Non-Hispanic Black",
|
|
18
|
-
"Age-adjusted rate": "563.7"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"Race": "Non-Hispanic Asian or Pacific Islander",
|
|
22
|
-
"Age-adjusted rate": "202.5"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"Race": "Non-Hispanic White",
|
|
26
|
-
"Age-adjusted rate": "183.6"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"dataFileName": "valid-data-chart.csv",
|
|
30
|
-
"dataFileSourceType": "file"
|
|
31
|
-
}
|
package/src/ConfigContext.jsx
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, memo, useContext } from 'react'
|
|
2
|
-
|
|
3
|
-
import ErrorBoundary from '@cdc/core/components/ErrorBoundary'
|
|
4
|
-
|
|
5
|
-
import ConfigContext from '../ConfigContext'
|
|
6
|
-
|
|
7
|
-
import Accordion from '@cdc/core/components/ui/Accordion'
|
|
8
|
-
import InputText from '@cdc/core/components/inputs/InputText'
|
|
9
|
-
import { updateFieldFactory } from '@cdc/core/helpers/updateFieldFactory'
|
|
10
|
-
import Layout from '@cdc/core/components/Layout'
|
|
11
|
-
import '@cdc/core/styles/v2/components/editor.scss'
|
|
12
|
-
|
|
13
|
-
const headerColors = ['theme-blue', 'theme-purple', 'theme-brown', 'theme-teal', 'theme-pink', 'theme-orange', 'theme-slate', 'theme-indigo', 'theme-cyan', 'theme-green', 'theme-amber']
|
|
14
|
-
|
|
15
|
-
const EditorPanel = memo(props => {
|
|
16
|
-
const { config, updateConfig, loading, data, setParentConfig, isDashboard, showConfigConfirm } = useContext(ConfigContext)
|
|
17
|
-
|
|
18
|
-
const [displayPanel, setDisplayPanel] = useState(true)
|
|
19
|
-
|
|
20
|
-
const updateField = updateFieldFactory(config, updateConfig, true)
|
|
21
|
-
|
|
22
|
-
const missingRequiredSections = () => {
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
// Pass up to Editor if needed
|
|
28
|
-
if (setParentConfig) {
|
|
29
|
-
const newConfig = convertStateToConfig()
|
|
30
|
-
|
|
31
|
-
setParentConfig(newConfig)
|
|
32
|
-
}
|
|
33
|
-
}, [config])
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (!showConfigConfirm) {
|
|
37
|
-
let newConfig = { ...config }
|
|
38
|
-
delete newConfig.newViz
|
|
39
|
-
updateConfig(newConfig)
|
|
40
|
-
}
|
|
41
|
-
}, [])
|
|
42
|
-
|
|
43
|
-
const onBackClick = () => {
|
|
44
|
-
setDisplayPanel(!displayPanel)
|
|
45
|
-
updateConfig({
|
|
46
|
-
...config,
|
|
47
|
-
showEditorPanel: !displayPanel
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
// if (isDashboard) {
|
|
51
|
-
// updateConfig({ ...config, editing: false })
|
|
52
|
-
// } else {
|
|
53
|
-
// setDisplayPanel(!displayPanel)
|
|
54
|
-
// }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const Error = () => {
|
|
58
|
-
return (
|
|
59
|
-
<section className='waiting'>
|
|
60
|
-
<section className='waiting-container'>
|
|
61
|
-
<h3>Error With Configuration</h3>
|
|
62
|
-
<p>{config.runtime.editorErrorMessage}</p>
|
|
63
|
-
</section>
|
|
64
|
-
</section>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const Confirm = () => {
|
|
69
|
-
const confirmDone = e => {
|
|
70
|
-
e.preventDefault()
|
|
71
|
-
let newConfig = { ...config }
|
|
72
|
-
delete newConfig.newViz
|
|
73
|
-
updateConfig(newConfig)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<section className='waiting'>
|
|
78
|
-
<section className='waiting-container'>
|
|
79
|
-
<h3>Finish Configuring</h3>
|
|
80
|
-
<p>Set all required options to the left and confirm below to display a preview of the markup.</p>
|
|
81
|
-
<button className='btn' style={{ margin: '1em auto' }} onClick={confirmDone}>
|
|
82
|
-
I'm Done
|
|
83
|
-
</button>
|
|
84
|
-
</section>
|
|
85
|
-
</section>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const convertStateToConfig = () => {
|
|
90
|
-
let strippedState = JSON.parse(JSON.stringify(config))
|
|
91
|
-
delete strippedState.newViz
|
|
92
|
-
delete strippedState.runtime
|
|
93
|
-
|
|
94
|
-
return strippedState
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const CheckBox = memo(({ label, value, fieldName, section = null, subsection = null, tooltip, updateField, ...attributes }) => (
|
|
98
|
-
<label className='checkbox'>
|
|
99
|
-
<input
|
|
100
|
-
type='checkbox'
|
|
101
|
-
name={fieldName}
|
|
102
|
-
checked={value}
|
|
103
|
-
onChange={() => {
|
|
104
|
-
updateField(section, subsection, fieldName, !value)
|
|
105
|
-
}}
|
|
106
|
-
{...attributes}
|
|
107
|
-
/>
|
|
108
|
-
<span className='edit-label column-heading'>{label}</span>
|
|
109
|
-
<span className='cove-icon'>{tooltip}</span>
|
|
110
|
-
</label>
|
|
111
|
-
))
|
|
112
|
-
|
|
113
|
-
const editorContent = (
|
|
114
|
-
<Accordion>
|
|
115
|
-
<Accordion.Section title='General'>
|
|
116
|
-
<InputText value={config.title || ''} fieldName='title' label='Title' placeholder='Markup Include Title' updateField={updateField} />
|
|
117
|
-
|
|
118
|
-
<InputText value={config.srcUrl || ''} fieldName='srcUrl' label='Source URL' placeholder='https://www.example.com/file.html' updateField={updateField} />
|
|
119
|
-
</Accordion.Section>
|
|
120
|
-
<Accordion.Section title='Visual'>
|
|
121
|
-
<div className='input-group'>
|
|
122
|
-
<label>Theme</label>
|
|
123
|
-
<ul className='color-palette'>
|
|
124
|
-
{headerColors.map(palette => (
|
|
125
|
-
<li
|
|
126
|
-
title={palette}
|
|
127
|
-
key={palette}
|
|
128
|
-
onClick={() => {
|
|
129
|
-
updateConfig({ ...config, theme: palette })
|
|
130
|
-
}}
|
|
131
|
-
className={config.theme === palette ? 'selected ' + palette : palette}
|
|
132
|
-
></li>
|
|
133
|
-
))}
|
|
134
|
-
</ul>
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
<div className='cove-accordion__panel-section checkbox-group'>
|
|
138
|
-
<CheckBox value={config.visual.border} section='visual' fieldName='border' label='Display Border' updateField={updateField} />
|
|
139
|
-
<CheckBox value={config.visual.borderColorTheme} section='visual' fieldName='borderColorTheme' label='Use Border Color Theme' updateField={updateField} />
|
|
140
|
-
<CheckBox value={config.visual.accent} section='visual' fieldName='accent' label='Use Accent Style' updateField={updateField} />
|
|
141
|
-
<CheckBox value={config.visual.background} section='visual' fieldName='background' label='Use Theme Background Color' updateField={updateField} />
|
|
142
|
-
<CheckBox value={config.visual.hideBackgroundColor} section='visual' fieldName='hideBackgroundColor' label='Hide Background Color' updateField={updateField} />
|
|
143
|
-
</div>
|
|
144
|
-
</Accordion.Section>
|
|
145
|
-
</Accordion>
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
if (loading) return null
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<ErrorBoundary component='EditorPanel'>
|
|
152
|
-
<Layout.Sidebar displayPanel={displayPanel} onBackClick={onBackClick} isDashboard={isDashboard} title='Configure Markup Include'>
|
|
153
|
-
{editorContent}
|
|
154
|
-
</Layout.Sidebar>
|
|
155
|
-
</ErrorBoundary>
|
|
156
|
-
)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
export default EditorPanel
|