@nurvus/ui 0.1.0-alpha.15 → 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.
Files changed (71) hide show
  1. package/README.md +11 -1
  2. package/dist/icons.svg +73 -0
  3. package/dist/index.js +1 -1
  4. package/dist/nurvus.css +13 -10
  5. package/dist/respawn.js +1 -1
  6. package/dist/types/breakpoints.d.ts +14 -0
  7. package/dist/types/components/FullPageModal/FullPageModal.d.ts +11 -2
  8. package/dist/types/components/Grid/Grid.d.ts +26 -0
  9. package/dist/types/components/Loader/Loader.d.ts +21 -0
  10. package/dist/types/components/Menu/Menu.d.ts +54 -19
  11. package/dist/types/components/Progress/Progress.d.ts +19 -5
  12. package/dist/types/components/Stack/Stack.d.ts +26 -0
  13. package/dist/types/dialog.d.ts +12 -0
  14. package/dist/types/icons.d.ts +28 -0
  15. package/dist/types/index.d.ts +9 -1
  16. package/dist/types/loader.d.ts +28 -0
  17. package/dist/types/logo.d.ts +5 -0
  18. package/dist/types/menu.d.ts +43 -14
  19. package/dist/types/progress.d.ts +11 -0
  20. package/dist/types/respawn/FullPageModal.d.ts +7 -1
  21. package/dist/types/respawn/Grid.d.ts +21 -0
  22. package/dist/types/respawn/Loader.d.ts +18 -0
  23. package/dist/types/respawn/Menu.d.ts +45 -15
  24. package/dist/types/respawn/Progress.d.ts +18 -6
  25. package/dist/types/respawn/Stack.d.ts +21 -0
  26. package/dist/types/respawn/index.d.ts +9 -1
  27. package/package.json +1 -3
  28. package/src/breakpoints.ts +28 -0
  29. package/src/components/Button/Button.scss +20 -20
  30. package/src/components/FullPageModal/FullPageModal.md +20 -17
  31. package/src/components/FullPageModal/FullPageModal.scss +5 -0
  32. package/src/components/FullPageModal/FullPageModal.tsx +37 -3
  33. package/src/components/Grid/Grid.md +37 -0
  34. package/src/components/Grid/Grid.scss +37 -0
  35. package/src/components/Grid/Grid.tsx +54 -0
  36. package/src/components/HistoryList/HistoryList.scss +2 -2
  37. package/src/components/Loader/Loader.md +30 -0
  38. package/src/components/Loader/Loader.scss +42 -0
  39. package/src/components/Loader/Loader.tsx +68 -0
  40. package/src/components/Menu/Menu.md +67 -3
  41. package/src/components/Menu/Menu.scss +48 -18
  42. package/src/components/Menu/Menu.tsx +146 -39
  43. package/src/components/Progress/Progress.md +27 -26
  44. package/src/components/Progress/Progress.scss +41 -36
  45. package/src/components/Progress/Progress.tsx +50 -6
  46. package/src/components/Select/Select.scss +20 -19
  47. package/src/components/Stack/Stack.md +43 -0
  48. package/src/components/Stack/Stack.scss +36 -0
  49. package/src/components/Stack/Stack.tsx +52 -0
  50. package/src/components/Table/Table.scss +1 -1
  51. package/src/components/Tag/Tag.scss +2 -2
  52. package/src/components/Title/Title.scss +6 -6
  53. package/src/components/Tree/Tree.md +1 -1
  54. package/src/css.ts +3 -0
  55. package/src/dialog.ts +47 -0
  56. package/src/icons.ts +29 -0
  57. package/src/index.ts +9 -1
  58. package/src/loader.ts +43 -0
  59. package/src/logo.ts +12 -0
  60. package/src/menu.ts +91 -21
  61. package/src/progress.ts +21 -0
  62. package/src/respawn/FullPageModal.ts +30 -3
  63. package/src/respawn/Grid.ts +41 -0
  64. package/src/respawn/Loader.ts +77 -0
  65. package/src/respawn/Menu.ts +138 -34
  66. package/src/respawn/Progress.ts +56 -13
  67. package/src/respawn/Stack.ts +37 -0
  68. package/src/respawn/index.ts +9 -1
  69. package/src/styles/breakpoints.scss +3 -0
  70. package/src/styles/theme.scss +55 -55
  71. package/src/styles/type.json +9 -9
@@ -1,36 +1,80 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import CONSTANT from '../../constants';
4
+ import Icon from '../Icon/Icon';
5
+ import { PROGRESS_STATUS, clampPercent, progressValueText, ProgressStatus } from '../../progress';
4
6
  import './Progress.scss';
5
7
 
6
8
  export type ProgressSize = 'small' | 'medium' | 'large';
7
- export type ProgressStatus = 'active' | 'success' | 'warning' | 'critical';
9
+ export type { ProgressStatus };
8
10
 
9
- export interface ProgressProps {
11
+ export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
10
12
  /** How far along, 0 to 100. */
11
13
  percent?: number;
12
14
  /** Bar height. */
13
15
  size?: ProgressSize;
14
- /** The bar color: active (accent), success, warning or critical (danger). */
16
+ /** The bar color: active (accent), success, warning or critical (danger). With a label or showValue, a status also shows as an icon and a word. */
15
17
  status?: ProgressStatus;
18
+ /** What is in progress ("Uploading"): shown above the bar, and its name for screen readers. */
19
+ label?: string;
20
+ /** Keeps the label for screen readers only. */
21
+ hideLabel?: boolean;
22
+ /** Shows the percent (and the status, as an icon and a word) at the right, above the bar. */
23
+ showValue?: boolean;
24
+ /** What screen readers say for the value, instead of "40%" (e.g. "3 of 8 files"). */
25
+ valueText?: string;
16
26
  /** Custom class name. */
17
27
  className?: string;
18
28
  }
19
29
 
20
- /** A progress bar. Use it to track progress! */
30
+ /**
31
+ * A progress bar: how far along something is. Screen readers hear it as a
32
+ * progress bar with its label and value ("Uploading, progress bar, 40%").
33
+ * Its status is never color alone: with a label or showValue it shows as an
34
+ * icon and a word too, and screen readers hear the word.
35
+ */
21
36
  export default function Progress({
22
37
  className,
23
38
  percent = 0,
24
39
  size = 'medium',
25
- status = 'active'
40
+ status = 'active',
41
+ label,
42
+ hideLabel = false,
43
+ showValue = false,
44
+ valueText,
45
+ ...restProps
26
46
  }: ProgressProps) {
47
+ const value = clampPercent(percent);
48
+ const meaning = PROGRESS_STATUS[status] || PROGRESS_STATUS.active;
49
+ const head = (label && !hideLabel) || showValue;
27
50
  return (
28
51
  <div
29
52
  className={ classNames(className, 'progress', CONSTANT.CLASS_PREFIX) }
30
53
  data-size={ size }
31
54
  data-status={ status }
55
+ role="progressbar"
56
+ aria-label={ label || 'Progress' }
57
+ aria-valuemin={ 0 }
58
+ aria-valuemax={ 100 }
59
+ aria-valuenow={ value }
60
+ aria-valuetext={ valueText || progressValueText(value, status) }
61
+ { ...restProps }
32
62
  >
33
- <div className="bar" style={ { width: `${percent}%` } } />
63
+ { head && (
64
+ <div className="progress-head">
65
+ { label && !hideLabel && <span className="progress-label">{ label }</span> }
66
+ { showValue && (
67
+ <span className="progress-value">
68
+ { meaning.icon && <Icon name={ meaning.icon } /> }
69
+ { meaning.word && <span className="progress-word">{ meaning.word }</span> }
70
+ <span>{ `${value}%` }</span>
71
+ </span>
72
+ ) }
73
+ </div>
74
+ ) }
75
+ <div className="progress-track">
76
+ <div className="bar" style={ { width: `${value}%` } } />
77
+ </div>
34
78
  </div>
35
79
  );
36
80
  }
@@ -8,18 +8,18 @@ $select-speed: 0.12s;
8
8
  position: relative;
9
9
  display: inline-block;
10
10
  max-width: 100%;
11
- font-size: 14px;
12
- line-height: 20px;
11
+ font-size: 0.875rem;
12
+ line-height: 1.25rem;
13
13
 
14
14
  .select-trigger {
15
15
  display: inline-flex;
16
16
  align-items: center;
17
17
  gap: var(--space--8);
18
18
  max-width: 100%;
19
- min-height: 32px;
19
+ min-height: 2rem;
20
20
  padding: var(--space--4) var(--space--8) var(--space--4) var(--space--12);
21
21
  border: 1px solid var(--nv-border-strong);
22
- border-radius: 8px;
22
+ border-radius: 0.5rem;
23
23
  background: var(--nv-surface);
24
24
  color: var(--nv-text);
25
25
  cursor: pointer;
@@ -47,13 +47,13 @@ $select-speed: 0.12s;
47
47
  .select-chevron {
48
48
  display: inline-flex;
49
49
  flex: none;
50
- width: 16px;
50
+ width: 1rem;
51
51
  justify-content: center;
52
52
 
53
53
  &::after {
54
54
  content: '';
55
- width: 6px;
56
- height: 6px;
55
+ width: 0.375rem;
56
+ height: 0.375rem;
57
57
  border-right: 1.5px solid currentColor;
58
58
  border-bottom: 1.5px solid currentColor;
59
59
  transform: translateY(-2px) rotate(45deg);
@@ -69,17 +69,18 @@ $select-speed: 0.12s;
69
69
  top: calc(100% + var(--space--4));
70
70
  left: 0;
71
71
  min-width: 100%;
72
- max-height: 360px;
72
+ // Set --nurvus-select-list-height to make the list taller or shorter.
73
+ max-height: var(--nurvus-select-list-height, 22.5rem);
73
74
  overflow: auto;
74
75
  padding: var(--space--4);
75
76
  border: 1px solid var(--nv-border);
76
- border-radius: 10px;
77
+ border-radius: 0.625rem;
77
78
  background: var(--nv-surface);
78
79
  color: var(--nv-text);
79
80
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.24);
80
81
  opacity: 0;
81
82
  visibility: hidden;
82
- transform: translateY(-4px) scale(0.98);
83
+ transform: translateY(-0.25rem) scale(0.98);
83
84
  transform-origin: top left;
84
85
  transition: opacity $select-speed ease, transform $select-speed ease, visibility 0s $select-speed;
85
86
  }
@@ -103,8 +104,8 @@ $select-speed: 0.12s;
103
104
  .select-group-label {
104
105
  padding: var(--space--4) var(--space--8);
105
106
  color: var(--nv-text-muted);
106
- font-size: 12px;
107
- line-height: 16px;
107
+ font-size: 0.75rem;
108
+ line-height: 1rem;
108
109
  font-weight: 600;
109
110
  letter-spacing: 0.04em;
110
111
  text-transform: uppercase;
@@ -115,8 +116,8 @@ $select-speed: 0.12s;
115
116
  display: flex;
116
117
  align-items: center;
117
118
  gap: var(--space--8);
118
- padding: 6px 32px 6px var(--space--8); // room on the right for the check
119
- border-radius: 6px;
119
+ padding: 0.375rem 2rem 0.375rem var(--space--8); // room on the right for the check
120
+ border-radius: 0.375rem;
120
121
  cursor: pointer;
121
122
  white-space: nowrap;
122
123
 
@@ -136,9 +137,9 @@ $select-speed: 0.12s;
136
137
  content: '';
137
138
  position: absolute;
138
139
  top: 50%;
139
- right: 12px;
140
- width: 5px;
141
- height: 10px;
140
+ right: 0.75rem;
141
+ width: 0.3125rem;
142
+ height: 0.625rem;
142
143
  border-right: 2px solid var(--nv-accent);
143
144
  border-bottom: 2px solid var(--nv-accent);
144
145
  transform: translateY(-60%) rotate(45deg);
@@ -157,8 +158,8 @@ $select-speed: 0.12s;
157
158
 
158
159
  .select-option-description {
159
160
  color: var(--nv-text-muted);
160
- font-size: 12px;
161
- line-height: 16px;
161
+ font-size: 0.75rem;
162
+ line-height: 1rem;
162
163
  font-weight: 400;
163
164
  }
164
165
 
@@ -0,0 +1,43 @@
1
+ A column or a row with even space between the children, from the [4px grid](#/Foundations/Spacing). It spaces with CSS `gap`, so a row that wraps keeps its spacing on every line.
2
+
3
+ ```jsx
4
+ import { Button, Stack, Tag, Text } from '@nurvus/ui';
5
+
6
+ <Stack gap={ 12 }>
7
+ <Text weight="semibold">Release 2.4</Text>
8
+ <Stack direction="row" gap={ 8 } align="center">
9
+ <Tag tone="success">Ready</Tag>
10
+ <Text tone="muted">All checks passed</Text>
11
+ </Stack>
12
+ <Stack direction="row" gap={ 8 }>
13
+ <Button>Publish</Button>
14
+ <Button type="secondary">Preview</Button>
15
+ </Stack>
16
+ </Stack>
17
+ ```
18
+
19
+ The direction can change with the screen: `{ base: 'column', md: 'row' }` stacks on phones and sits in a row from the md breakpoint (48em, 768 pixels) up. Make the window narrower to see it.
20
+ ```jsx
21
+ import { Panel, Stack, Text } from '@nurvus/ui';
22
+
23
+ <Stack direction={ { base: 'column', md: 'row' } } gap={ 16 }>
24
+ <Panel title="Plan" style={ { flex: 1 } }><Text>Pro, billed yearly</Text></Panel>
25
+ <Panel title="Seats" style={ { flex: 1 } }><Text>12 of 20 used</Text></Panel>
26
+ <Panel title="Renews" style={ { flex: 1 } }><Text>March 3</Text></Panel>
27
+ </Stack>
28
+ ```
29
+
30
+ `justify="between"` pushes the ends apart; `wrap` lets a long row break onto more lines.
31
+ ```jsx
32
+ import { Button, Stack, Tag, Text } from '@nurvus/ui';
33
+
34
+ <Stack gap={ 16 }>
35
+ <Stack direction="row" justify="between" align="center">
36
+ <Text weight="semibold">Filters</Text>
37
+ <Button size="small" type="secondary">Clear</Button>
38
+ </Stack>
39
+ <Stack direction="row" gap={ 8 } wrap>
40
+ { ['React', 'Respawn', 'TypeScript', 'Themes', 'Icons', 'Accessibility', 'Spacing', 'Motion'].map((t) => <Tag key={ t }>{ t }</Tag>) }
41
+ </Stack>
42
+ </Stack>
43
+ ```
@@ -0,0 +1,36 @@
1
+ // Styles for Stack (React and Respawn: same markup).
2
+ @import "../../styles/variables.scss";
3
+ @import "../../styles/breakpoints.scss";
4
+
5
+ $stack-steps: 0, 2, 4, 8, 12, 16, 24, 32, 48, 64;
6
+
7
+ .#{$cls-prefix}.stack {
8
+ display: flex;
9
+ flex-direction: column;
10
+
11
+ &[data-direction="row"] { flex-direction: row; }
12
+
13
+ @each $bp, $width in $nurvus-breakpoints {
14
+ @media (min-width: $width) {
15
+ &[data-direction-#{$bp}="column"] { flex-direction: column; }
16
+ &[data-direction-#{$bp}="row"] { flex-direction: row; }
17
+ }
18
+ }
19
+
20
+ @each $n in $stack-steps {
21
+ &[data-gap="#{$n}"] { gap: var(--space--#{$n}); }
22
+ }
23
+
24
+ &[data-align="start"] { align-items: flex-start; }
25
+ &[data-align="center"] { align-items: center; }
26
+ &[data-align="end"] { align-items: flex-end; }
27
+ &[data-align="stretch"] { align-items: stretch; }
28
+ &[data-align="baseline"] { align-items: baseline; }
29
+
30
+ &[data-justify="start"] { justify-content: flex-start; }
31
+ &[data-justify="center"] { justify-content: center; }
32
+ &[data-justify="end"] { justify-content: flex-end; }
33
+ &[data-justify="between"] { justify-content: space-between; }
34
+
35
+ &[data-wrap="true"] { flex-wrap: wrap; }
36
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import CONSTANT from '../../constants';
4
+ import { Spacing } from '../../spacing';
5
+ import { Responsive, responsiveData } from '../../breakpoints';
6
+ import './Stack.scss';
7
+
8
+ export type StackDirection = 'column' | 'row';
9
+
10
+ export interface StackProps extends React.HTMLAttributes<HTMLDivElement> {
11
+ /** column (top to bottom, the default) or row. Can change with the width: { base: 'column', md: 'row' }. */
12
+ direction?: Responsive<StackDirection>;
13
+ /** Space between the children, from the 4px grid: 0, 2, 4, 8, 12, 16, 24, 32, 48 or 64. */
14
+ gap?: Spacing;
15
+ /** How the children line up across the stack. */
16
+ align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
17
+ /** How the children spread along the stack. */
18
+ justify?: 'start' | 'center' | 'end' | 'between';
19
+ /** Lets a row wrap onto more lines when it runs out of room. */
20
+ wrap?: boolean;
21
+ /** What to lay out. */
22
+ children?: React.ReactNode;
23
+ /** Custom class name. */
24
+ className?: string;
25
+ }
26
+
27
+ /**
28
+ * Puts its children in a column or a row with even space between them, from
29
+ * the 4px grid (CSS gap, so wrapped rows keep their spacing too). The
30
+ * direction can change at a breakpoint: a column on phones, a row from md up.
31
+ */
32
+ export default function Stack({
33
+ direction = 'column',
34
+ gap = 16,
35
+ align,
36
+ justify,
37
+ wrap = false,
38
+ className,
39
+ ...restProps
40
+ }: StackProps) {
41
+ return (
42
+ <div
43
+ className={ classNames(className, 'stack', CONSTANT.CLASS_PREFIX) }
44
+ { ...responsiveData('direction', direction) }
45
+ data-gap={ gap }
46
+ data-align={ align }
47
+ data-justify={ justify }
48
+ data-wrap={ wrap || undefined }
49
+ { ...restProps }
50
+ />
51
+ );
52
+ }
@@ -19,7 +19,7 @@
19
19
  th,
20
20
  td {
21
21
  box-sizing: border-box;
22
- padding: 10px $--space--12;
22
+ padding: 0.625rem $--space--12;
23
23
  text-align: left;
24
24
  vertical-align: middle;
25
25
  border-bottom: 1px solid var(--nv-border);
@@ -12,9 +12,9 @@
12
12
  // The tone mixed with a fifth of the text color: on its own tint (and on a
13
13
  // Panel's surface) every tone keeps 4.5:1 in every theme.
14
14
  color: color-mix(in srgb, var(--tag-color) 80%, var(--nv-text));
15
- font-size: 12px;
15
+ font-size: 0.75rem;
16
16
  font-weight: 500;
17
- line-height: 18px;
17
+ line-height: 1.125rem;
18
18
  white-space: nowrap;
19
19
 
20
20
  &[data-tone="accent"] { --tag-color: var(--nv-accent); }
@@ -18,28 +18,28 @@
18
18
 
19
19
  @at-root {
20
20
  h1#{&} {
21
- font-size: 24px;
21
+ font-size: 1.5rem;
22
22
  }
23
23
 
24
24
  h2#{&} {
25
- font-size: 20px;
25
+ font-size: 1.25rem;
26
26
  }
27
27
 
28
28
  h3#{&} {
29
- font-size: 18px;
29
+ font-size: 1.125rem;
30
30
  }
31
31
 
32
32
  h4#{&} {
33
- font-size: 16px;
33
+ font-size: 1rem;
34
34
  }
35
35
 
36
36
  h5#{&} {
37
- font-size: 14px;
37
+ font-size: 0.875rem;
38
38
  font-weight: 500;
39
39
  }
40
40
 
41
41
  h6#{&} {
42
- font-size: 12px;
42
+ font-size: 0.75rem;
43
43
  }
44
44
  }
45
45
  }
@@ -1,4 +1,4 @@
1
- **Tree or Menu?** Tree picks an item in a list on the same page (layers, folders, outline). To take people to other pages, use [Menu](#/Components/Menu): its rows are links in a `<nav>`.
1
+ **Tree is a Menu that picks.** `<Tree />` and `<Menu kind="tree" />` are the same thing: rows to choose from on the page (layers, folders, an outline). For links or commands, use [Menu](#/Components/Menu) with links or actions: the same look, and screen readers hear each as what it is.
2
2
 
3
3
  A list of rows to pick from, nested like a layers panel. Click a row, or use the keyboard: Tab reaches the active row, ↑ ↓ move, → goes to a child row, ← to its parent, Enter or Space picks.
4
4
  ```jsx
package/src/css.ts CHANGED
@@ -6,8 +6,11 @@ import './components/ButtonGroup/ButtonGroup.scss';
6
6
  import './components/FullPageModal/FullPageModal.scss';
7
7
  import './components/HistoryList/HistoryList.scss';
8
8
  import './components/Layout/Layout.scss';
9
+ import './components/Stack/Stack.scss';
10
+ import './components/Grid/Grid.scss';
9
11
  import './components/Link/Link.scss';
10
12
  import './components/Icon/Icon.scss';
13
+ import './components/Loader/Loader.scss';
11
14
  import './components/Tree/Tree.scss';
12
15
  import './components/Menu/Menu.scss';
13
16
  import './components/Select/Select.scss';
package/src/dialog.ts ADDED
@@ -0,0 +1,47 @@
1
+ // Dialog rules shared by the React and the Respawn FullPageModal (no React
2
+ // here): what can take focus inside, Tab kept inside, Esc to close.
3
+
4
+ const FOCUSABLE = [
5
+ 'a[href]', 'area[href]', 'button:not([disabled])', 'input:not([disabled]):not([type="hidden"])',
6
+ 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', '[contenteditable="true"]', '[tabindex]',
7
+ ].join(',');
8
+
9
+ /** The elements Tab can reach inside `root`, in order (shown ones, not tabindex="-1"). */
10
+ export function focusables(root: HTMLElement): HTMLElement[] {
11
+ return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE))
12
+ .filter((el) => el.tabIndex >= 0 && el.getClientRects().length > 0);
13
+ }
14
+
15
+ /**
16
+ * The keys of a modal dialog (the WAI-ARIA dialog pattern): Tab and
17
+ * Shift+Tab go round the dialog's own controls and never leave it; Esc calls
18
+ * onClose. Returns true when it used the key.
19
+ */
20
+ export function dialogKeydown(event: KeyboardEvent, dialog: HTMLElement, onClose?: () => void): boolean {
21
+ if (event.key === 'Escape') {
22
+ if (!onClose) return false;
23
+ event.preventDefault();
24
+ onClose();
25
+ return true;
26
+ }
27
+ if (event.key !== 'Tab') return false;
28
+ const stops = focusables(dialog);
29
+ if (!stops.length) { event.preventDefault(); dialog.focus(); return true; }
30
+ const first = stops[0];
31
+ const last = stops[stops.length - 1];
32
+ const at = document.activeElement;
33
+ if (event.shiftKey && (at === first || at === dialog)) { event.preventDefault(); last.focus(); return true; }
34
+ if (!event.shiftKey && at === last) { event.preventDefault(); first.focus(); return true; }
35
+ return false;
36
+ }
37
+
38
+ /** Moves focus to the dialog itself once it shows (screen readers then say its name and "dialog"). */
39
+ export function focusDialog(dialog: HTMLElement): void {
40
+ const go = () => { if (dialog.isConnected) dialog.focus({ preventScroll: true }); };
41
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(go); else go();
42
+ }
43
+
44
+ /** Gives focus back to what had it before the dialog opened, if it is still on the page. */
45
+ export function restoreFocus(opener: Element | null): void {
46
+ if (opener && (opener as HTMLElement).focus && opener.isConnected) (opener as HTMLElement).focus({ preventScroll: true });
47
+ }
package/src/icons.ts CHANGED
@@ -15,6 +15,7 @@ const circle = (cx: number, cy: number, r: number): IconNode => ['circle', { cx,
15
15
  const rect = (x: number, y: number, width: number, height: number, rx = 2): IconNode => ['rect', { x, y, width, height, rx }];
16
16
  const ring = circle(12, 12, 9);
17
17
  const dot = (x: number, y: number) => path(`M${x} ${y}h.01`);
18
+ const bead = (x: number, y: number) => circle(x, y, 1); // a bigger dot: r 1 + the 2-unit line = 4 across
18
19
 
19
20
  const DEFS = {
20
21
  // Navigation
@@ -29,6 +30,12 @@ const DEFS = {
29
30
  'arrow-up': [path('M12 19V5M6 11l6-6 6 6')],
30
31
  'arrow-down': [path('M12 5v14M6 13l6 6 6-6')],
31
32
  'external-link': [path('M14 4h6v6M20 4l-9 9M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4')],
33
+ home: [path('M4 11l8-7 8 7v8a2 2 0 0 1-2 2h-3v-6H9v6H6a2 2 0 0 1-2-2z')],
34
+ 'panel-left': [rect(3, 4, 18, 16), path('M9 4v16')],
35
+ 'more-horizontal': [bead(5, 12), bead(12, 12), bead(19, 12)],
36
+ 'more-vertical': [bead(12, 5), bead(12, 12), bead(12, 19)],
37
+ maximize: [path('M14 4h6v6M10 20H4v-6M20 4l-6 6M4 20l6-6')],
38
+ minimize: [path('M4 14h6v6M20 10h-6V4M14 10l6-6M4 20l6-6')],
32
39
  // Actions
33
40
  add: [path('M12 5v14M5 12h14')],
34
41
  remove: [path('M5 12h14')],
@@ -43,6 +50,11 @@ const DEFS = {
43
50
  refresh: [path('M19 12a7 7 0 1 1-7-7'), path('M9.5 2.5L12 5l-2.5 2.5')],
44
51
  undo: [path('M9 14L4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11')],
45
52
  redo: [path('M15 14l5-5-5-5M20 9H9.5a5.5 5.5 0 0 0 0 11H13')],
53
+ settings: [path('M10.01 5.29L10.51 2.62L13.49 2.62L13.99 5.29L15.34 5.85L17.58 4.31L19.69 6.42L18.15 8.66L18.71 10.01L21.38 10.51L21.38 13.49L18.71 13.99L18.15 15.34L19.69 17.58L17.58 19.69L15.34 18.15L13.99 18.71L13.49 21.38L10.51 21.38L10.01 18.71L8.66 18.15L6.42 19.69L4.31 17.58L5.85 15.34L5.29 13.99L2.62 13.49L2.62 10.51L5.29 10.01L5.85 8.66L4.31 6.42L6.42 4.31L8.66 5.85z'), circle(12, 12, 3)],
54
+ share: [circle(18, 5, 2.5), circle(6, 12, 2.5), circle(18, 19, 2.5), path('M8.2 13.3l7.6 4.4M15.8 6.3l-7.6 4.4')],
55
+ play: [path('M7 4.5l12.5 7.5L7 19.5z')],
56
+ pause: [path('M8 5v14M16 5v14')],
57
+ 'sign-out': [path('M10 20H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h4M15 16l4-4-4-4M19 12H9')],
46
58
  // Status
47
59
  check: [path('M5 12.5l4.5 4.5L19 7.5')],
48
60
  info: [ring, path('M12 11v5'), dot(12, 8)],
@@ -58,10 +70,27 @@ const DEFS = {
58
70
  'eye-off': [path('M3 3l18 18'), path('M10.6 6.1A9.7 9.7 0 0 1 12 6c6.4 0 10 6 10 6a17 17 0 0 1-2.6 3.4M6.6 6.6C3.9 8.4 2 12 2 12s3.6 6 10 6a9.7 9.7 0 0 0 5.4-1.6'), path('M9.9 9.9a3 3 0 0 0 4.2 4.2')],
59
71
  lock: [rect(5, 11, 14, 10), path('M8 11V8a4 4 0 0 1 8 0v3')],
60
72
  unlock: [rect(5, 11, 14, 10), path('M8 11V8a4 4 0 0 1 7.75-1.4')],
73
+ user: [circle(12, 8, 4), path('M4 21a8 8 0 0 1 16 0')],
74
+ users: [circle(9, 8, 3.5), path('M2 20a7 7 0 0 1 14 0'), path('M15.5 4.6a3.5 3.5 0 0 1 0 6.8M18 13.6a7 7 0 0 1 4 6.4')],
75
+ mail: [rect(3, 5, 18, 14), path('M3 7.5l9 6 9-6')],
76
+ bell: [path('M18 16v-5a6 6 0 0 0-12 0v5l-2 2h16z'), path('M10 21a2 2 0 0 0 4 0')],
77
+ calendar: [rect(3, 5, 18, 16), path('M3 10h18M8 3v4M16 3v4')],
78
+ clock: [ring, path('M12 7v5l3 2')],
79
+ globe: [ring, path('M3 12h18'), path('M12 3c-2.5 2.5-3.8 5.5-3.8 9s1.3 6.5 3.8 9c2.5-2.5 3.8-5.5 3.8-9S14.5 5.5 12 3z')],
80
+ 'map-pin': [path('M12 21s-7-6-7-11.5a7 7 0 0 1 14 0C19 15 12 21 12 21z'), circle(12, 9.5, 2.5)],
81
+ tag: [path('M3 12V5a2 2 0 0 1 2-2h7l9 9-9 9z'), dot(8, 8)],
82
+ bookmark: [path('M6 5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16l-6-4-6 4z')],
83
+ star: [path('M12 3.3L14.47 9.4L21.04 9.86L15.99 14.1L17.58 20.49L12 17L6.42 20.49L8.01 14.1L2.96 9.86L9.53 9.4z')],
84
+ heart: [path('M12 20s-8-4.6-8-10.2A4.3 4.3 0 0 1 12 7.4a4.3 4.3 0 0 1 8 2.4C20 15.4 12 20 12 20z')],
85
+ grid: [rect(4, 4, 6, 6, 1), rect(14, 4, 6, 6, 1), rect(4, 14, 6, 6, 1), rect(14, 14, 6, 6, 1)],
86
+ list: [path('M9 6h11M9 12h11M9 18h11'), dot(4.5, 6), dot(4.5, 12), dot(4.5, 18)],
61
87
  link: [path('M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1'), path('M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1')],
62
88
  // Theme
63
89
  sun: [circle(12, 12, 4), path('M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41')],
64
90
  moon: [path('M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z')],
91
+ palette: [path('M12 3a9 9 0 0 0 0 18c1.1 0 1.6-.8 1.6-1.6 0-1-.9-1.4-.9-2.4 0-.9.7-1.5 1.6-1.5H16a5 5 0 0 0 5-5C21 6.4 17 3 12 3z'), dot(7.5, 11.5), dot(9.5, 7.5), dot(14.5, 7.5)],
92
+ sparkles: [path('M10 4l1.6 4.4L16 10l-4.4 1.6L10 16l-1.6-4.4L4 10l4.4-1.6z'), path('M18 14l.8 2.2L21 17l-2.2.8L18 20l-.8-2.2L15 17l2.2-.8z')],
93
+ zap: [path('M13 2.5L4.5 13.5H11l-1 8 8.5-11H12z')],
65
94
  // Code
66
95
  code: [path('M8 7l-5 5 5 5M16 7l5 5-5 5')],
67
96
  terminal: [path('M4 17l6-5-6-5M12 19h8')],
package/src/index.ts CHANGED
@@ -22,14 +22,22 @@ export { default as Progress } from './components/Progress/Progress';
22
22
  export type { ProgressProps, ProgressSize, ProgressStatus } from './components/Progress/Progress';
23
23
  export { default as Layout } from './components/Layout/Layout';
24
24
  export type { LayoutProps, Spacing, LegacySpacing } from './components/Layout/Layout';
25
+ export { default as Stack } from './components/Stack/Stack';
26
+ export type { StackProps, StackDirection } from './components/Stack/Stack';
27
+ export { default as Grid } from './components/Grid/Grid';
28
+ export type { GridProps, GridColumns } from './components/Grid/Grid';
29
+ export { BREAKPOINTS, isAtLeast } from './breakpoints';
30
+ export type { Breakpoint, Responsive } from './breakpoints';
25
31
  export { default as Icon } from './components/Icon/Icon';
26
32
  export type { IconProps } from './components/Icon/Icon';
27
33
  export { ICONS, ICON_NAMES } from './icons';
28
34
  export type { IconName, IconNode } from './icons';
35
+ export { default as Loader } from './components/Loader/Loader';
36
+ export type { LoaderProps } from './components/Loader/Loader';
29
37
  export { default as Tree } from './components/Tree/Tree';
30
38
  export type { TreeProps, TreeItem } from './components/Tree/Tree';
31
39
  export { default as Menu } from './components/Menu/Menu';
32
- export type { MenuProps, MenuItem, MenuSection } from './components/Menu/Menu';
40
+ export type { MenuProps, MenuListProps, MenuTreeProps, MenuItem, MenuSection, MenuKind } from './components/Menu/Menu';
33
41
  export { default as Select } from './components/Select/Select';
34
42
  export type { SelectProps, SelectOption, SelectOptionState } from './components/Select/Select';
35
43
  export { default as FullPageModal } from './components/FullPageModal/FullPageModal';
package/src/loader.ts ADDED
@@ -0,0 +1,43 @@
1
+ // Loader's drawing, shared by the React and the Respawn Loader (no React here).
2
+ import { LOGO_INNER, LOGO_OUTER, LogoSegment } from './logo';
3
+
4
+ export { LOGO_VIEWBOX } from './logo';
5
+
6
+ const hex = (h: string) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));
7
+ /** The middle of a segment's gradient: its one color when there are no gradients. */
8
+ const middle = (from: string, to: string) => `#${hex(from).map((v, i) => Math.round((v + hex(to)[i]) / 2).toString(16).padStart(2, '0')).join('')}`;
9
+
10
+ export interface LoaderSegment {
11
+ d: string;
12
+ /** "url(#<id>-<n>)" with gradients, else one color. */
13
+ fill: string;
14
+ /** Where it sits round the ring, 0 to 1 from the top, clockwise: the pulse reaches it then. */
15
+ angle: number;
16
+ }
17
+
18
+ export interface LoaderGradient {
19
+ id: string;
20
+ x1: number; y1: number; x2: number; y2: number;
21
+ from: string; to: string;
22
+ }
23
+
24
+ /**
25
+ * The two rings' segments. With an `id`, each segment is filled with its own
26
+ * gradient (ids "<id>-0", "<id>-1"…), as in the logo; without one, with its
27
+ * gradient's middle color, so a page can show any number of loaders with no
28
+ * ids at all. They look the same up to about 64 pixels.
29
+ */
30
+ export function loaderRings(id?: string): { inner: LoaderSegment[]; outer: LoaderSegment[]; gradients: LoaderGradient[] } {
31
+ const gradients: LoaderGradient[] = [];
32
+ let n = 0;
33
+ const seg = ([d, from, to, [x1, y1, x2, y2], angle]: LogoSegment): LoaderSegment => {
34
+ if (!id) return { d, fill: middle(from, to), angle };
35
+ const gid = `${id}-${n}`;
36
+ n += 1;
37
+ gradients.push({ id: gid, x1, y1, x2, y2, from, to });
38
+ return { d, fill: `url(#${gid})`, angle };
39
+ };
40
+ const inner = LOGO_INNER.map(seg);
41
+ const outer = LOGO_OUTER.map(seg);
42
+ return { inner, outer, gradients };
43
+ }
package/src/logo.ts ADDED
@@ -0,0 +1,12 @@
1
+ // GENERATED from docs/public/nurvus-logo.svg (via docs/src/components/logoData.js) by
2
+ // tools/build-logo.mjs. The NURVUS mark, for Loader: two rings of segments.
3
+ // Each segment: [path, gradient from, gradient to, [x1, y1, x2, y2] of the gradient, angle round the ring (0 at the top, 0..1 clockwise)].
4
+
5
+ export type LogoSegment = [d: string, from: string, to: string, line: [number, number, number, number], angle: number];
6
+
7
+ /** The artwork's viewBox around the mark alone. */
8
+ export const LOGO_VIEWBOX = '492 149 540 540';
9
+
10
+ export const LOGO_INNER: LogoSegment[] = [["M696 237 C670 244 639 264 620 298 C605 320 607 335 615 342 C632 336 647 329 661 309 C675 293 689 286 705 279 C696 266 693 251 696 237 Z","#141934","#244f70",[707,229,619,338],0.894],["M705 229 C718 222 734 218 746 221 C763 242 785 257 806 267 C776 271 750 285 727 274 C709 266 701 249 705 229 Z","#20174e","#344eaa",[744,221,760,277],0.981],["M787 232 C838 231 894 267 922 305 C932 318 928 328 915 340 C906 348 896 348 891 336 C874 293 845 257 787 232 Z","#453be8","#6284e7",[785,234,915,343],0.12],["M896 343 C901 347 907 347 912 344 C915 358 934 373 943 390 C957 439 942 490 905 532 C924 500 932 461 923 433 C913 409 899 391 896 371 Z","#6686e7","#4cbaf5",[907,344,928,529],0.239],["M725 557 C677 541 639 512 649 469 C653 447 642 434 627 435 C611 436 605 448 610 476 C619 521 665 550 723 562 Z","#30c3b6","#42e2c9",[612,444,708,560],0.658],["M655 575 C622 552 613 527 608 499 C605 482 596 473 585 477 C570 482 573 498 585 518 C601 546 627 563 655 575 Z","#64dfdf","#259cea",[584,479,651,575],0.657],["M680 580 C684 567 708 568 718 576 C731 587 720 599 704 597 C690 596 680 588 680 580 Z","#5ebee8","#4367e8",[697,571,707,597],0.557],["M807 547 C783 550 770 545 752 551 C733 557 727 570 736 581 C746 594 769 592 781 580 C789 571 798 557 807 547 Z","#50ded1","#26a6d8",[744,548,786,589],0.491],["M797 572 C839 550 852 527 860 497 C865 476 878 466 891 472 C912 481 905 505 889 525 C864 552 835 567 797 572 Z","#3c7de7","#20c9e8",[887,471,819,571],0.376],["M755 210 C758 194 785 193 795 206 C805 218 789 227 775 226 C761 225 753 219 755 210 Z","#d5f3f3","#c8b5eb",[761,202,792,225],0.009],["M932 334 C945 326 960 344 964 359 C969 378 951 385 940 370 C930 357 926 341 932 334 Z","#e5b5e9","#92b0f2",[937,336,959,378],0.195]];
11
+
12
+ export const LOGO_OUTER: LogoSegment[] = [["M557 294 C587 234 662 173 718 162 C734 163 744 182 736 198 C725 224 680 231 645 242 C609 253 581 278 568 292 C565 295 561 295 557 294 Z","#78e8de","#5471ee",[600,165,654,300],0.906],["M534 283 C547 307 583 305 609 289 L639 270 C613 302 604 343 601 383 C599 420 606 454 595 464 C577 476 545 443 533 418 C513 379 515 313 534 283 Z","#79e8df","#4664ee",[521,300,625,432],0.798],["M506 382 C509 421 529 452 551 469 C551 526 592 577 659 598 C697 610 699 639 669 655 C579 619 511 540 504 449 C502 420 503 399 506 382 Z","#59cbe9","#5141e9",[508,401,650,654],0.681],["M687 657 L697 646 C736 653 781 641 814 620 L733 625 C787 599 833 572 890 577 C902 578 902 594 894 605 C850 655 771 684 687 657 Z","#3333df","#12a9e7",[750,649,890,566],0.472],["M970 394 C1000 460 989 531 951 580 C937 598 922 610 913 610 C889 583 919 553 942 526 C972 490 983 444 970 394 Z","#82f6dc","#2296d9",[979,419,914,610],0.329],["M975 341 C970 333 988 322 996 327 C1000 329 1002 335 1005 344 C1024 397 1019 449 1000 499 C1012 442 1009 392 975 341 Z","#923ce9","#ed80df",[985,334,1013,493],0.22],["M744 167 C829 154 920 205 974 277 C987 295 979 315 966 322 C947 332 921 316 922 279 C880 207 807 176 744 167 Z","#fff9ef","#ee74b8",[755,167,958,308],0.105]];