qpp-style 2.0.2-sm.1 → 2.0.2-sm.2
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/Details/Details.stories.js +63 -0
- package/components/Details/DetailsIcons.js +50 -0
- package/components/Details/index.js +3 -6
- package/components/SideNav/Links/NavLinkInline.jsx +2 -4
- package/components/SideNav/UI/SideNavUI.jsx +15 -51
- package/components/SideNav/UI/utils.js +0 -0
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/qppds/components/_details.scss +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Details from './index';
|
|
3
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Details',
|
|
7
|
+
component: Details,
|
|
8
|
+
decorators: [withKnobs],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const DefaultDetails = () => <Details title="default" />;
|
|
12
|
+
|
|
13
|
+
export const HeaderDetails = () => <Details variant="header" title="Header" />;
|
|
14
|
+
|
|
15
|
+
export const TextButtonDetails = () => (
|
|
16
|
+
<Details variant="text-button" title="Text Button" />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const HeaderListDetails = () => (
|
|
20
|
+
<ul className="qpp-c-details-list">
|
|
21
|
+
<li>
|
|
22
|
+
<Details title="Header 1" variant="header">
|
|
23
|
+
<p className="qpp-p1 qpp-u-padding-left--40">
|
|
24
|
+
Aenean lacinia <a href="#">inline link</a> nulla sed{' '}
|
|
25
|
+
<a href="#">inline link</a>. Integer posuere erat a ante venenatis
|
|
26
|
+
dapibus posuere velit aliquet. Integer posuere erat a ante venenatis{' '}
|
|
27
|
+
<a href="#">inline link</a> dapibus posuere velit aliquet.
|
|
28
|
+
</p>
|
|
29
|
+
<hr />
|
|
30
|
+
<p className="qpp-p1 qpp-u-padding-left--40">
|
|
31
|
+
Aenean lacinia <a href="#">inline link</a> nulla sed{' '}
|
|
32
|
+
<a href="#">inline link</a>. Integer posuere erat a ante venenatis
|
|
33
|
+
dapibus posuere velit aliquet. Integer posuere erat a ante venenatis{' '}
|
|
34
|
+
<a href="#">inline link</a> dapibus posuere velit aliquet.
|
|
35
|
+
</p>
|
|
36
|
+
</Details>
|
|
37
|
+
</li>
|
|
38
|
+
<li>
|
|
39
|
+
<Details title="Header 2" variant="header">
|
|
40
|
+
<p className="qpp-p1 qpp-u-padding-left--40">
|
|
41
|
+
Aenean lacinia <a href="#">inline link</a> nulla sed{' '}
|
|
42
|
+
<a href="#">inline link</a>. Integer posuere erat a ante venenatis
|
|
43
|
+
dapibus posuere velit aliquet. Integer posuere erat a ante venenatis{' '}
|
|
44
|
+
<a href="#">inline link</a> dapibus posuere velit aliquet.
|
|
45
|
+
</p>
|
|
46
|
+
<ul>
|
|
47
|
+
<li>foo</li>
|
|
48
|
+
<li>bar</li>
|
|
49
|
+
</ul>
|
|
50
|
+
</Details>
|
|
51
|
+
</li>
|
|
52
|
+
<li>
|
|
53
|
+
<Details title="Header 3" variant="header">
|
|
54
|
+
<p className="qpp-p1 qpp-u-padding-left--40">
|
|
55
|
+
Aenean lacinia <a href="#">inline link</a> nulla sed{' '}
|
|
56
|
+
<a href="#">inline link</a>. Integer posuere erat a ante venenatis
|
|
57
|
+
dapibus posuere velit aliquet. Integer posuere erat a ante venenatis{' '}
|
|
58
|
+
<a href="#">inline link</a> dapibus posuere velit aliquet.
|
|
59
|
+
</p>
|
|
60
|
+
</Details>
|
|
61
|
+
</li>
|
|
62
|
+
</ul>
|
|
63
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
export const Add = ({ iconText }) => (
|
|
5
|
+
<>
|
|
6
|
+
<svg
|
|
7
|
+
className="qpp-c-details--icon-closed qpp-icon-mat qpp-icon-inline--md"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 24 24"
|
|
11
|
+
role="img"
|
|
12
|
+
focusable="false"
|
|
13
|
+
>
|
|
14
|
+
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
15
|
+
</svg>{' '}
|
|
16
|
+
{iconText}
|
|
17
|
+
</>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
Add.propTypes = {
|
|
21
|
+
iconText: PropTypes.string,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
Add.defaultProps = {
|
|
25
|
+
iconText: null,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Remove = ({ iconText }) => (
|
|
29
|
+
<>
|
|
30
|
+
<svg
|
|
31
|
+
className="qpp-c-details--icon-open qpp-icon-mat qpp-icon-inline--md"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
viewBox="0 0 24 24"
|
|
35
|
+
role="img"
|
|
36
|
+
focusable="false"
|
|
37
|
+
>
|
|
38
|
+
<path d="M19 13H5v-2h14v2z" />
|
|
39
|
+
</svg>
|
|
40
|
+
{iconText}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
Remove.propTypes = {
|
|
45
|
+
iconText: PropTypes.string,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Remove.defaultProps = {
|
|
49
|
+
iconText: null,
|
|
50
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Add from '
|
|
4
|
-
import Remove from '@material-design-icons/svg/filled/remove.svg';
|
|
3
|
+
import { Add, Remove } from './DetailsIcons';
|
|
5
4
|
|
|
6
5
|
const Details = ({ children, title, variant, className, ...rest }) => {
|
|
7
6
|
if (variant === 'header') {
|
|
@@ -10,12 +9,10 @@ const Details = ({ children, title, variant, className, ...rest }) => {
|
|
|
10
9
|
<summary>
|
|
11
10
|
{title}
|
|
12
11
|
<span className="qpp-c-details--icon-closed" aria-hidden="true">
|
|
13
|
-
<Add
|
|
14
|
-
<span>View</span>
|
|
12
|
+
<Add iconText="View" />
|
|
15
13
|
</span>
|
|
16
14
|
<span className="qpp-c-details--icon-open" aria-hidden="true">
|
|
17
|
-
<Remove
|
|
18
|
-
<span>Hide</span>
|
|
15
|
+
<Remove iconText="Hide" />
|
|
19
16
|
</span>
|
|
20
17
|
</summary>
|
|
21
18
|
{children}
|
|
@@ -14,7 +14,6 @@ const NavLinkInline = ({
|
|
|
14
14
|
showLabel,
|
|
15
15
|
linkCallback,
|
|
16
16
|
disabled,
|
|
17
|
-
useTooltips,
|
|
18
17
|
target,
|
|
19
18
|
}) => {
|
|
20
19
|
const localUrl = urlExpressionToMatch || url;
|
|
@@ -26,12 +25,12 @@ const NavLinkInline = ({
|
|
|
26
25
|
const tooltipRef = React.useRef();
|
|
27
26
|
|
|
28
27
|
React.useEffect(() => {
|
|
29
|
-
if (!showLabel &&
|
|
28
|
+
if (!showLabel && svgRef.current) {
|
|
30
29
|
const existingMouseenter = svgRef.current.onmouseover;
|
|
31
30
|
const existingMouseout = svgRef.current.onmouseout;
|
|
32
31
|
|
|
33
32
|
svgRef.current.onmouseover = () => {
|
|
34
|
-
if (tooltipRef.current
|
|
33
|
+
if (tooltipRef.current) {
|
|
35
34
|
const svgOffset = svgRef.current.getBoundingClientRect();
|
|
36
35
|
tooltipRef.current.style.top = `${svgOffset.top - 5}px`;
|
|
37
36
|
tooltipRef.current.style.display = 'block';
|
|
@@ -105,7 +104,6 @@ NavLinkInline.propTypes = {
|
|
|
105
104
|
showLabel: PropTypes.bool,
|
|
106
105
|
linkCallback: PropTypes.func,
|
|
107
106
|
disabled: PropTypes.bool,
|
|
108
|
-
useTooltips: PropTypes.bool,
|
|
109
107
|
target: PropTypes.string,
|
|
110
108
|
};
|
|
111
109
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import { withGetConfig } from '../../hooks/useGetConfig';
|
|
5
|
-
import { LevelOneContent
|
|
5
|
+
import { LevelOneContent } from '../Content';
|
|
6
6
|
import {
|
|
7
7
|
NavLinkContainer,
|
|
8
8
|
NavLinkInline,
|
|
@@ -18,21 +18,16 @@ import CmsSwitchLink from '../Links/CmsSwitchLink';
|
|
|
18
18
|
import defaultContent from './default-content';
|
|
19
19
|
|
|
20
20
|
const SideNavUI = ({
|
|
21
|
-
chartData,
|
|
22
21
|
config,
|
|
23
|
-
currentLevel,
|
|
24
22
|
isAltStyle,
|
|
25
23
|
isExpanded,
|
|
26
24
|
items,
|
|
27
25
|
onCollapsed,
|
|
28
26
|
onExpanded,
|
|
29
27
|
performanceYear,
|
|
30
|
-
showReportingLinks,
|
|
31
28
|
result,
|
|
32
29
|
}) => {
|
|
33
30
|
const [isExpandedState, setIsExpandedState] = useState(isExpanded);
|
|
34
|
-
const [itemsState, setItemsState] = useState(items);
|
|
35
|
-
const [currentLevelState, setCurrentLevelState] = useState(currentLevel);
|
|
36
31
|
|
|
37
32
|
const collapseRef = useRef(null);
|
|
38
33
|
|
|
@@ -54,30 +49,8 @@ const SideNavUI = ({
|
|
|
54
49
|
isExpandedState ? collapse() : expand();
|
|
55
50
|
};
|
|
56
51
|
|
|
57
|
-
const getLevelContent = () => {
|
|
58
|
-
return (
|
|
59
|
-
{
|
|
60
|
-
2: (
|
|
61
|
-
<LevelTwoContent
|
|
62
|
-
showReportingLinks={showReportingLinks}
|
|
63
|
-
isExpanded={isExpandedState}
|
|
64
|
-
chartData={chartData}
|
|
65
|
-
config={config}
|
|
66
|
-
/>
|
|
67
|
-
),
|
|
68
|
-
}[currentLevelState] || (
|
|
69
|
-
<LevelOneContent
|
|
70
|
-
levelOneContent={result?.content}
|
|
71
|
-
isExpanded={isExpandedState}
|
|
72
|
-
config={config}
|
|
73
|
-
/>
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
52
|
const getDynamicContent = (contentItems, className, recursionId) => {
|
|
79
|
-
const { openDrawersByDefault, linkActiveFunc, linkCallback
|
|
80
|
-
config;
|
|
53
|
+
const { openDrawersByDefault, linkActiveFunc, linkCallback } = config;
|
|
81
54
|
let linkClass = isExpandedState ? 'link-inline' : 'link-collapsed';
|
|
82
55
|
const containerRecursionId = recursionId || 0;
|
|
83
56
|
|
|
@@ -117,7 +90,6 @@ const SideNavUI = ({
|
|
|
117
90
|
label={item.label}
|
|
118
91
|
linkCallback={linkCallback}
|
|
119
92
|
showLabel={true}
|
|
120
|
-
useTooltips={useTooltips}
|
|
121
93
|
/>
|
|
122
94
|
</AnimationGroup>
|
|
123
95
|
),
|
|
@@ -130,7 +102,6 @@ const SideNavUI = ({
|
|
|
130
102
|
label={item.label}
|
|
131
103
|
linkCallback={linkCallback}
|
|
132
104
|
showLabel={true}
|
|
133
|
-
useTooltips={useTooltips}
|
|
134
105
|
/>
|
|
135
106
|
</AnimationGroup>
|
|
136
107
|
),
|
|
@@ -220,7 +191,6 @@ const SideNavUI = ({
|
|
|
220
191
|
linkCallback={linkCallback}
|
|
221
192
|
showLabel={isExpandedState}
|
|
222
193
|
disabled={item.disabled}
|
|
223
|
-
useTooltips={useTooltips}
|
|
224
194
|
target={item.target}
|
|
225
195
|
/>
|
|
226
196
|
)
|
|
@@ -244,24 +214,18 @@ const SideNavUI = ({
|
|
|
244
214
|
}
|
|
245
215
|
};
|
|
246
216
|
|
|
247
|
-
const content =
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
setCurrentLevelState(currentLevel);
|
|
260
|
-
}, [currentLevel]);
|
|
261
|
-
|
|
262
|
-
useEffect(() => {
|
|
263
|
-
setItemsState(items);
|
|
264
|
-
}, [items]);
|
|
217
|
+
const content = !items?.length ? (
|
|
218
|
+
<LevelOneContent
|
|
219
|
+
levelOneContent={result?.content}
|
|
220
|
+
isExpanded={isExpandedState}
|
|
221
|
+
config={config}
|
|
222
|
+
/>
|
|
223
|
+
) : (
|
|
224
|
+
getDynamicContent(
|
|
225
|
+
items,
|
|
226
|
+
'sidebar-content' + (isAltStyle ? ' alt-style' : '')
|
|
227
|
+
)
|
|
228
|
+
);
|
|
265
229
|
|
|
266
230
|
return (
|
|
267
231
|
<aside
|
|
File without changes
|