@nurvus/ui 0.1.0-alpha.14 → 0.1.0-alpha.16
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/README.md +13 -0
- package/dist/icons.svg +73 -0
- package/dist/index.js +1 -1
- package/dist/nurvus.css +14 -10
- package/dist/respawn.js +1 -1
- package/dist/types/breakpoints.d.ts +14 -0
- package/dist/types/components/FullPageModal/FullPageModal.d.ts +11 -2
- package/dist/types/components/Grid/Grid.d.ts +26 -0
- package/dist/types/components/Icon/Icon.d.ts +20 -0
- package/dist/types/components/Loader/Loader.d.ts +21 -0
- package/dist/types/components/Menu/Menu.d.ts +54 -19
- package/dist/types/components/Progress/Progress.d.ts +19 -5
- package/dist/types/components/Stack/Stack.d.ts +26 -0
- package/dist/types/dialog.d.ts +12 -0
- package/dist/types/icons.d.ts +83 -0
- package/dist/types/index.d.ts +13 -1
- package/dist/types/loader.d.ts +28 -0
- package/dist/types/logo.d.ts +5 -0
- package/dist/types/menu.d.ts +43 -14
- package/dist/types/progress.d.ts +11 -0
- package/dist/types/respawn/FullPageModal.d.ts +7 -1
- package/dist/types/respawn/Grid.d.ts +21 -0
- package/dist/types/respawn/Icon.d.ts +22 -0
- package/dist/types/respawn/Loader.d.ts +18 -0
- package/dist/types/respawn/Menu.d.ts +45 -15
- package/dist/types/respawn/Progress.d.ts +18 -6
- package/dist/types/respawn/Stack.d.ts +21 -0
- package/dist/types/respawn/index.d.ts +13 -1
- package/dist/types/respawn/spawn.d.ts +2 -0
- package/package.json +1 -3
- package/src/breakpoints.ts +28 -0
- package/src/components/Button/Button.scss +20 -20
- package/src/components/ButtonGroup/ButtonGroup.md +8 -12
- package/src/components/FullPageModal/FullPageModal.md +20 -17
- package/src/components/FullPageModal/FullPageModal.scss +5 -0
- package/src/components/FullPageModal/FullPageModal.tsx +37 -3
- package/src/components/Grid/Grid.md +37 -0
- package/src/components/Grid/Grid.scss +37 -0
- package/src/components/Grid/Grid.tsx +54 -0
- package/src/components/HistoryList/HistoryList.scss +2 -2
- package/src/components/Icon/Icon.md +22 -0
- package/src/components/Icon/Icon.scss +10 -0
- package/src/components/Icon/Icon.tsx +45 -0
- package/src/components/Layout/Layout.md +10 -18
- package/src/components/Loader/Loader.md +30 -0
- package/src/components/Loader/Loader.scss +42 -0
- package/src/components/Loader/Loader.tsx +68 -0
- package/src/components/Menu/Menu.md +68 -2
- package/src/components/Menu/Menu.scss +48 -18
- package/src/components/Menu/Menu.tsx +146 -39
- package/src/components/Progress/Progress.md +27 -26
- package/src/components/Progress/Progress.scss +41 -36
- package/src/components/Progress/Progress.tsx +50 -6
- package/src/components/Select/Select.scss +20 -19
- package/src/components/Stack/Stack.md +43 -0
- package/src/components/Stack/Stack.scss +36 -0
- package/src/components/Stack/Stack.tsx +52 -0
- package/src/components/Table/Table.scss +1 -1
- package/src/components/Tag/Tag.scss +2 -2
- package/src/components/Text/Text.md +3 -5
- package/src/components/Title/Title.scss +6 -6
- package/src/components/Tree/Tree.md +5 -5
- package/src/css.ts +4 -0
- package/src/dialog.ts +47 -0
- package/src/icons.ts +117 -0
- package/src/index.ts +13 -1
- package/src/loader.ts +43 -0
- package/src/logo.ts +12 -0
- package/src/menu.ts +91 -21
- package/src/progress.ts +21 -0
- package/src/respawn/FullPageModal.ts +30 -3
- package/src/respawn/Grid.ts +41 -0
- package/src/respawn/Icon.ts +47 -0
- package/src/respawn/Loader.ts +77 -0
- package/src/respawn/Menu.ts +138 -34
- package/src/respawn/Progress.ts +56 -13
- package/src/respawn/Stack.ts +37 -0
- package/src/respawn/index.ts +13 -1
- package/src/respawn/spawn.ts +5 -3
- package/src/styles/breakpoints.scss +3 -0
- package/src/styles/theme.scss +55 -55
- package/src/styles/type.json +9 -9
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Icons are 1em by default, so they are as big as the text they sit in, and they take its color. Every icon is in **Foundations → Icons**.
|
|
2
|
+
```jsx
|
|
3
|
+
import { Icon, Layout, Text, Title } from '@nurvus/ui';
|
|
4
|
+
|
|
5
|
+
<Layout itemSpacing={ 12 }>
|
|
6
|
+
<Title level={ 3 }><Icon name="layers" /> Layers</Title>
|
|
7
|
+
<Text as="p" variant="body"><Icon name="info" /> Body text, and its icon is body size.</Text>
|
|
8
|
+
<Text as="p" variant="caption" tone="muted"><Icon name="check" /> A caption, a smaller icon.</Text>
|
|
9
|
+
</Layout>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
In a button: put the icon beside the words. An icon alone needs a `label`, which screen readers read; with words beside it, leave the label out (the icon is decorative).
|
|
13
|
+
```jsx
|
|
14
|
+
import { Button, Icon, Layout } from '@nurvus/ui';
|
|
15
|
+
|
|
16
|
+
<Layout display="flex" alignItems="center" itemSpacing={ 8 }>
|
|
17
|
+
<Button type="primary"><Icon name="add" /> New layer</Button>
|
|
18
|
+
<Button type="secondary"><Icon name="download" /> Export</Button>
|
|
19
|
+
<Button type="secondary" aria-label="Delete layer"><Icon name="delete" /></Button>
|
|
20
|
+
<Icon name="warning" label="Unsaved changes" size={ 24 } style={ { color: 'var(--nv-warning)' } } />
|
|
21
|
+
</Layout>
|
|
22
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@import "../../styles/variables.scss";
|
|
2
|
+
|
|
3
|
+
// Icons sit on the text's baseline like a letter: 1em tall, nudged down an
|
|
4
|
+
// eighth so their middle lines up with the middle of capitals and lowercase.
|
|
5
|
+
.#{$cls-prefix}.icon {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
flex: none;
|
|
8
|
+
vertical-align: -0.125em;
|
|
9
|
+
overflow: visible;
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import CONSTANT from '../../constants';
|
|
4
|
+
import { iconNodes, IconName } from '../../icons';
|
|
5
|
+
import './Icon.scss';
|
|
6
|
+
|
|
7
|
+
export interface IconProps extends Omit<React.SVGAttributes<SVGSVGElement>, 'name'> {
|
|
8
|
+
/** Which icon (Foundations > Icons lists them all). */
|
|
9
|
+
name: IconName;
|
|
10
|
+
/** Width and height. Defaults to 1em: the icon is as big as the text around it. A number is pixels. */
|
|
11
|
+
size?: number | string;
|
|
12
|
+
/** Says what the icon means, for an icon that stands alone (screen readers read it). Leave it out when text beside it already says it. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** Line thickness in grid units (the grid is 24). */
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
/** Custom class name. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* An icon from the NURVUS set: drawn on a 24-unit grid with round 2-unit
|
|
22
|
+
* lines, in the text's color (currentColor), and 1em by default so it matches
|
|
23
|
+
* the text it sits in. Decorative unless you give it a label.
|
|
24
|
+
*/
|
|
25
|
+
export default function Icon({ name, size = '1em', label, strokeWidth = 2, className, ...restProps }: IconProps) {
|
|
26
|
+
const a11y = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true, focusable: 'false' as const };
|
|
27
|
+
return (
|
|
28
|
+
<svg
|
|
29
|
+
className={ classNames(className, 'icon', CONSTANT.CLASS_PREFIX) }
|
|
30
|
+
data-icon={ name }
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
width={ size }
|
|
33
|
+
height={ size }
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="currentColor"
|
|
36
|
+
strokeWidth={ strokeWidth }
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
{ ...a11y }
|
|
40
|
+
{ ...restProps }
|
|
41
|
+
>
|
|
42
|
+
{ iconNodes(name).map(([tag, attrs], i) => React.createElement(tag, { key: i, ...attrs })) }
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
Basic Example
|
|
2
2
|
```jsx
|
|
3
|
-
import { Button, Layout, Title } from '@nurvus/ui';
|
|
4
|
-
import AddIcon from '@material-ui/icons/Add';
|
|
5
|
-
import FileCopyIcon from '@material-ui/icons/FileCopy';
|
|
6
|
-
import RemoveRedEyeIcon from '@material-ui/icons/RemoveRedEye';
|
|
7
|
-
import LockOpenIcon from '@material-ui/icons/LockOpen';
|
|
3
|
+
import { Button, Icon, Layout, Title } from '@nurvus/ui';
|
|
8
4
|
|
|
9
5
|
<Layout>
|
|
10
6
|
<Title level={ 3 }>Layers</Title>
|
|
11
|
-
<Button>
|
|
12
|
-
<
|
|
7
|
+
<Button aria-label="Add">
|
|
8
|
+
<Icon name="add" size="1.25em" />
|
|
13
9
|
</Button>
|
|
14
10
|
</Layout>
|
|
15
11
|
```
|
|
16
12
|
|
|
17
13
|
Horizontal Example
|
|
18
14
|
```jsx
|
|
19
|
-
import { Button, Layout, Title } from '@nurvus/ui';
|
|
20
|
-
import AddIcon from '@material-ui/icons/Add';
|
|
21
|
-
import FileCopyIcon from '@material-ui/icons/FileCopy';
|
|
22
|
-
import RemoveRedEyeIcon from '@material-ui/icons/RemoveRedEye';
|
|
23
|
-
import LockOpenIcon from '@material-ui/icons/LockOpen';
|
|
15
|
+
import { Button, Icon, Layout, Title } from '@nurvus/ui';
|
|
24
16
|
|
|
25
17
|
<Layout itemSpacing={ 32 }>
|
|
26
18
|
<Layout itemSpacing={ 8 }>
|
|
27
19
|
<Title level={ 4 }>Display Flex</Title>
|
|
28
20
|
<Layout display="flex">
|
|
29
21
|
<Title level={ 3 }>Layers</Title>
|
|
30
|
-
<Button>
|
|
31
|
-
<
|
|
22
|
+
<Button aria-label="Add">
|
|
23
|
+
<Icon name="add" size="1.25em" />
|
|
32
24
|
</Button>
|
|
33
25
|
</Layout>
|
|
34
26
|
</Layout>
|
|
@@ -36,8 +28,8 @@ import LockOpenIcon from '@material-ui/icons/LockOpen';
|
|
|
36
28
|
<Title level={ 4 }>Display Flex and Align Item</Title>
|
|
37
29
|
<Layout display="flex" alignItems="center">
|
|
38
30
|
<Title level={ 3 }>Layers</Title>
|
|
39
|
-
<Button>
|
|
40
|
-
<
|
|
31
|
+
<Button aria-label="Add">
|
|
32
|
+
<Icon name="add" size="1.25em" />
|
|
41
33
|
</Button>
|
|
42
34
|
</Layout>
|
|
43
35
|
</Layout>
|
|
@@ -45,8 +37,8 @@ import LockOpenIcon from '@material-ui/icons/LockOpen';
|
|
|
45
37
|
<Title level={ 4 }>Display Flex and Align Item and Spaced Apart</Title>
|
|
46
38
|
<Layout display="flex" alignItems="center" justifyContent="space-between">
|
|
47
39
|
<Title level={ 3 }>Layers</Title>
|
|
48
|
-
<Button>
|
|
49
|
-
<
|
|
40
|
+
<Button aria-label="Add">
|
|
41
|
+
<Icon name="add" size="1.25em" />
|
|
50
42
|
</Button>
|
|
51
43
|
</Layout>
|
|
52
44
|
</Layout>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
The light is the logo's Pulse (see [Brand](#/Foundations/Brand)). It is 2em by default, so it sizes with the text around it.
|
|
2
|
+
|
|
3
|
+
```jsx
|
|
4
|
+
import { Layout, Loader } from '@nurvus/ui';
|
|
5
|
+
|
|
6
|
+
<Layout display="flex" alignItems="center" itemSpacing={ 32 }>
|
|
7
|
+
<Loader size="1em" />
|
|
8
|
+
<Loader />
|
|
9
|
+
<Loader size={ 48 } />
|
|
10
|
+
<Loader size={ 96 } id="big-loader" label="Loading your workspace" />
|
|
11
|
+
</Layout>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With `showLabel` the label shows beside it. Name what is loading where it helps: "Loading photos" says more than "Loading".
|
|
15
|
+
```jsx
|
|
16
|
+
import { Button, Layout, Loader, Text } from '@nurvus/ui';
|
|
17
|
+
|
|
18
|
+
const Fetch = () => {
|
|
19
|
+
const [loading, setLoading] = React.useState(true);
|
|
20
|
+
return (
|
|
21
|
+
<Layout itemSpacing={ 12 }>
|
|
22
|
+
{ loading ? <Loader label="Loading photos" showLabel /> : <Text>12 photos</Text> }
|
|
23
|
+
<div><Button size="small" type="secondary" onClick={ () => setLoading(!loading) }>{ loading ? 'Finish' : 'Load again' }</Button></div>
|
|
24
|
+
</Layout>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
<Fetch />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
From about 64 pixels the segments look better with the logo's gradients: give it an `id` and they are drawn with gradients named after it.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Styles for Loader.tsx (and the Respawn Loader: same markup). The logo's
|
|
2
|
+
// Pulse: each segment brightens as a light runs round the ring.
|
|
3
|
+
@import "../../styles/variables.scss";
|
|
4
|
+
|
|
5
|
+
$loader-turn: 1.6s;
|
|
6
|
+
|
|
7
|
+
.#{$cls-prefix}.loader {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: var(--space--8);
|
|
11
|
+
color: var(--nv-text-muted);
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
|
|
14
|
+
.loader-mark {
|
|
15
|
+
display: block;
|
|
16
|
+
flex: none;
|
|
17
|
+
overflow: visible;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.loader-seg {
|
|
21
|
+
opacity: 0.35;
|
|
22
|
+
animation: nurvus-loader-glint $loader-turn ease-in-out infinite;
|
|
23
|
+
// Each segment lights up when the light reaches its place on the ring.
|
|
24
|
+
animation-delay: calc(var(--nurvus-loader-at, 0) * #{$loader-turn} - #{$loader-turn});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Shown only to screen readers unless showLabel.
|
|
28
|
+
&[data-label="hidden"] .loader-label {
|
|
29
|
+
position: absolute;
|
|
30
|
+
width: 1px;
|
|
31
|
+
height: 1px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
clip: rect(0 0 0 0);
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@keyframes nurvus-loader-glint {
|
|
39
|
+
0%, 100% { opacity: 0.35; }
|
|
40
|
+
14% { opacity: 1; }
|
|
41
|
+
45% { opacity: 0.35; }
|
|
42
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import CONSTANT from '../../constants';
|
|
4
|
+
import { loaderRings, LOGO_VIEWBOX } from '../../loader';
|
|
5
|
+
import './Loader.scss';
|
|
6
|
+
|
|
7
|
+
export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
/** Width and height of the mark. Defaults to 2em (twice the text size). A number is pixels. */
|
|
9
|
+
size?: number | string;
|
|
10
|
+
/** What is loading, for screen readers ("Loading photos"). Defaults to "Loading". */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Shows the label beside the mark, not only to screen readers. */
|
|
13
|
+
showLabel?: boolean;
|
|
14
|
+
/** Fills the segments with the logo's gradients (for big loaders); their ids start with this. Without it, one color each. */
|
|
15
|
+
id?: string;
|
|
16
|
+
/** Custom class name. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Shows that something is loading: the NURVUS mark with a light running round
|
|
22
|
+
* it (the logo's Pulse). Screen readers hear the label once, politely
|
|
23
|
+
* (role="status"). The light keeps running with reduced motion: it only
|
|
24
|
+
* changes brightness, nothing moves, and a loader that stopped would look
|
|
25
|
+
* stuck (WCAG 2.2.2 counts a loading animation as essential).
|
|
26
|
+
*/
|
|
27
|
+
export default function Loader({
|
|
28
|
+
size = '2em',
|
|
29
|
+
label = 'Loading',
|
|
30
|
+
showLabel = false,
|
|
31
|
+
id,
|
|
32
|
+
className,
|
|
33
|
+
...restProps
|
|
34
|
+
}: LoaderProps) {
|
|
35
|
+
const { inner, outer, gradients } = loaderRings(id);
|
|
36
|
+
const ring = (cls: string, segments: typeof inner) => (
|
|
37
|
+
<g className={ `loader-ring ${cls}` }>
|
|
38
|
+
{ segments.map((s, i) => (
|
|
39
|
+
<path key={ i } className="loader-seg" d={ s.d } fill={ s.fill } style={ { '--nurvus-loader-at': String(s.angle) } as React.CSSProperties } />
|
|
40
|
+
)) }
|
|
41
|
+
</g>
|
|
42
|
+
);
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
className={ classNames(className, 'loader', CONSTANT.CLASS_PREFIX) }
|
|
46
|
+
role="status"
|
|
47
|
+
data-label={ showLabel ? 'shown' : 'hidden' }
|
|
48
|
+
id={ id }
|
|
49
|
+
{ ...restProps }
|
|
50
|
+
>
|
|
51
|
+
<svg className="loader-mark" viewBox={ LOGO_VIEWBOX } width={ size } height={ size } aria-hidden="true" focusable="false">
|
|
52
|
+
{ gradients.length > 0 && (
|
|
53
|
+
<defs>
|
|
54
|
+
{ gradients.map((g) => (
|
|
55
|
+
<linearGradient key={ g.id } id={ g.id } gradientUnits="userSpaceOnUse" x1={ g.x1 } y1={ g.y1 } x2={ g.x2 } y2={ g.y2 }>
|
|
56
|
+
<stop stopColor={ g.from } />
|
|
57
|
+
<stop offset="1" stopColor={ g.to } />
|
|
58
|
+
</linearGradient>
|
|
59
|
+
)) }
|
|
60
|
+
</defs>
|
|
61
|
+
) }
|
|
62
|
+
{ ring('loader-inner', inner) }
|
|
63
|
+
{ ring('loader-outer', outer) }
|
|
64
|
+
</svg>
|
|
65
|
+
<span className="loader-label">{ label }</span>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
**The items decide what it is**, and screen readers hear it that way:
|
|
2
|
+
|
|
3
|
+
| Items | It becomes | Screen readers say | Keys |
|
|
4
|
+
|---|---|---|---|
|
|
5
|
+
| Links (`href`) | Navigation: a `<nav>` landmark | "Pages, navigation… Billing, link, current page" | Tab goes link by link; ↑ ↓ Home End move too; → ← open and close sections |
|
|
6
|
+
| Actions (`onSelect`) | A menu of commands (`role="menu"`) | "Actions, menu… Duplicate, menu item" | One Tab stop; ↑ ↓ Home End move; type a letter to jump; Enter or Space runs it |
|
|
7
|
+
| Rows to pick, `kind="tree"` | A tree (the same as [Tree](#/Components/Tree)) | "Layers, tree… Header, level 1, 1 of 3, selected" | One Tab stop; ↑ ↓ move, → ← go in and out, Enter or Space picks |
|
|
8
|
+
|
|
9
|
+
Left out, `kind` follows the items: navigation when any item has an `href`, actions when none has. An item without an `href` inside navigation is a button there ("Sign out"). Links take Enter only, as everywhere on the web (Space scrolls the page); buttons, chevrons and tree rows take Enter and Space.
|
|
10
|
+
|
|
11
|
+
**Navigation.** Sections open and close with the chevron (or the whole heading, when it isn't a link). The current page is marked with a bar beside it, and its section opens by itself.
|
|
2
12
|
|
|
3
|
-
By keyboard: Tab goes link by link as usual, and inside the menu ↑ ↓ move between rows (going round at the ends), Home and End jump to the first and last, → opens a section and ← closes it.
|
|
4
13
|
```jsx
|
|
5
14
|
import { Menu } from '@nurvus/ui';
|
|
6
15
|
|
|
@@ -39,3 +48,60 @@ import { Menu } from '@nurvus/ui';
|
|
|
39
48
|
/>
|
|
40
49
|
</div>
|
|
41
50
|
```
|
|
51
|
+
|
|
52
|
+
**Actions.** Items with `onSelect` and no `href`: a menu of commands. Tab reaches it once (the item you were last on), then ↑ ↓ move and typing a letter jumps to the next item that starts with it. A disabled item stays in the list, so people still find it, but does nothing.
|
|
53
|
+
```jsx
|
|
54
|
+
import { Menu, Text } from '@nurvus/ui';
|
|
55
|
+
|
|
56
|
+
const Actions = () => {
|
|
57
|
+
const [done, setDone] = React.useState('Nothing yet');
|
|
58
|
+
const run = (what) => () => setDone(what);
|
|
59
|
+
return (
|
|
60
|
+
<div style={ { maxWidth: 260 } }>
|
|
61
|
+
<Menu
|
|
62
|
+
id="layer-actions"
|
|
63
|
+
label="Layer actions"
|
|
64
|
+
sections={ [
|
|
65
|
+
{ title: 'Edit', items: [
|
|
66
|
+
{ label: 'Duplicate', onSelect: run('Duplicated') },
|
|
67
|
+
{ label: 'Rename', onSelect: run('Renamed') },
|
|
68
|
+
{ label: 'Group', onSelect: run('Grouped'), disabled: true },
|
|
69
|
+
] },
|
|
70
|
+
{ title: 'Arrange', items: [
|
|
71
|
+
{ label: 'Bring to front', onSelect: run('Brought to front') },
|
|
72
|
+
{ label: 'Send to back', onSelect: run('Sent to back') },
|
|
73
|
+
{ label: 'Delete', onSelect: run('Deleted'), divider: true },
|
|
74
|
+
] },
|
|
75
|
+
] }
|
|
76
|
+
/>
|
|
77
|
+
<Text variant="caption" tone="muted">{ done }</Text>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
<Actions />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**A tree.** `kind="tree"` takes Tree's props: nested `items`, the `activePath` of the picked row, and `onClick(event, path)`.
|
|
85
|
+
```jsx
|
|
86
|
+
import { Menu } from '@nurvus/ui';
|
|
87
|
+
|
|
88
|
+
const Layers = () => {
|
|
89
|
+
const [path, setPath] = React.useState([1, 0]);
|
|
90
|
+
return (
|
|
91
|
+
<div style={ { maxWidth: 260 } }>
|
|
92
|
+
<Menu
|
|
93
|
+
kind="tree"
|
|
94
|
+
label="Layers"
|
|
95
|
+
activePath={ path }
|
|
96
|
+
onClick={ (event, next) => setPath(next) }
|
|
97
|
+
items={ [
|
|
98
|
+
{ label: 'Header' },
|
|
99
|
+
{ label: 'Hero', items: [{ label: 'Title' }, { label: 'Image' }] },
|
|
100
|
+
{ label: 'Footer' },
|
|
101
|
+
] }
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
<Layers />
|
|
107
|
+
```
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
@import "../../styles/variables.scss";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Menu: navigation (links; sections open and close by animating the list's
|
|
4
|
+
// row, grid-template-rows 1fr <-> 0fr: smooth, no height measuring) or a menu
|
|
5
|
+
// of actions (buttons, data-kind="actions").
|
|
5
6
|
$menu-speed: 0.2s;
|
|
6
7
|
|
|
7
8
|
.#{$cls-prefix}.menu {
|
|
8
|
-
font-size:
|
|
9
|
-
line-height:
|
|
9
|
+
font-size: 0.875rem;
|
|
10
|
+
line-height: 1.25rem;
|
|
10
11
|
|
|
11
12
|
.menu-section + .menu-section { margin-top: var(--space--8); }
|
|
12
13
|
|
|
@@ -19,9 +20,9 @@ $menu-speed: 0.2s;
|
|
|
19
20
|
.menu-title {
|
|
20
21
|
flex: 1;
|
|
21
22
|
min-width: 0;
|
|
22
|
-
padding: var(--space--4)
|
|
23
|
+
padding: var(--space--4) 0.625rem;
|
|
23
24
|
border: 0;
|
|
24
|
-
border-radius:
|
|
25
|
+
border-radius: 0.375rem;
|
|
25
26
|
background: none;
|
|
26
27
|
color: var(--nv-text);
|
|
27
28
|
font: inherit;
|
|
@@ -44,8 +45,8 @@ $menu-speed: 0.2s;
|
|
|
44
45
|
|
|
45
46
|
&::after {
|
|
46
47
|
content: '';
|
|
47
|
-
width:
|
|
48
|
-
height:
|
|
48
|
+
width: 0.375rem;
|
|
49
|
+
height: 0.375rem;
|
|
49
50
|
margin: 0 var(--space--4);
|
|
50
51
|
border-right: 1.5px solid currentColor;
|
|
51
52
|
border-bottom: 1.5px solid currentColor;
|
|
@@ -57,11 +58,11 @@ $menu-speed: 0.2s;
|
|
|
57
58
|
// The icon-only toggle beside a heading that is a link.
|
|
58
59
|
.menu-toggle:not(.menu-title) {
|
|
59
60
|
flex: none;
|
|
60
|
-
width:
|
|
61
|
-
height:
|
|
61
|
+
width: 1.5rem;
|
|
62
|
+
height: 1.5rem;
|
|
62
63
|
padding: 0;
|
|
63
64
|
border: 0;
|
|
64
|
-
border-radius:
|
|
65
|
+
border-radius: 0.375rem;
|
|
65
66
|
background: none;
|
|
66
67
|
color: var(--nv-text-muted);
|
|
67
68
|
cursor: pointer;
|
|
@@ -88,8 +89,8 @@ $menu-speed: 0.2s;
|
|
|
88
89
|
min-height: 0;
|
|
89
90
|
overflow: hidden;
|
|
90
91
|
// Room on the left for the current-page bar, which sits outside the item.
|
|
91
|
-
margin: 0 0 0 -
|
|
92
|
-
padding: 0 0 0
|
|
92
|
+
margin: 0 0 0 -0.75rem;
|
|
93
|
+
padding: 0 0 0 0.75rem; // no vertical padding: it would stay when the row closes to 0
|
|
93
94
|
list-style: none;
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -113,10 +114,22 @@ $menu-speed: 0.2s;
|
|
|
113
114
|
.menu-item {
|
|
114
115
|
position: relative;
|
|
115
116
|
display: block;
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
width: 100%;
|
|
119
|
+
padding: var(--space--4) 0.625rem var(--space--4) 1.25rem;
|
|
120
|
+
border: 0;
|
|
121
|
+
border-radius: 0.375rem;
|
|
122
|
+
background: none;
|
|
118
123
|
color: var(--nv-text-muted);
|
|
124
|
+
font: inherit;
|
|
125
|
+
text-align: left;
|
|
119
126
|
text-decoration: none;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
|
|
129
|
+
&:disabled,
|
|
130
|
+
&[aria-disabled="true"] { color: var(--nv-text-subtle); cursor: not-allowed; }
|
|
131
|
+
&:disabled:hover,
|
|
132
|
+
&[aria-disabled="true"]:hover { background: none; color: var(--nv-text-subtle); }
|
|
120
133
|
|
|
121
134
|
&:hover { background: var(--nv-surface-hover); color: var(--nv-text); }
|
|
122
135
|
&:focus-visible { outline: 2px solid var(--nv-accent); outline-offset: -2px; }
|
|
@@ -133,15 +146,32 @@ $menu-speed: 0.2s;
|
|
|
133
146
|
content: '';
|
|
134
147
|
position: absolute;
|
|
135
148
|
top: 50%;
|
|
136
|
-
left: -
|
|
137
|
-
width:
|
|
138
|
-
height:
|
|
149
|
+
left: -0.5rem;
|
|
150
|
+
width: 0.25rem;
|
|
151
|
+
height: 1.125rem;
|
|
139
152
|
border-radius: 2px;
|
|
140
153
|
background: var(--nv-accent);
|
|
141
154
|
transform: translateY(-50%);
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
|
|
158
|
+
// Actions: always open; section titles are labels, not buttons; items in the text color.
|
|
159
|
+
&[data-kind="actions"] {
|
|
160
|
+
.menu-title {
|
|
161
|
+
cursor: default;
|
|
162
|
+
color: var(--nv-text-muted);
|
|
163
|
+
font-size: 0.75rem;
|
|
164
|
+
line-height: 1rem;
|
|
165
|
+
letter-spacing: 0.04em;
|
|
166
|
+
text-transform: uppercase;
|
|
167
|
+
|
|
168
|
+
&:hover { background: none; }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.menu-item { padding-left: 0.625rem; color: var(--nv-text); }
|
|
172
|
+
li:last-child { margin-bottom: 0; }
|
|
173
|
+
}
|
|
174
|
+
|
|
145
175
|
@media (prefers-reduced-motion: reduce) {
|
|
146
176
|
.menu-items,
|
|
147
177
|
.menu-toggle::after,
|