@nurvus/ui 0.1.0-alpha.11 → 0.1.0-alpha.13

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 (135) hide show
  1. package/README.md +20 -9
  2. package/dist/index.js +1 -1
  3. package/dist/nurvus.css +15 -0
  4. package/dist/respawn.js +2 -0
  5. package/dist/respawn.js.LICENSE.txt +5 -0
  6. package/dist/theme.js +1 -0
  7. package/dist/themes/all.css +231 -0
  8. package/dist/themes/apollo-white.css +33 -0
  9. package/dist/themes/apollo-white.json +52 -0
  10. package/dist/themes/arcane.css +33 -0
  11. package/dist/themes/arcane.json +52 -0
  12. package/dist/themes/dopamine.css +33 -0
  13. package/dist/themes/dopamine.json +52 -0
  14. package/dist/themes/nether-neon.css +33 -0
  15. package/dist/themes/nether-neon.json +52 -0
  16. package/dist/themes/nether.css +33 -0
  17. package/dist/themes/nether.json +52 -0
  18. package/dist/themes/outworld.css +33 -0
  19. package/dist/themes/outworld.json +52 -0
  20. package/dist/themes/roles.json +29 -0
  21. package/dist/themes/tokyo-neon.css +33 -0
  22. package/dist/themes/tokyo-neon.json +52 -0
  23. package/dist/types/components/Button/Button.d.ts +19 -0
  24. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +12 -0
  25. package/dist/types/components/FullPageModal/FullPageModal.d.ts +15 -0
  26. package/dist/types/components/HistoryList/HistoryList.d.ts +40 -0
  27. package/dist/types/components/Layout/Layout.d.ts +27 -0
  28. package/dist/types/components/Link/Link.d.ts +9 -0
  29. package/dist/types/components/Menu/Menu.d.ts +35 -0
  30. package/dist/types/components/NavList/NavList.d.ts +43 -0
  31. package/dist/types/components/Panel/Panel.d.ts +19 -0
  32. package/dist/types/components/Progress/Progress.d.ts +15 -0
  33. package/dist/types/components/Table/Table.d.ts +25 -0
  34. package/dist/types/components/Tag/Tag.d.ts +15 -0
  35. package/dist/types/components/Text/Text.d.ts +28 -0
  36. package/dist/types/components/Title/Title.d.ts +288 -0
  37. package/dist/types/constants.d.ts +5 -0
  38. package/dist/types/index.d.ts +32 -0
  39. package/dist/types/navList.d.ts +7 -0
  40. package/dist/types/respawn/Button.d.ts +16 -0
  41. package/dist/types/respawn/ButtonGroup.d.ts +8 -0
  42. package/dist/types/respawn/FullPageModal.d.ts +32 -0
  43. package/dist/types/respawn/HistoryList.d.ts +36 -0
  44. package/dist/types/respawn/Layout.d.ts +22 -0
  45. package/dist/types/respawn/Link.d.ts +12 -0
  46. package/dist/types/respawn/Menu.d.ts +33 -0
  47. package/dist/types/respawn/NavList.d.ts +43 -0
  48. package/dist/types/respawn/Panel.d.ts +15 -0
  49. package/dist/types/respawn/Progress.d.ts +15 -0
  50. package/dist/types/respawn/Table.d.ts +22 -0
  51. package/dist/types/respawn/Tag.d.ts +11 -0
  52. package/dist/types/respawn/Text.d.ts +19 -0
  53. package/dist/types/respawn/Title.d.ts +14 -0
  54. package/dist/types/respawn/index.d.ts +35 -0
  55. package/dist/types/respawn/spawn.d.ts +50 -0
  56. package/dist/types/respawn/update.d.ts +13 -0
  57. package/dist/types/spacing.d.ts +8 -0
  58. package/dist/types/theme.d.ts +32 -0
  59. package/dist/types/themes/index.d.ts +45 -0
  60. package/package.json +40 -12
  61. package/src/components/Button/Button.md +5 -5
  62. package/src/components/Button/Button.tsx +44 -0
  63. package/src/components/ButtonGroup/ButtonGroup.tsx +23 -0
  64. package/src/components/FullPageModal/FullPageModal.scss +9 -5
  65. package/src/components/FullPageModal/FullPageModal.tsx +74 -0
  66. package/src/components/HistoryList/{HistoryList.jsx → HistoryList.tsx} +45 -58
  67. package/src/components/Layout/Layout.md +4 -4
  68. package/src/components/Layout/Layout.scss +14 -47
  69. package/src/components/Layout/Layout.tsx +56 -0
  70. package/src/components/Link/Link.scss +9 -9
  71. package/src/components/Link/Link.tsx +23 -0
  72. package/src/components/Menu/Menu.tsx +90 -0
  73. package/src/components/NavList/NavList.md +39 -0
  74. package/src/components/NavList/NavList.scss +149 -0
  75. package/src/components/NavList/NavList.tsx +129 -0
  76. package/src/components/Panel/{Panel.jsx → Panel.tsx} +17 -26
  77. package/src/components/Progress/Progress.md +5 -5
  78. package/src/components/Progress/Progress.tsx +36 -0
  79. package/src/components/Table/Table.tsx +59 -0
  80. package/src/components/Tag/{Tag.jsx → Tag.tsx} +13 -18
  81. package/src/components/Text/Text.md +13 -0
  82. package/src/components/Text/Text.scss +6 -0
  83. package/src/components/Text/Text.tsx +54 -0
  84. package/src/components/Title/Title.tsx +42 -0
  85. package/src/constants.ts +6 -0
  86. package/src/css.ts +17 -0
  87. package/src/global.d.ts +3 -0
  88. package/src/index.ts +42 -0
  89. package/src/navList.ts +9 -0
  90. package/src/respawn/Button.ts +31 -0
  91. package/src/respawn/ButtonGroup.ts +19 -0
  92. package/src/respawn/FullPageModal.ts +125 -0
  93. package/src/respawn/HistoryList.ts +100 -0
  94. package/src/respawn/Layout.ts +44 -0
  95. package/src/respawn/Link.ts +24 -0
  96. package/src/respawn/Menu.ts +86 -0
  97. package/src/respawn/NavList.ts +126 -0
  98. package/src/respawn/Panel.ts +36 -0
  99. package/src/respawn/Progress.ts +29 -0
  100. package/src/respawn/Table.ts +54 -0
  101. package/src/respawn/Tag.ts +25 -0
  102. package/src/respawn/Text.ts +35 -0
  103. package/src/respawn/Title.ts +30 -0
  104. package/src/respawn/index.ts +59 -0
  105. package/src/respawn/spawn.ts +155 -0
  106. package/src/respawn/update.ts +49 -0
  107. package/src/spacing.ts +23 -0
  108. package/src/styles/theme.scss +6 -197
  109. package/src/styles/type.json +35 -5
  110. package/src/theme.ts +92 -0
  111. package/src/themes/css/all.css +231 -0
  112. package/src/themes/css/apollo-white.css +33 -0
  113. package/src/themes/css/arcane.css +33 -0
  114. package/src/themes/css/dopamine.css +33 -0
  115. package/src/themes/css/nether-neon.css +33 -0
  116. package/src/themes/css/nether.css +33 -0
  117. package/src/themes/css/outworld.css +33 -0
  118. package/src/themes/css/tokyo-neon.css +33 -0
  119. package/src/themes/index.ts +61 -0
  120. package/src/themes/roles.json +1 -1
  121. package/src/app.js +0 -29
  122. package/src/components/Button/Button.jsx +0 -59
  123. package/src/components/ButtonGroup/ButtonGroup.jsx +0 -28
  124. package/src/components/FullPageModal/FullPageModal.jsx +0 -106
  125. package/src/components/Layout/Layout.jsx +0 -68
  126. package/src/components/Link/Link.jsx +0 -39
  127. package/src/components/Menu/Menu.jsx +0 -120
  128. package/src/components/Progress/Progress.jsx +0 -56
  129. package/src/components/Table/Table.jsx +0 -94
  130. package/src/components/Text/Text.jsx +0 -54
  131. package/src/components/Title/Title.jsx +0 -48
  132. package/src/constants.js +0 -3
  133. package/src/index.js +0 -20
  134. package/src/theme.js +0 -64
  135. package/src/themes/index.js +0 -22
@@ -0,0 +1,33 @@
1
+ /* GENERATED by tools/build-tokens.js from src/themes/*.json. Do not edit. */
2
+ /* Nether Neon: Deep. Wired. Electric. (dark, demo) */
3
+ [data-theme="nether-neon"] {
4
+ color-scheme: dark;
5
+ --nv-theme-id: nether-neon;
6
+ --nv-bg: #0B0C10;
7
+ --nv-bg-alt: #0F1015;
8
+ --nv-bg-deep: #08090C;
9
+ --nv-surface: #17181F;
10
+ --nv-surface-hover: #1F2129;
11
+ --nv-border: #22242D;
12
+ --nv-border-strong: #5E6272;
13
+ --nv-text: #E7E9EE;
14
+ --nv-text-muted: #B4B8C4;
15
+ --nv-text-subtle: #8B90A0;
16
+ --nv-accent: #8A89FA;
17
+ --nv-accent-fill: #504FF6;
18
+ --nv-on-accent: #FFFFFF;
19
+ --nv-accent-soft: rgba(110, 109, 248, 0.16);
20
+ --nv-selection: #26264A;
21
+ --nv-cursor: #00F5FF;
22
+ --nv-success: #5FD08A;
23
+ --nv-warning: #F5B83D;
24
+ --nv-danger: #FF6B6B;
25
+ --nv-info: #00D5FF;
26
+ --nv-syntax-comment: #8B90A0;
27
+ --nv-syntax-keyword: #BB9AF7;
28
+ --nv-syntax-function: #00D5FF;
29
+ --nv-syntax-tag: #FF4FD8;
30
+ --nv-syntax-attr: #FF9E64;
31
+ --nv-syntax-string: #9ECE6A;
32
+ --nv-syntax-number: #FF9E64;
33
+ }
@@ -0,0 +1,33 @@
1
+ /* GENERATED by tools/build-tokens.js from src/themes/*.json. Do not edit. */
2
+ /* Nether: Deep. Silent. Absolute. (dark, demo) */
3
+ [data-theme="nether"] {
4
+ color-scheme: dark;
5
+ --nv-theme-id: nether;
6
+ --nv-bg: #0B0C10;
7
+ --nv-bg-alt: #0F1015;
8
+ --nv-bg-deep: #08090C;
9
+ --nv-surface: #17181F;
10
+ --nv-surface-hover: #1F2129;
11
+ --nv-border: #22242D;
12
+ --nv-border-strong: #5E6272;
13
+ --nv-text: #E7E9EE;
14
+ --nv-text-muted: #B4B8C4;
15
+ --nv-text-subtle: #8B90A0;
16
+ --nv-accent: #8A89FA;
17
+ --nv-accent-fill: #504FF6;
18
+ --nv-on-accent: #FFFFFF;
19
+ --nv-accent-soft: rgba(110, 109, 248, 0.16);
20
+ --nv-selection: #26264A;
21
+ --nv-cursor: #8A89FA;
22
+ --nv-success: #5FD08A;
23
+ --nv-warning: #F5B83D;
24
+ --nv-danger: #FF6B6B;
25
+ --nv-info: #8A89FA;
26
+ --nv-syntax-comment: #8B90A0;
27
+ --nv-syntax-keyword: #A5A4FB;
28
+ --nv-syntax-function: #F5F6F8;
29
+ --nv-syntax-tag: #8A89FA;
30
+ --nv-syntax-attr: #C9CCD6;
31
+ --nv-syntax-string: #B4B8C4;
32
+ --nv-syntax-number: #F5B83D;
33
+ }
@@ -0,0 +1,33 @@
1
+ /* GENERATED by tools/build-tokens.js from src/themes/*.json. Do not edit. */
2
+ /* Outworld: Alien. Molten. Untamed. (dark, demo) */
3
+ [data-theme="outworld"] {
4
+ color-scheme: dark;
5
+ --nv-theme-id: outworld;
6
+ --nv-bg: #1A1020;
7
+ --nv-bg-alt: #140C19;
8
+ --nv-bg-deep: #0F0913;
9
+ --nv-surface: #24172A;
10
+ --nv-surface-hover: #2E1E35;
11
+ --nv-border: #38253F;
12
+ --nv-border-strong: #7D6385;
13
+ --nv-text: #F3E6E0;
14
+ --nv-text-muted: #CDB7BD;
15
+ --nv-text-subtle: #9C8496;
16
+ --nv-accent: #FF8A3D;
17
+ --nv-accent-fill: #FF8A3D;
18
+ --nv-on-accent: #1A1020;
19
+ --nv-accent-soft: rgba(255, 138, 61, 0.14);
20
+ --nv-selection: #3E2442;
21
+ --nv-cursor: #FFB35C;
22
+ --nv-success: #9BE564;
23
+ --nv-warning: #FFC857;
24
+ --nv-danger: #FF5470;
25
+ --nv-info: #C792EA;
26
+ --nv-syntax-comment: #A08A99;
27
+ --nv-syntax-keyword: #C792EA;
28
+ --nv-syntax-function: #FFB35C;
29
+ --nv-syntax-tag: #FF6B5B;
30
+ --nv-syntax-attr: #FFC857;
31
+ --nv-syntax-string: #9BE564;
32
+ --nv-syntax-number: #FF8A3D;
33
+ }
@@ -0,0 +1,33 @@
1
+ /* GENERATED by tools/build-tokens.js from src/themes/*.json. Do not edit. */
2
+ /* Tokyo Neon: Electric. Immersive. Futuristic. (dark, demo) */
3
+ [data-theme="tokyo-neon"] {
4
+ color-scheme: dark;
5
+ --nv-theme-id: tokyo-neon;
6
+ --nv-bg: #141625;
7
+ --nv-bg-alt: #10111F;
8
+ --nv-bg-deep: #0C0D18;
9
+ --nv-surface: #191B2E;
10
+ --nv-surface-hover: #21243B;
11
+ --nv-border: #262A45;
12
+ --nv-border-strong: #5D6488;
13
+ --nv-text: #D6DEFF;
14
+ --nv-text-muted: #A9B1D6;
15
+ --nv-text-subtle: #6B728E;
16
+ --nv-accent: #8A89FA;
17
+ --nv-accent-fill: #504FF6;
18
+ --nv-on-accent: #FFFFFF;
19
+ --nv-accent-soft: rgba(110, 109, 248, 0.16);
20
+ --nv-selection: #2A2E52;
21
+ --nv-cursor: #00F5FF;
22
+ --nv-success: #9ECE6A;
23
+ --nv-warning: #E0AF68;
24
+ --nv-danger: #FF5C8A;
25
+ --nv-info: #7AA2F7;
26
+ --nv-syntax-comment: #8A92B2;
27
+ --nv-syntax-keyword: #BB9AF7;
28
+ --nv-syntax-function: #00D5FF;
29
+ --nv-syntax-tag: #FF4FD8;
30
+ --nv-syntax-attr: #FF9E64;
31
+ --nv-syntax-string: #9ECE6A;
32
+ --nv-syntax-number: #FF9E64;
33
+ }
@@ -0,0 +1,61 @@
1
+ // The NURVUS themes. Each one is a complete, standalone palette: every role
2
+ // token has a value, and no theme inherits from another. Add a theme by adding
3
+ // a JSON file here (see roles.json for what each token is for) and listing it
4
+ // below; tools/build-tokens.js turns them into [data-theme="<id>"] CSS.
5
+ import apolloWhite from './apollo-white.json';
6
+ import dopamine from './dopamine.json';
7
+ import tokyoNeon from './tokyo-neon.json';
8
+ import nether from './nether.json';
9
+ import netherNeon from './nether-neon.json';
10
+ import outworld from './outworld.json';
11
+ import arcane from './arcane.json';
12
+ import rolesJson from './roles.json';
13
+
14
+ /** One of the 27 color roles every theme defines, e.g. 'bg', 'text', 'accent'. */
15
+ export type ThemeRole =
16
+ | 'bg' | 'bg-alt' | 'bg-deep' | 'surface' | 'surface-hover' | 'border' | 'border-strong'
17
+ | 'text' | 'text-muted' | 'text-subtle' | 'accent' | 'accent-fill' | 'accent-soft' | 'on-accent'
18
+ | 'success' | 'warning' | 'danger' | 'info' | 'cursor' | 'selection'
19
+ | 'syntax-keyword' | 'syntax-string' | 'syntax-function' | 'syntax-number' | 'syntax-comment'
20
+ | 'syntax-tag' | 'syntax-attr';
21
+
22
+ /** A theme, as in src/themes/<id>.json. */
23
+ export interface Theme {
24
+ /** Used in data-theme and setTheme, e.g. 'tokyo-neon'. */
25
+ id: string;
26
+ /** Display name, e.g. 'Tokyo Neon'. */
27
+ name: string;
28
+ mode: 'light' | 'dark';
29
+ /** 'demo' themes warn on a contrast failure; 'stable' ones fail the build. */
30
+ status: 'demo' | 'stable';
31
+ /** Position in menus (light themes first). */
32
+ order: number;
33
+ keywords: string;
34
+ summary: string;
35
+ description: string;
36
+ bestFor: string;
37
+ /** Which roles the theme's showcase card uses. */
38
+ showcase: { label: string; title: string; tagline: string; swatches: string[] };
39
+ /** Every role's color (hex). */
40
+ colors: Record<ThemeRole, string>;
41
+ }
42
+
43
+ /** What a role is for, and which roles it must contrast with. */
44
+ export interface ThemeRoleInfo {
45
+ /** Which group the role belongs to, e.g. "Text". */
46
+ group: string;
47
+ /** What the role is for. */
48
+ use: string;
49
+ /** Contrast it must meet against other roles. */
50
+ check?: { against: ThemeRole[]; min: number };
51
+ }
52
+
53
+ /** All themes, in display order (light first). */
54
+ export const themes: Theme[] = ([apolloWhite, dopamine, tokyoNeon, nether, netherNeon, outworld, arcane] as Theme[])
55
+ .sort((a, b) => a.order - b.order);
56
+
57
+ /** The theme a page gets with no data-theme attribute at all. */
58
+ export const DEFAULT_THEME = 'apollo-white';
59
+
60
+ /** What each role token is for, and the contrast it must meet. */
61
+ export const roles: Record<ThemeRole, ThemeRoleInfo> = rolesJson as Record<ThemeRole, ThemeRoleInfo>;
@@ -8,7 +8,7 @@
8
8
  "border-strong": { "group": "Surfaces", "use": "Edges that define a control, like an input box.", "check": { "against": ["bg"], "min": 3 } },
9
9
  "text": { "group": "Text", "use": "Body copy and headings.", "check": { "against": ["bg", "surface"], "min": 4.5 } },
10
10
  "text-muted": { "group": "Text", "use": "Secondary text: labels, captions, meta.", "check": { "against": ["bg", "surface"], "min": 4.5 } },
11
- "text-subtle": { "group": "Text", "use": "Placeholders, disabled and hints. Never for anything the reader must read.", "check": { "against": ["bg"], "min": 3 } },
11
+ "text-subtle": { "group": "Text", "use": "Disabled controls, large text and decoration. Not for text people need to read: WCAG asks 4.5:1 for normal-size text, and this role only has to reach 3:1.", "check": { "against": ["bg"], "min": 3 } },
12
12
  "accent": { "group": "Accent", "use": "Links, focus rings, active marks and icons.", "check": { "against": ["bg", "surface"], "min": 4.5 } },
13
13
  "accent-fill": { "group": "Accent", "use": "Solid fill of primary buttons and active pills.", "check": { "against": ["bg"], "min": 3 } },
14
14
  "on-accent": { "group": "Accent", "use": "Text and icons on accent-fill.", "check": { "against": ["accent-fill"], "min": 4.5 } },
package/src/app.js DELETED
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import Button from './components/Button.jsx';
4
- import Progress from './components/Progress/Progress.jsx';
5
- import './index.scss';
6
-
7
- class App extends React.Component {
8
- render() {
9
- return (
10
- <div>
11
- asdsadaszzz asdsad
12
- <Button>
13
- Button 1
14
- </Button>
15
- <Button>
16
- Button 2
17
- </Button>
18
- <Progress>
19
- P
20
- </Progress>
21
- </div>
22
- );
23
- }
24
- }
25
-
26
- ReactDOM.render(
27
- <App />,
28
- document.body
29
- );
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import PropTypes from 'prop-types';
4
- import CONSTANT from '../../constants.js';
5
- import './Button.scss';
6
-
7
- /**
8
- * Button component.
9
- * @returns {ReactElement} of Button component.
10
- */
11
- const Button = React.forwardRef(function Button({
12
- className,
13
- children,
14
- size = 'medium',
15
- type = 'primary',
16
- ...restProps
17
- }, ref) {
18
- return (
19
- <button
20
- className={ classNames(className, 'button', CONSTANT.CLASS_PREFIX) }
21
- data-size={ size }
22
- data-type={ type }
23
- ref={ ref }
24
- { ...restProps }
25
- >
26
- { children }
27
- </button>
28
- );
29
- });
30
-
31
- Button.propTypes = {
32
- /**
33
- * Custom class name.
34
- */
35
- className: PropTypes.string,
36
- /**
37
- * Content to render inside button.
38
- */
39
- children: PropTypes.node,
40
- /**
41
- * Size of button.
42
- */
43
- size: PropTypes.oneOf([
44
- 'extra-large',
45
- 'large',
46
- 'medium',
47
- 'small',
48
- 'mini'
49
- ]),
50
- /**
51
- * Size of button.
52
- */
53
- type: PropTypes.oneOf([
54
- 'primary',
55
- 'secondary'
56
- ])
57
- };
58
-
59
- export default Button;
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import CONSTANT from '../../constants.js';
5
- import './ButtonGroup.scss';
6
-
7
- /**
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>`.
10
- */
11
- export default function ButtonGroup({ className, ...restProps }) {
12
- return (
13
- <div
14
- className={ classNames(className, 'button-group', CONSTANT.CLASS_PREFIX) }
15
- { ...restProps } />
16
- );
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
- };
@@ -1,106 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { PropTypes } from 'prop-types';
4
- import CONSTANT from '../../constants.js';
5
- import Layout from '../Layout/Layout.jsx';
6
- import Title from '../Title/Title.jsx';
7
- import './FullPageModal.scss';
8
-
9
- /**
10
- * The FullPageModal shows additonal content overlayed on the screen.
11
- */
12
- function FullPageModal({
13
- children,
14
- headerActions,
15
- title,
16
- visible = false,
17
- ...restProps
18
- }) {
19
- function getAnimationState() {
20
- if (visible) {
21
- return 'reveal-in';
22
- }
23
-
24
- return 'reveal-out';
25
- }
26
-
27
- const [animationState, setAnimationState] = useState('');
28
- const [isVisible, setIsVisible] = useState(visible);
29
-
30
- // Clear animation and sync visibility states
31
- function clearAnimation() {
32
- if (animationState) {
33
- if (visible !== isVisible) {
34
- setIsVisible(visible);
35
- setAnimationState('');
36
- }
37
- }
38
- }
39
-
40
- // Trigger animation when visibility changes
41
- useEffect(() => {
42
- if (visible !== isVisible) {
43
- const animState = getAnimationState();
44
- setAnimationState(animState);
45
- }
46
-
47
- if (visible && !animationState) {
48
- setIsVisible(visible);
49
- }
50
- }, [visible]);
51
-
52
- const modalMask = isVisible ? <div className="mask" data-animate={ animationState } /> : null;
53
-
54
- const modalEl = (
55
- <div className={ `portal ${CONSTANT.CLASS_PREFIX}` } data-visible={ visible }>
56
- { modalMask }
57
- <div
58
- className={ `modal ${CONSTANT.CLASS_PREFIX}` }
59
- data-visible={ isVisible }
60
- data-animate={ animationState }
61
- onAnimationEnd={ clearAnimation }
62
- { ...restProps }
63
- >
64
- <div className="header">
65
- <Layout display="flex" alignItems="center" justifyContent="space-between">
66
- <Title>
67
- { title }
68
- </Title>
69
- <div className="header-actions">
70
- { headerActions }
71
- </div>
72
- </Layout>
73
- </div>
74
- { children }
75
- </div>
76
- </div>
77
- );
78
-
79
- // Note: Using Fragment for JS-DOCS to read prop-types
80
- return (
81
- <React.Fragment>
82
- { ReactDOM.createPortal(modalEl, document.body) }
83
- </React.Fragment>
84
- );
85
- }
86
-
87
- FullPageModal.propTypes = {
88
- /**
89
- * Custom class name.
90
- */
91
- className: PropTypes.string,
92
- /**
93
- * Title of Modal
94
- */
95
- title: PropTypes.node,
96
- /**
97
- * Header actions of Modal
98
- */
99
- headerActions: PropTypes.node,
100
- /**
101
- * Visibility of Modal
102
- */
103
- visible: PropTypes.bool
104
- };
105
-
106
- export default FullPageModal;
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import CONSTANT from '../../constants.js';
5
- import './Layout.scss';
6
-
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
- }) {
21
- return (
22
- <div
23
- className={ classNames(className, 'layout', CONSTANT.CLASS_PREFIX) }
24
- data-align-items={ alignItems }
25
- data-display={ display }
26
- data-flex-direction={ flexDirection }
27
- data-item-display={ itemDisplay }
28
- data-item-spacing={ itemSpacing }
29
- data-justify-content={ justifyContent }
30
- { ...restProps }
31
- />
32
- );
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
- };
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import CONSTANT from '../../constants.js';
5
- import './Link.scss';
6
-
7
- /**
8
- * Link component.
9
- * @returns {ReactElement} of Link component.
10
- */
11
- function Link(props) {
12
- const {
13
- children,
14
- className,
15
- ...restProps
16
- } = props;
17
-
18
- return (
19
- <a
20
- className={ classNames(className, 'link', CONSTANT.CLASS_PREFIX) }
21
- { ...restProps }
22
- >
23
- { children }
24
- </a>
25
- );
26
- }
27
-
28
- Link.propTypes = {
29
- /**
30
- * Custom class name.
31
- */
32
- className: PropTypes.string,
33
- /**
34
- * Content to render.
35
- */
36
- children: PropTypes.node
37
- };
38
-
39
- export default Link;
@@ -1,120 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import CONSTANT from '../../constants.js';
5
- import './Menu.scss';
6
-
7
- /**
8
- * Menu component.
9
- * @returns {ReactElement} of Menu component.
10
- */
11
- class Menu extends React.Component {
12
-
13
- handleClick = (e, path) => {
14
- e.stopPropagation();
15
- if (this.props.onClick) {
16
- this.props.onClick(e, path);
17
- }
18
- }
19
-
20
- isActiveItem(path, currentIndex) {
21
- return path.length && path.length === 1 && path[0] === currentIndex;
22
- }
23
-
24
- renderItems(items, activePath=[], path = []) {
25
- const { itemRenderer } = this.props;
26
-
27
- if (items) {
28
- return items.map((item, i) => {
29
- const { className, label, style } = item;
30
- const type = path.length > 1 ? 'group' : '';
31
- const isActive = this.isActiveItem(activePath, i);
32
- const [ first, ...remainingPath ] = activePath;
33
- const nextPath = [...path, i];
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);
37
-
38
- let itemChildren;
39
- if (itemRenderer) {
40
- itemChildren = itemRenderer(item);
41
- } else {
42
- itemChildren = label;
43
- }
44
-
45
- return (
46
- <React.Fragment key={ i }>
47
- <div
48
- className={ classNames(className, 'menu-item', CONSTANT.CLASS_PREFIX) }
49
- data-active={ isActive }
50
- data-type={ type }
51
- onClick={ e => this.handleClick(e, nextPath) }
52
- style={ {
53
- '--nurvus-menu-depth': String(depth),
54
- ...style
55
- } }
56
- >
57
- { itemChildren }
58
- </div>
59
- { this.renderItems(item.items, first === i ? remainingPath : [], nextPath) }
60
-
61
- </React.Fragment>
62
- );
63
- });
64
- }
65
-
66
- return null;
67
- }
68
-
69
-
70
- render() {
71
- const { activePath, className, children, itemRenderer, items, maxIndentDepth, ...props } = this.props;
72
-
73
- return (
74
- <div
75
- className={ classNames(className, 'menu', CONSTANT.CLASS_PREFIX) }
76
- { ...props }
77
- >
78
- { this.renderItems(items, activePath) }
79
- </div>
80
- );
81
- }
82
- }
83
-
84
- Menu.propTypes = {
85
- /**
86
- * Active menu item path.
87
- */
88
- activePath: PropTypes.array,
89
- /**
90
- * Menu item list to render.
91
- */
92
- items: PropTypes.arrayOf(PropTypes.shape({
93
- /**
94
- * Menu item label.
95
- */
96
- label: PropTypes.node
97
- })),
98
- /**
99
- * Custom renderer for menu items.
100
- * @param {object} item - of current menu item
101
- */
102
- itemRenderer: PropTypes.func,
103
- /**
104
- * Event handler for menu item onClick.
105
- * @param {object} event - object
106
- * @param {array} activePath - of clicked menu item.
107
- */
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
118
- };
119
-
120
- export default Menu;