@nurvus/ui 0.1.0-alpha.1 → 0.1.0-alpha.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/LICENSE +1 -1
- package/README.md +22 -9
- package/dist/index.js +2 -6
- package/dist/index.js.LICENSE.txt +5 -0
- package/package.json +26 -16
- package/src/components/Button/Button.jsx +7 -9
- package/src/components/Button/Button.md +0 -4
- package/src/components/Button/Button.scss +10 -10
- package/src/components/ButtonGroup/ButtonGroup.jsx +16 -5
- package/src/components/FullPageModal/FullPageModal.jsx +7 -9
- package/src/components/HistoryList/HistoryList.jsx +120 -0
- package/src/components/HistoryList/HistoryList.md +30 -0
- package/src/components/HistoryList/HistoryList.scss +89 -0
- package/src/components/Layout/Layout.jsx +50 -12
- package/src/components/Layout/Layout.scss +12 -0
- package/src/components/Menu/Menu.jsx +15 -4
- package/src/components/Menu/Menu.scss +47 -15
- package/src/components/Panel/Panel.jsx +57 -0
- package/src/components/Panel/Panel.md +23 -0
- package/src/components/Panel/Panel.scss +33 -0
- package/src/components/Progress/Progress.jsx +9 -11
- package/src/components/Progress/Progress.scss +6 -6
- package/src/components/Table/Table.jsx +4 -2
- package/src/components/Table/Table.scss +23 -49
- package/src/components/Tag/Tag.jsx +41 -0
- package/src/components/Tag/Tag.md +13 -0
- package/src/components/Tag/Tag.scss +23 -0
- package/src/components/Text/Text.jsx +48 -18
- package/src/components/Text/Text.md +13 -0
- package/src/components/Text/Text.scss +22 -0
- package/src/components/Title/Title.jsx +38 -41
- package/src/components/Title/Title.scss +3 -2
- package/src/index.js +9 -0
- package/src/styles/theme.scss +497 -0
- package/src/styles/tokens.scss +244 -459
- package/src/styles/type.json +13 -0
- package/src/theme.js +48 -0
- package/src/themes/apollo-white.json +52 -0
- package/src/themes/arcane.json +52 -0
- package/src/themes/dopamine.json +52 -0
- package/src/themes/index.js +22 -0
- package/src/themes/nether-neon.json +52 -0
- package/src/themes/nether.json +52 -0
- package/src/themes/outworld.json +52 -0
- package/src/themes/roles.json +29 -0
- package/src/themes/tokyo-neon.json +52 -0
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
// Type
|
|
11
11
|
&[data-type="primary"] {
|
|
12
|
-
background-color:
|
|
13
|
-
color:
|
|
12
|
+
background-color: var(--nv-accent-fill);
|
|
13
|
+
color: var(--nv-on-accent);
|
|
14
14
|
|
|
15
15
|
&:hover {
|
|
16
|
-
background-color:
|
|
16
|
+
background-color: color-mix(in srgb, var(--nv-accent-fill) 86%, var(--nv-text));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
&:active {
|
|
20
|
-
background-color:
|
|
20
|
+
background-color: color-mix(in srgb, var(--nv-accent-fill) 74%, var(--nv-text));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
&:disabled {
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
// Disable event styles
|
|
28
28
|
&:hover,
|
|
29
29
|
&:active {
|
|
30
|
-
background:
|
|
30
|
+
background: var(--nv-accent-fill);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&[data-type="secondary"] {
|
|
36
|
-
background-color:
|
|
37
|
-
color:
|
|
36
|
+
background-color: color-mix(in srgb, var(--nv-text) 8%, transparent);
|
|
37
|
+
color: var(--nv-text);
|
|
38
38
|
|
|
39
39
|
&:hover {
|
|
40
|
-
background-color:
|
|
40
|
+
background-color: color-mix(in srgb, var(--nv-text) 14%, transparent);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
&:active {
|
|
44
|
-
background-color:
|
|
44
|
+
background-color: color-mix(in srgb, var(--nv-text) 20%, transparent);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&:disabled {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
// Disable event styles
|
|
52
52
|
&:hover,
|
|
53
53
|
&:active {
|
|
54
|
-
background:
|
|
54
|
+
background: color-mix(in srgb, var(--nv-text) 8%, transparent);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import CONSTANT from '../../constants.js';
|
|
4
5
|
import './ButtonGroup.scss';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Joins Buttons into one row: square corners where they meet, rounded at the
|
|
9
|
+
* two outer ends. Any other prop goes on the wrapping `<div>`.
|
|
9
10
|
*/
|
|
10
|
-
export default function ButtonGroup(
|
|
11
|
-
const { className, ...restProps } = props;
|
|
11
|
+
export default function ButtonGroup({ className, ...restProps }) {
|
|
12
12
|
return (
|
|
13
13
|
<div
|
|
14
14
|
className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'button-group', className) }
|
|
15
15
|
{ ...restProps } />
|
|
16
16
|
);
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ButtonGroup.propTypes = {
|
|
20
|
+
/**
|
|
21
|
+
* The Buttons to join.
|
|
22
|
+
*/
|
|
23
|
+
children: PropTypes.node,
|
|
24
|
+
/**
|
|
25
|
+
* Custom class name.
|
|
26
|
+
*/
|
|
27
|
+
className: PropTypes.string
|
|
28
|
+
};
|
|
@@ -9,15 +9,13 @@ import './FullPageModal.scss';
|
|
|
9
9
|
/**
|
|
10
10
|
* The FullPageModal shows additonal content overlayed on the screen.
|
|
11
11
|
*/
|
|
12
|
-
function FullPageModal(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = props;
|
|
20
|
-
|
|
12
|
+
function FullPageModal({
|
|
13
|
+
children,
|
|
14
|
+
headerActions,
|
|
15
|
+
title,
|
|
16
|
+
visible = false,
|
|
17
|
+
...restProps
|
|
18
|
+
}) {
|
|
21
19
|
function getAnimationState() {
|
|
22
20
|
if (visible) {
|
|
23
21
|
return 'reveal-in';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import CONSTANT from '../../constants.js';
|
|
5
|
+
import './HistoryList.scss';
|
|
6
|
+
|
|
7
|
+
const defaultFormatTime = (time) => new Date(time).toLocaleTimeString([], {
|
|
8
|
+
hour: '2-digit',
|
|
9
|
+
minute: '2-digit',
|
|
10
|
+
second: '2-digit'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Undo history as a list (Photoshop's History panel): every step newest
|
|
15
|
+
* first with its number, what it did and when, the current step marked, the
|
|
16
|
+
* undone steps faded above it, and a "start" row at the bottom. Clicking any
|
|
17
|
+
* row jumps to that step.
|
|
18
|
+
*
|
|
19
|
+
* Purely presentational: the app owns the history and passes `steps` (oldest
|
|
20
|
+
* first) plus `index`, the number of steps currently applied.
|
|
21
|
+
* @returns {ReactElement} of HistoryList component.
|
|
22
|
+
*/
|
|
23
|
+
export default function HistoryList(props) {
|
|
24
|
+
const {
|
|
25
|
+
className,
|
|
26
|
+
formatTime,
|
|
27
|
+
index,
|
|
28
|
+
onJump,
|
|
29
|
+
startDetail,
|
|
30
|
+
startLabel,
|
|
31
|
+
steps,
|
|
32
|
+
...restProps
|
|
33
|
+
} = props;
|
|
34
|
+
|
|
35
|
+
if (!steps.length) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const renderRow = (number, label, detail, time, key) => {
|
|
40
|
+
const isCurrent = number === index;
|
|
41
|
+
const isFuture = number > index;
|
|
42
|
+
let title = 'Jump to this step (undo to here)';
|
|
43
|
+
if (isCurrent) title = 'Current state';
|
|
44
|
+
else if (isFuture) title = 'Jump to this step (redo to here)';
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<li key={ key }>
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
className="history-list-item"
|
|
51
|
+
data-current={ isCurrent }
|
|
52
|
+
data-future={ isFuture }
|
|
53
|
+
aria-current={ isCurrent ? 'step' : undefined }
|
|
54
|
+
title={ title }
|
|
55
|
+
onClick={ () => onJump && onJump(number) }
|
|
56
|
+
>
|
|
57
|
+
<span className="history-list-index">{ number }</span>
|
|
58
|
+
<span className="history-list-text">
|
|
59
|
+
<span className="history-list-label">{ label }</span>
|
|
60
|
+
{ detail ? <span className="history-list-detail">{ detail }</span> : null }
|
|
61
|
+
</span>
|
|
62
|
+
{ time ? <span className="history-list-time">{ formatTime(time) }</span> : null }
|
|
63
|
+
</button>
|
|
64
|
+
</li>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const rows = steps.map((step, i) => ({ step, number: i + 1 })).reverse();
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<ol
|
|
72
|
+
className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'history-list', className) }
|
|
73
|
+
aria-label="History, newest first"
|
|
74
|
+
{ ...restProps }
|
|
75
|
+
>
|
|
76
|
+
{ rows.map(({ step, number }) => renderRow(number, step.label, step.detail, step.time, step.id)) }
|
|
77
|
+
{ renderRow(0, startLabel, startDetail, null, '__start__') }
|
|
78
|
+
</ol>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
HistoryList.propTypes = {
|
|
83
|
+
/**
|
|
84
|
+
* Every step, OLDEST first: `{ id, label, detail?, time? }`. `time` is a
|
|
85
|
+
* timestamp in ms.
|
|
86
|
+
*/
|
|
87
|
+
steps: PropTypes.arrayOf(PropTypes.shape({
|
|
88
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
89
|
+
label: PropTypes.node.isRequired,
|
|
90
|
+
detail: PropTypes.node,
|
|
91
|
+
time: PropTypes.number
|
|
92
|
+
})).isRequired,
|
|
93
|
+
/**
|
|
94
|
+
* How many steps are applied: step N (1-based) is current when N === index,
|
|
95
|
+
* and 0 means everything is undone.
|
|
96
|
+
*/
|
|
97
|
+
index: PropTypes.number.isRequired,
|
|
98
|
+
/**
|
|
99
|
+
* Called with the step number to jump to (0 = the start row).
|
|
100
|
+
*/
|
|
101
|
+
onJump: PropTypes.func,
|
|
102
|
+
/**
|
|
103
|
+
* Label of the bottom row, the state before any step.
|
|
104
|
+
*/
|
|
105
|
+
startLabel: PropTypes.node,
|
|
106
|
+
/**
|
|
107
|
+
* Second line of the bottom row.
|
|
108
|
+
*/
|
|
109
|
+
startDetail: PropTypes.node,
|
|
110
|
+
/**
|
|
111
|
+
* Formats a step's `time` for its row. Defaults to the locale time with seconds.
|
|
112
|
+
*/
|
|
113
|
+
formatTime: PropTypes.func
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
HistoryList.defaultProps = {
|
|
117
|
+
startLabel: 'Start',
|
|
118
|
+
startDetail: 'Before any changes',
|
|
119
|
+
formatTime: defaultFormatTime
|
|
120
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Undo history, newest first. Click a row to jump to it: the rows above it fade (undone, one click redoes), and the bottom row returns to the start.
|
|
2
|
+
```jsx
|
|
3
|
+
import { HistoryList } from '@nurvus/ui';
|
|
4
|
+
|
|
5
|
+
const now = Date.now();
|
|
6
|
+
const steps = [
|
|
7
|
+
{ id: 1, label: 'Hide layer', detail: 'triforce', time: now - 9000 },
|
|
8
|
+
{ id: 2, label: 'Delete layer', detail: 'zelda_dark_shadow', time: now - 6000 },
|
|
9
|
+
{ id: 3, label: 'Rename layer', detail: 'cloud', time: now - 3000 },
|
|
10
|
+
{ id: 4, label: 'Edit class', detail: '.me404', time: now }
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const MyApp = () => {
|
|
14
|
+
const [index, setIndex] = React.useState(steps.length);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div style={ { maxWidth: 320 } }>
|
|
18
|
+
<HistoryList steps={ steps } index={ index } onJump={ setIndex } />
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
<MyApp />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Nothing to show yet: with no steps it renders nothing, so the host can show its own empty message.
|
|
26
|
+
```jsx
|
|
27
|
+
import { HistoryList } from '@nurvus/ui';
|
|
28
|
+
|
|
29
|
+
<HistoryList steps={ [] } index={ 0 } />
|
|
30
|
+
```
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@import "../../styles/variables.scss";
|
|
2
|
+
@import "../../styles/tokens.scss";
|
|
3
|
+
|
|
4
|
+
// Role tokens only (--nv-*), so it follows whichever theme is applied. The current step uses the
|
|
5
|
+
// same accent rail + wash language as Menu's active row.
|
|
6
|
+
.#{$cls-prefix}.history-list {
|
|
7
|
+
list-style: none;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: $--space--8;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
|
|
12
|
+
.history-list-item {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: $--space--8;
|
|
16
|
+
width: 100%;
|
|
17
|
+
margin: 0 0 $--space--4;
|
|
18
|
+
padding: $--space--4 $--space--8;
|
|
19
|
+
font: inherit;
|
|
20
|
+
text-align: left;
|
|
21
|
+
color: var(--nv-text);
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: 1px solid transparent;
|
|
24
|
+
border-radius: $--radius--4;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
|
|
27
|
+
&:hover {
|
|
28
|
+
background: var(--nv-accent-soft);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
outline: 2px solid var(--nv-accent);
|
|
33
|
+
outline-offset: 1px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Where you are now.
|
|
37
|
+
&[data-current="true"] {
|
|
38
|
+
border-color: var(--nv-accent);
|
|
39
|
+
background: color-mix(in srgb, var(--nv-accent) 22%, transparent);
|
|
40
|
+
color: var(--nv-text);
|
|
41
|
+
cursor: default;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Undone steps: still listed (one click redoes to them), but faded.
|
|
45
|
+
&[data-future="true"] {
|
|
46
|
+
opacity: 0.45;
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
opacity: 0.75;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.history-list-index {
|
|
55
|
+
flex: 0 0 auto;
|
|
56
|
+
min-width: $--space--24;
|
|
57
|
+
padding: 1px $--space--4;
|
|
58
|
+
text-align: center;
|
|
59
|
+
font-size: 11px;
|
|
60
|
+
color: var(--nv-text-muted);
|
|
61
|
+
border: 1px solid var(--nv-border);
|
|
62
|
+
border-radius: $--radius--4;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.history-list-text {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
min-width: 0;
|
|
69
|
+
flex: 1 1 auto;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.history-list-label,
|
|
73
|
+
.history-list-detail {
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
text-overflow: ellipsis;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.history-list-detail,
|
|
80
|
+
.history-list-time {
|
|
81
|
+
color: var(--nv-text-muted);
|
|
82
|
+
font-size: 11px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.history-list-time {
|
|
86
|
+
flex: 0 0 auto;
|
|
87
|
+
font-variant-numeric: tabular-nums;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import CONSTANT from '../../constants.js';
|
|
4
5
|
import './Layout.scss';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Stacks its children in a column (`block`) or a row (`flex`) with even
|
|
9
|
+
* space between them. Any other prop goes on the wrapping `<div>`.
|
|
10
|
+
*/
|
|
11
|
+
export default function Layout({
|
|
12
|
+
alignItems,
|
|
13
|
+
className,
|
|
14
|
+
display = 'block',
|
|
15
|
+
flexDirection,
|
|
16
|
+
justifyContent,
|
|
17
|
+
itemDisplay,
|
|
18
|
+
itemSpacing = 20,
|
|
19
|
+
...restProps
|
|
20
|
+
}) {
|
|
18
21
|
return (
|
|
19
22
|
<div
|
|
20
23
|
className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'layout', className) }
|
|
@@ -28,3 +31,38 @@ export default function Layout(props) {
|
|
|
28
31
|
/>
|
|
29
32
|
);
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
Layout.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* `block` stacks the children top to bottom; `flex` puts them in a row.
|
|
38
|
+
*/
|
|
39
|
+
display: PropTypes.oneOf(['block', 'flex']),
|
|
40
|
+
/**
|
|
41
|
+
* With `display="flex"`: `column` stacks the children instead of a row.
|
|
42
|
+
*/
|
|
43
|
+
flexDirection: PropTypes.oneOf(['row', 'column']),
|
|
44
|
+
/**
|
|
45
|
+
* Space between the children, in px (0 for none). A flex row takes 0, 10, 20 or 40.
|
|
46
|
+
*/
|
|
47
|
+
itemSpacing: PropTypes.oneOf([0, 10, 13, 20, 30, 40]),
|
|
48
|
+
/**
|
|
49
|
+
* With `display="flex"`: how the children line up across the row (CSS `align-items`).
|
|
50
|
+
*/
|
|
51
|
+
alignItems: PropTypes.oneOf(['flex-start', 'center', 'flex-end']),
|
|
52
|
+
/**
|
|
53
|
+
* With `display="flex"`: how the children spread along the row (CSS `justify-content`).
|
|
54
|
+
*/
|
|
55
|
+
justifyContent: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'space-between']),
|
|
56
|
+
/**
|
|
57
|
+
* `block` makes every child `display: block` (e.g. links stacked one per line).
|
|
58
|
+
*/
|
|
59
|
+
itemDisplay: PropTypes.oneOf(['block']),
|
|
60
|
+
/**
|
|
61
|
+
* Custom class name.
|
|
62
|
+
*/
|
|
63
|
+
className: PropTypes.string,
|
|
64
|
+
/**
|
|
65
|
+
* What to lay out.
|
|
66
|
+
*/
|
|
67
|
+
children: PropTypes.node
|
|
68
|
+
};
|
|
@@ -75,6 +75,18 @@
|
|
|
75
75
|
align-items: flex-end;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
&[data-justify-content="flex-start"] {
|
|
79
|
+
justify-content: flex-start;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&[data-justify-content="center"] {
|
|
83
|
+
justify-content: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&[data-justify-content="flex-end"] {
|
|
87
|
+
justify-content: flex-end;
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
&[data-justify-content="space-between"] {
|
|
79
91
|
justify-content: space-between;
|
|
80
92
|
}
|
|
@@ -31,7 +31,9 @@ class Menu extends React.Component {
|
|
|
31
31
|
const isActive = this.isActiveItem(activePath, i);
|
|
32
32
|
const [ first, ...remainingPath ] = activePath;
|
|
33
33
|
const nextPath = [...path, i];
|
|
34
|
-
|
|
34
|
+
// Clamped so a deep tree cannot indent the label out of a narrow panel.
|
|
35
|
+
// The px maths lives in Menu.scss against spacing tokens; JS only supplies depth.
|
|
36
|
+
const depth = Math.min(path.length, this.props.maxIndentDepth);
|
|
35
37
|
|
|
36
38
|
let itemChildren;
|
|
37
39
|
if (itemRenderer) {
|
|
@@ -48,7 +50,7 @@ class Menu extends React.Component {
|
|
|
48
50
|
data-type={ type }
|
|
49
51
|
onClick={ e => this.handleClick(e, nextPath) }
|
|
50
52
|
style={ {
|
|
51
|
-
|
|
53
|
+
'--nurvus-menu-depth': String(depth),
|
|
52
54
|
...style
|
|
53
55
|
} }
|
|
54
56
|
>
|
|
@@ -66,7 +68,7 @@ class Menu extends React.Component {
|
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
render() {
|
|
69
|
-
const { activePath, className, children, itemRenderer, items, ...props } = this.props;
|
|
71
|
+
const { activePath, className, children, itemRenderer, items, maxIndentDepth, ...props } = this.props;
|
|
70
72
|
|
|
71
73
|
return (
|
|
72
74
|
<div
|
|
@@ -103,7 +105,16 @@ Menu.propTypes = {
|
|
|
103
105
|
* @param {object} event - object
|
|
104
106
|
* @param {array} activePath - of clicked menu item.
|
|
105
107
|
*/
|
|
106
|
-
onClick: PropTypes.func
|
|
108
|
+
onClick: PropTypes.func,
|
|
109
|
+
/**
|
|
110
|
+
* Maximum nesting depth that still adds indentation. Deeper rows render at the
|
|
111
|
+
* max indent so the label keeps its room in a narrow panel.
|
|
112
|
+
*/
|
|
113
|
+
maxIndentDepth: PropTypes.number
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Menu.defaultProps = {
|
|
117
|
+
maxIndentDepth: 6
|
|
107
118
|
};
|
|
108
119
|
|
|
109
120
|
export default Menu;
|
|
@@ -1,36 +1,68 @@
|
|
|
1
1
|
@import "../../styles/variables.scss";
|
|
2
|
+
@import "../../styles/tokens.scss";
|
|
2
3
|
|
|
3
4
|
.#{$cls-prefix}.menu {
|
|
4
|
-
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Indentation is token-driven, not a magic number in JS.
|
|
7
|
+
// Rows are FLAT siblings in the DOM (see Menu.jsx) — nesting is purely visual,
|
|
8
|
+
// produced by padding-left. Menu.jsx stamps `--nurvus-menu-depth` per row and
|
|
9
|
+
// clamps it with the `maxIndentDepth` prop, so a deep tree can never indent
|
|
10
|
+
// the label out of a narrow panel.
|
|
11
|
+
// Consumers retune the whole tree by overriding these two on .nurvus.menu.
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
--nurvus-menu-indent-base: #{$--space--8};
|
|
14
|
+
--nurvus-menu-indent-step: #{$--space--12};
|
|
15
|
+
|
|
16
|
+
background: var(--nv-bg);
|
|
17
|
+
color: var(--nv-text);
|
|
18
|
+
padding: $--space--4;
|
|
19
|
+
|
|
20
|
+
// Allow the menu to shrink inside a flex/grid parent instead of forcing its
|
|
21
|
+
// intrinsic width and pushing the row content out.
|
|
22
|
+
min-width: 0;
|
|
5
23
|
|
|
6
24
|
.menu-item {
|
|
7
25
|
position: relative;
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
min-width: 0; // ...and let row content ellipsis rather than collapse to 0
|
|
27
|
+
padding: $--space--8 $--space--12;
|
|
28
|
+
padding-left: calc(
|
|
29
|
+
var(--nurvus-menu-indent-base) +
|
|
30
|
+
var(--nurvus-menu-depth, 0) * var(--nurvus-menu-indent-step)
|
|
31
|
+
);
|
|
32
|
+
border-radius: $--radius--4;
|
|
33
|
+
color: var(--nv-text);
|
|
10
34
|
cursor: pointer;
|
|
11
35
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
color: white;
|
|
36
|
+
&:hover {
|
|
37
|
+
background: var(--nv-surface-hover);
|
|
38
|
+
color: var(--nv-text);
|
|
16
39
|
}
|
|
17
40
|
|
|
41
|
+
// Active row: 2px accent rail + a tinted wash, both from the theme's
|
|
42
|
+
// accent, so every theme keeps the same "you are here" language.
|
|
18
43
|
&[data-active="true"] {
|
|
44
|
+
background: var(--nv-accent-soft);
|
|
45
|
+
color: var(--nv-text);
|
|
46
|
+
|
|
19
47
|
&::before {
|
|
20
48
|
content: '';
|
|
21
|
-
height: 100%;
|
|
22
|
-
width: 2px;
|
|
23
49
|
position: absolute;
|
|
24
50
|
left: 0;
|
|
25
51
|
top: 0;
|
|
26
|
-
|
|
52
|
+
height: 100%;
|
|
53
|
+
width: $--space--2;
|
|
54
|
+
border-radius: $--radius--2;
|
|
55
|
+
background: var(--nv-accent);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
background: color-mix(in srgb, var(--nv-accent) 22%, transparent);
|
|
27
60
|
}
|
|
28
|
-
// border-left: 2px solid #48c3f4;
|
|
29
|
-
background: linear-gradient(90deg, rgba(72,195,244, 0.5) 0%, rgba(64,57,96,1) 100%);
|
|
30
61
|
}
|
|
31
62
|
|
|
32
|
-
|
|
33
|
-
|
|
63
|
+
// Nested groups read one step quieter than leaf rows.
|
|
64
|
+
&[data-type="group"] {
|
|
65
|
+
color: var(--nv-text-muted);
|
|
34
66
|
}
|
|
35
67
|
}
|
|
36
|
-
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import CONSTANT from '../../constants.js';
|
|
5
|
+
import './Panel.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A card: the theme's surface, a hairline border and 12px corners, with an
|
|
9
|
+
* optional title and a caption footer. Use it to group related content.
|
|
10
|
+
*/
|
|
11
|
+
export default function Panel({
|
|
12
|
+
title,
|
|
13
|
+
caption,
|
|
14
|
+
padding = 'medium',
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
...restProps
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<section
|
|
21
|
+
className={ classNames(`${CONSTANT.CLASS_PREFIX}`, 'panel', className) }
|
|
22
|
+
data-padding={ padding }
|
|
23
|
+
{ ...restProps }
|
|
24
|
+
>
|
|
25
|
+
{ (title || children) && (
|
|
26
|
+
<div className="panel-body">
|
|
27
|
+
{ title && <h3 className="panel-title">{ title }</h3> }
|
|
28
|
+
{ children }
|
|
29
|
+
</div>
|
|
30
|
+
) }
|
|
31
|
+
{ caption && <div className="panel-caption">{ caption }</div> }
|
|
32
|
+
</section>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Panel.propTypes = {
|
|
37
|
+
/**
|
|
38
|
+
* Heading at the top of the panel.
|
|
39
|
+
*/
|
|
40
|
+
title: PropTypes.node,
|
|
41
|
+
/**
|
|
42
|
+
* Footer line under a hairline, in caption type.
|
|
43
|
+
*/
|
|
44
|
+
caption: PropTypes.node,
|
|
45
|
+
/**
|
|
46
|
+
* Inner spacing: none (e.g. a full-bleed image), small (12px) or medium (16px).
|
|
47
|
+
*/
|
|
48
|
+
padding: PropTypes.oneOf(['none', 'small', 'medium']),
|
|
49
|
+
/**
|
|
50
|
+
* Custom class name.
|
|
51
|
+
*/
|
|
52
|
+
className: PropTypes.string,
|
|
53
|
+
/**
|
|
54
|
+
* The panel's content.
|
|
55
|
+
*/
|
|
56
|
+
children: PropTypes.node
|
|
57
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Give it a `title`, a `caption` footer, or both.
|
|
2
|
+
```jsx
|
|
3
|
+
import { Panel, Tag, Text } from '@nurvus/ui';
|
|
4
|
+
|
|
5
|
+
<div style={ { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(240px, 1fr))', gap: 16 } }>
|
|
6
|
+
<Panel title="Deploys" caption="Updated 2 minutes ago">
|
|
7
|
+
<Text variant="display">128</Text>
|
|
8
|
+
<Text as="p" variant="caption" tone="muted">this week, up 12%</Text>
|
|
9
|
+
</Panel>
|
|
10
|
+
<Panel title="Status" caption={ <Tag tone="success">All systems normal</Tag> }>
|
|
11
|
+
<Text as="p" variant="body">Every service answered in under 200 ms.</Text>
|
|
12
|
+
</Panel>
|
|
13
|
+
</div>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
With `padding="none"`, content runs to the edges, for an image or a table.
|
|
17
|
+
```jsx
|
|
18
|
+
import { Panel } from '@nurvus/ui';
|
|
19
|
+
|
|
20
|
+
<Panel padding="none" caption="Full-bleed content, then a caption" style={ { maxWidth: 360 } }>
|
|
21
|
+
<div style={ { height: 120, background: 'linear-gradient(135deg, var(--nv-accent-fill), var(--nv-syntax-tag))' } } />
|
|
22
|
+
</Panel>
|
|
23
|
+
```
|