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

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 (127) hide show
  1. package/README.md +20 -9
  2. package/dist/index.js +1 -1
  3. package/dist/nurvus.css +14 -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/Panel/Panel.d.ts +19 -0
  31. package/dist/types/components/Progress/Progress.d.ts +15 -0
  32. package/dist/types/components/Table/Table.d.ts +25 -0
  33. package/dist/types/components/Tag/Tag.d.ts +15 -0
  34. package/dist/types/components/Text/Text.d.ts +28 -0
  35. package/dist/types/components/Title/Title.d.ts +288 -0
  36. package/dist/types/constants.d.ts +5 -0
  37. package/dist/types/index.d.ts +30 -0
  38. package/dist/types/respawn/Button.d.ts +16 -0
  39. package/dist/types/respawn/ButtonGroup.d.ts +8 -0
  40. package/dist/types/respawn/FullPageModal.d.ts +32 -0
  41. package/dist/types/respawn/HistoryList.d.ts +36 -0
  42. package/dist/types/respawn/Layout.d.ts +22 -0
  43. package/dist/types/respawn/Link.d.ts +12 -0
  44. package/dist/types/respawn/Menu.d.ts +33 -0
  45. package/dist/types/respawn/Panel.d.ts +15 -0
  46. package/dist/types/respawn/Progress.d.ts +15 -0
  47. package/dist/types/respawn/Table.d.ts +22 -0
  48. package/dist/types/respawn/Tag.d.ts +11 -0
  49. package/dist/types/respawn/Text.d.ts +19 -0
  50. package/dist/types/respawn/Title.d.ts +14 -0
  51. package/dist/types/respawn/index.d.ts +33 -0
  52. package/dist/types/respawn/spawn.d.ts +50 -0
  53. package/dist/types/respawn/update.d.ts +13 -0
  54. package/dist/types/spacing.d.ts +8 -0
  55. package/dist/types/theme.d.ts +32 -0
  56. package/dist/types/themes/index.d.ts +45 -0
  57. package/package.json +40 -12
  58. package/src/components/Button/Button.md +5 -5
  59. package/src/components/Button/Button.tsx +44 -0
  60. package/src/components/ButtonGroup/ButtonGroup.tsx +23 -0
  61. package/src/components/FullPageModal/FullPageModal.scss +9 -5
  62. package/src/components/FullPageModal/FullPageModal.tsx +74 -0
  63. package/src/components/HistoryList/{HistoryList.jsx → HistoryList.tsx} +45 -58
  64. package/src/components/Layout/Layout.md +4 -4
  65. package/src/components/Layout/Layout.scss +14 -47
  66. package/src/components/Layout/Layout.tsx +56 -0
  67. package/src/components/Link/Link.scss +9 -9
  68. package/src/components/Link/Link.tsx +23 -0
  69. package/src/components/Menu/Menu.tsx +90 -0
  70. package/src/components/Panel/{Panel.jsx → Panel.tsx} +17 -26
  71. package/src/components/Progress/Progress.md +5 -5
  72. package/src/components/Progress/Progress.tsx +36 -0
  73. package/src/components/Table/Table.tsx +59 -0
  74. package/src/components/Tag/{Tag.jsx → Tag.tsx} +13 -18
  75. package/src/components/Text/Text.md +13 -0
  76. package/src/components/Text/Text.scss +6 -0
  77. package/src/components/Text/Text.tsx +54 -0
  78. package/src/components/Title/Title.tsx +42 -0
  79. package/src/constants.ts +6 -0
  80. package/src/css.ts +16 -0
  81. package/src/global.d.ts +3 -0
  82. package/src/index.ts +40 -0
  83. package/src/respawn/Button.ts +31 -0
  84. package/src/respawn/ButtonGroup.ts +19 -0
  85. package/src/respawn/FullPageModal.ts +125 -0
  86. package/src/respawn/HistoryList.ts +100 -0
  87. package/src/respawn/Layout.ts +44 -0
  88. package/src/respawn/Link.ts +24 -0
  89. package/src/respawn/Menu.ts +86 -0
  90. package/src/respawn/Panel.ts +36 -0
  91. package/src/respawn/Progress.ts +29 -0
  92. package/src/respawn/Table.ts +54 -0
  93. package/src/respawn/Tag.ts +25 -0
  94. package/src/respawn/Text.ts +35 -0
  95. package/src/respawn/Title.ts +30 -0
  96. package/src/respawn/index.ts +57 -0
  97. package/src/respawn/spawn.ts +155 -0
  98. package/src/respawn/update.ts +49 -0
  99. package/src/spacing.ts +23 -0
  100. package/src/styles/theme.scss +6 -197
  101. package/src/styles/type.json +35 -5
  102. package/src/theme.ts +92 -0
  103. package/src/themes/css/all.css +231 -0
  104. package/src/themes/css/apollo-white.css +33 -0
  105. package/src/themes/css/arcane.css +33 -0
  106. package/src/themes/css/dopamine.css +33 -0
  107. package/src/themes/css/nether-neon.css +33 -0
  108. package/src/themes/css/nether.css +33 -0
  109. package/src/themes/css/outworld.css +33 -0
  110. package/src/themes/css/tokyo-neon.css +33 -0
  111. package/src/themes/index.ts +61 -0
  112. package/src/themes/roles.json +1 -1
  113. package/src/app.js +0 -29
  114. package/src/components/Button/Button.jsx +0 -59
  115. package/src/components/ButtonGroup/ButtonGroup.jsx +0 -28
  116. package/src/components/FullPageModal/FullPageModal.jsx +0 -106
  117. package/src/components/Layout/Layout.jsx +0 -68
  118. package/src/components/Link/Link.jsx +0 -39
  119. package/src/components/Menu/Menu.jsx +0 -120
  120. package/src/components/Progress/Progress.jsx +0 -56
  121. package/src/components/Table/Table.jsx +0 -94
  122. package/src/components/Text/Text.jsx +0 -54
  123. package/src/components/Title/Title.jsx +0 -48
  124. package/src/constants.js +0 -3
  125. package/src/index.js +0 -20
  126. package/src/theme.js +0 -64
  127. package/src/themes/index.js +0 -22
@@ -0,0 +1,15 @@
1
+ import { Child, ElementProps } from './spawn';
2
+ import { NurvusElement } from './update';
3
+ export type PanelPadding = 'none' | 'small' | 'medium';
4
+ export interface PanelProps extends ElementProps {
5
+ /** Heading at the top of the panel. */
6
+ title?: Child;
7
+ /** Footer line under a hairline, in caption type. */
8
+ caption?: Child;
9
+ /** Inner spacing: none (e.g. a full-bleed image), small (12px) or medium (16px). */
10
+ padding?: PanelPadding;
11
+ /** The panel's content. */
12
+ children?: Child;
13
+ }
14
+ /** A card: the theme's surface, a hairline border and 12px corners, with an optional title and caption. */
15
+ export default function Panel(props?: PanelProps): NurvusElement<HTMLElement, PanelProps>;
@@ -0,0 +1,15 @@
1
+ import { NurvusElement } from './update';
2
+ export type ProgressSize = 'small' | 'medium' | 'large';
3
+ export type ProgressStatus = 'active' | 'success' | 'warning' | 'critical';
4
+ export interface ProgressProps {
5
+ /** How far along, 0 to 100. */
6
+ percent?: number;
7
+ /** Bar height. */
8
+ size?: ProgressSize;
9
+ /** The bar color: active (accent), success, warning or critical (danger). */
10
+ status?: ProgressStatus;
11
+ /** Custom class name. */
12
+ className?: string;
13
+ }
14
+ /** A progress bar. Like the React one, it takes no other attributes. */
15
+ export default function Progress(props?: ProgressProps): NurvusElement<HTMLDivElement, ProgressProps>;
@@ -0,0 +1,22 @@
1
+ import { Child, ElementProps } from './spawn';
2
+ import { NurvusElement } from './update';
3
+ /** A row of data: any object. */
4
+ export type TableRow = Record<string, any>;
5
+ export interface TableColumn<Row extends TableRow = TableRow> extends ElementProps {
6
+ /** Which field of each row this column shows. */
7
+ dataKey: string;
8
+ /** Header text. Defaults to the dataKey. */
9
+ title?: Child;
10
+ /** Formats a cell: gets the value, the dataKey and the whole row. Returns text, an element or spawn props. */
11
+ render?: (value: any, dataKey: string, row: Row) => Child;
12
+ }
13
+ export interface TableProps<Row extends TableRow = TableRow> {
14
+ /** The columns, in order. Any other column prop (e.g. style) goes on its `<th>` and `<td>`s. */
15
+ columns: TableColumn<Row>[];
16
+ /** The rows, in order. */
17
+ data: Row[];
18
+ /** Custom class name. */
19
+ className?: string;
20
+ }
21
+ /** A data table. Columns describe the fields; each can format its cells with `render`. */
22
+ export default function Table<Row extends TableRow = TableRow>(props: TableProps<Row>): NurvusElement<HTMLTableElement, TableProps<Row>>;
@@ -0,0 +1,11 @@
1
+ import { Child, ElementProps } from './spawn';
2
+ import { NurvusElement } from './update';
3
+ export type TagTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info';
4
+ export interface TagProps extends ElementProps {
5
+ /** Color: neutral (muted text) or one of the theme's accent / status colors. */
6
+ tone?: TagTone;
7
+ /** The label. */
8
+ children?: Child;
9
+ }
10
+ /** A small pill for a status or label ("new", "preview", "demo"). */
11
+ export default function Tag(props?: TagProps): NurvusElement<HTMLSpanElement, TagProps>;
@@ -0,0 +1,19 @@
1
+ import { Child, ElementProps } from './spawn';
2
+ import { NurvusElement } from './update';
3
+ export type TextVariant = 'display' | 'title' | 'body' | 'caption' | 'mono';
4
+ export type TextTone = 'default' | 'muted' | 'subtle';
5
+ export type TextWeight = 'regular' | 'medium' | 'semibold' | 'bold';
6
+ export interface TextProps extends ElementProps {
7
+ /** The element to render: 'p' for a paragraph, 'span' inside a line, 'h1'…, 'label'. */
8
+ as?: string;
9
+ /** Type role: display, title, body, caption or mono. Without one it inherits its parent's type. */
10
+ variant?: TextVariant;
11
+ /** Text color from the theme: default (text), muted or subtle. */
12
+ tone?: TextTone;
13
+ /** Font weight, overriding the role's own: regular 400, medium 500, semibold 600, bold 700. */
14
+ weight?: TextWeight;
15
+ /** The text. */
16
+ children?: Child;
17
+ }
18
+ /** Text in one of the type roles. A paragraph is `Text({ as: 'p', variant: 'body', children: '…' })`. */
19
+ export default function Text(props?: TextProps): NurvusElement<HTMLElement, TextProps>;
@@ -0,0 +1,14 @@
1
+ import { Child, ElementProps } from './spawn';
2
+ import { NurvusElement } from './update';
3
+ export type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
4
+ export type TitleType = 'primary' | 'secondary';
5
+ export interface TitleProps extends ElementProps {
6
+ /** Heading level: 1 renders `<h1>` (24px) down to 6 (`<h6>`). */
7
+ level?: TitleLevel;
8
+ /** `primary` uses the theme's text color; `secondary` the muted one. */
9
+ type?: TitleType;
10
+ /** The heading text. */
11
+ children?: Child;
12
+ }
13
+ /** A heading, `<h1>` to `<h6>`, in the theme's text color. */
14
+ export default function Title(props?: TitleProps): NurvusElement<HTMLHeadingElement, TitleProps>;
@@ -0,0 +1,33 @@
1
+ export { themes, DEFAULT_THEME, THEME_STORAGE_KEY, THEME_CHANGE_EVENT, getTheme, currentTheme, setTheme, initTheme, } from '../theme';
2
+ export type { SetThemeOptions } from '../theme';
3
+ export { roles as themeRoles } from '../themes';
4
+ export type { Theme, ThemeRole, ThemeRoleInfo } from '../themes';
5
+ export { spawn } from './spawn';
6
+ export type { Child, ElementProps, Events, Listener, SpawnProps, Style } from './spawn';
7
+ export type { NurvusElement } from './update';
8
+ export { default as Button } from './Button';
9
+ export type { ButtonProps, ButtonSize, ButtonType } from './Button';
10
+ export { default as ButtonGroup } from './ButtonGroup';
11
+ export type { ButtonGroupProps } from './ButtonGroup';
12
+ export { default as Link } from './Link';
13
+ export type { LinkProps } from './Link';
14
+ export { default as Progress } from './Progress';
15
+ export type { ProgressProps, ProgressSize, ProgressStatus } from './Progress';
16
+ export { default as Layout } from './Layout';
17
+ export type { LayoutProps, Spacing, LegacySpacing } from './Layout';
18
+ export { default as Menu } from './Menu';
19
+ export type { MenuProps, MenuItem } from './Menu';
20
+ export { default as FullPageModal } from './FullPageModal';
21
+ export type { FullPageModalProps } from './FullPageModal';
22
+ export { default as HistoryList } from './HistoryList';
23
+ export type { HistoryListProps, HistoryStep } from './HistoryList';
24
+ export { default as Panel } from './Panel';
25
+ export type { PanelProps, PanelPadding } from './Panel';
26
+ export { default as Table } from './Table';
27
+ export type { TableProps, TableColumn, TableRow } from './Table';
28
+ export { default as Tag } from './Tag';
29
+ export type { TagProps, TagTone } from './Tag';
30
+ export { default as Text } from './Text';
31
+ export type { TextProps, TextVariant, TextTone, TextWeight } from './Text';
32
+ export { default as Title } from './Title';
33
+ export type { TitleProps, TitleLevel, TitleType } from './Title';
@@ -0,0 +1,50 @@
1
+ /** Something to render: text, a DOM node, nested spawn props, or a list of them. */
2
+ export type Child = string | number | boolean | null | undefined | Node | SpawnProps | Child[];
3
+ /** An event listener: gets the event and the element it is on. */
4
+ export type Listener<E extends Event = Event> = (event: E, el: HTMLElement) => void;
5
+ /** `events: { click: (event, el) => … }`, as in Respawn's Spawn. */
6
+ export type Events = {
7
+ [K in keyof HTMLElementEventMap]?: Listener<HTMLElementEventMap[K]>;
8
+ } & {
9
+ [type: string]: Listener<any> | undefined;
10
+ };
11
+ /** Inline styles: camelCase or kebab-case names, custom properties (--x) too. Numbers get px where CSS needs a unit. */
12
+ export type Style = {
13
+ [name: string]: string | number | null | undefined;
14
+ };
15
+ /** What every component's root element accepts besides its own props: HTML attributes and listeners. */
16
+ export interface ElementProps {
17
+ /** Your class name; it comes first: class="yours <component> nurvus". */
18
+ className?: string;
19
+ /** Inline styles, as an object or a CSS string. */
20
+ style?: Style | string;
21
+ /** Event listeners by event type, as in Respawn: `{ click: (event, el) => … }`. */
22
+ events?: Events;
23
+ /** on<Event> listeners, e.g. onClick, onMouseEnter. */
24
+ [handler: `on${string}`]: ((...args: any[]) => void) | undefined;
25
+ /** Any other HTML attribute: id, title, disabled, aria-label, data-*… */
26
+ [attribute: string]: unknown;
27
+ }
28
+ /** Respawn's props shape: the element to make, its attributes, listeners and children. */
29
+ export interface SpawnProps extends ElementProps {
30
+ /** The element to create. Defaults to 'div'. */
31
+ tag?: string;
32
+ /** What goes inside. A function is called with the element instead. */
33
+ children?: Child | ((el: HTMLElement) => void);
34
+ /** Appends the new element to this one. */
35
+ mountEl?: Element;
36
+ }
37
+ /** Appends `child` (any Child) to `parent`. */
38
+ export declare function append(parent: Node, child: Child): void;
39
+ /** One Child as a single DOM node (a list becomes a fragment; nothing becomes an empty fragment). */
40
+ export declare function toNode(child: Child): Node;
41
+ /**
42
+ * Builds an element from Respawn-style props and returns it.
43
+ *
44
+ * spawn({ tag: 'p', className: 'note', children: ['Saved ', spawn({ tag: 'b', children: 'now' })] })
45
+ * spawn({ tag: 'button', events: { click: (event, el) => el.remove() }, children: 'Remove' })
46
+ *
47
+ * An element passed in comes back as it is, so components and your own
48
+ * elements mix freely in children.
49
+ */
50
+ export declare function spawn<E extends HTMLElement = HTMLElement>(props?: SpawnProps | HTMLElement): E;
@@ -0,0 +1,13 @@
1
+ /** An element a component returned: the DOM element itself, plus update(). */
2
+ export type NurvusElement<E extends HTMLElement, P> = E & {
3
+ /** Rebuilds it with `changes` merged into its props, swaps the new one into the page, and returns it. */
4
+ update(changes: Partial<P>): NurvusElement<E, P>;
5
+ };
6
+ /** Lets a render function save props without rebuilding (e.g. Menu's row click). */
7
+ export type Keep<P> = (changes: Partial<P>) => void;
8
+ /**
9
+ * Wraps a render function so its element gets update(). A `mountEl` prop
10
+ * (as in Respawn's Spawn) appends the first element to it; updates replace it
11
+ * in place instead.
12
+ */
13
+ export declare function updatable<E extends HTMLElement, P extends object>(render: (props: P, keep: Keep<P>) => E, initial: P): NurvusElement<E, P>;
@@ -0,0 +1,8 @@
1
+ /** A step of the 4px spacing grid (the --space--N tokens). */
2
+ export type Spacing = 0 | 2 | 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64;
3
+ /** Values from before the grid. Still accepted: each snaps to a grid step, with a console warning. */
4
+ export type LegacySpacing = 10 | 13 | 20 | 30 | 40;
5
+ /** Where each pre-grid value lands: the nearest step, ties going down (20 → 16, 40 → 32). */
6
+ export declare const LEGACY_SPACING: Record<LegacySpacing, Spacing>;
7
+ /** The grid step to use for `value`; warns once per pre-grid value. */
8
+ export declare function toGrid(value: Spacing | LegacySpacing): Spacing;
@@ -0,0 +1,32 @@
1
+ import { themes, DEFAULT_THEME, Theme } from './themes';
2
+ /** localStorage key that remembers the chosen theme. */
3
+ export declare const THEME_STORAGE_KEY = "nurvus.theme";
4
+ /** Fired on the themed element (bubbles) after setTheme; detail = the theme. */
5
+ export declare const THEME_CHANGE_EVENT = "nurvus:themechange";
6
+ export interface SetThemeOptions {
7
+ /** The element to theme. Defaults to <html>; any element themes just that part of the page. */
8
+ root?: HTMLElement;
9
+ /** Save it as the visitor's choice (localStorage). Defaults to true. */
10
+ persist?: boolean;
11
+ }
12
+ /** A theme object by id, or undefined. */
13
+ export declare function getTheme(id: string | null | undefined): Theme | undefined;
14
+ /** The theme currently applied to `root` (defaults to <html>). */
15
+ export declare function currentTheme(root?: HTMLElement): Theme;
16
+ /**
17
+ * Apply a theme. Sets data-theme on `root` (default <html>), which swaps every
18
+ * --nv-* custom property underneath it. Pass any element as `root` to theme
19
+ * just that part of the page; themes nest.
20
+ *
21
+ * setTheme('tokyo-neon');
22
+ * setTheme('apollo-white', { root: sidebarEl, persist: false });
23
+ */
24
+ export declare function setTheme(id: string, { root, persist }?: SetThemeOptions): Theme;
25
+ /**
26
+ * Apply the saved theme, or `fallback` when nothing (valid) is saved. Only
27
+ * needed for a default other than Apollo White set from code: the package
28
+ * already restores a saved theme by itself when it loads.
29
+ */
30
+ export declare function initTheme(fallback?: string, options?: SetThemeOptions): Theme;
31
+ export { themes, DEFAULT_THEME };
32
+ export type { Theme };
@@ -0,0 +1,45 @@
1
+ /** One of the 27 color roles every theme defines, e.g. 'bg', 'text', 'accent'. */
2
+ export type ThemeRole = 'bg' | 'bg-alt' | 'bg-deep' | 'surface' | 'surface-hover' | 'border' | 'border-strong' | 'text' | 'text-muted' | 'text-subtle' | 'accent' | 'accent-fill' | 'accent-soft' | 'on-accent' | 'success' | 'warning' | 'danger' | 'info' | 'cursor' | 'selection' | 'syntax-keyword' | 'syntax-string' | 'syntax-function' | 'syntax-number' | 'syntax-comment' | 'syntax-tag' | 'syntax-attr';
3
+ /** A theme, as in src/themes/<id>.json. */
4
+ export interface Theme {
5
+ /** Used in data-theme and setTheme, e.g. 'tokyo-neon'. */
6
+ id: string;
7
+ /** Display name, e.g. 'Tokyo Neon'. */
8
+ name: string;
9
+ mode: 'light' | 'dark';
10
+ /** 'demo' themes warn on a contrast failure; 'stable' ones fail the build. */
11
+ status: 'demo' | 'stable';
12
+ /** Position in menus (light themes first). */
13
+ order: number;
14
+ keywords: string;
15
+ summary: string;
16
+ description: string;
17
+ bestFor: string;
18
+ /** Which roles the theme's showcase card uses. */
19
+ showcase: {
20
+ label: string;
21
+ title: string;
22
+ tagline: string;
23
+ swatches: string[];
24
+ };
25
+ /** Every role's color (hex). */
26
+ colors: Record<ThemeRole, string>;
27
+ }
28
+ /** What a role is for, and which roles it must contrast with. */
29
+ export interface ThemeRoleInfo {
30
+ /** Which group the role belongs to, e.g. "Text". */
31
+ group: string;
32
+ /** What the role is for. */
33
+ use: string;
34
+ /** Contrast it must meet against other roles. */
35
+ check?: {
36
+ against: ThemeRole[];
37
+ min: number;
38
+ };
39
+ }
40
+ /** All themes, in display order (light first). */
41
+ export declare const themes: Theme[];
42
+ /** The theme a page gets with no data-theme attribute at all. */
43
+ export declare const DEFAULT_THEME = "apollo-white";
44
+ /** What each role token is for, and the contrast it must meet. */
45
+ export declare const roles: Record<ThemeRole, ThemeRoleInfo>;
package/package.json CHANGED
@@ -1,35 +1,58 @@
1
1
  {
2
2
  "name": "@nurvus/ui",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "NURVUS Design System",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/types/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./respawn": {
13
+ "types": "./dist/types/respawn/index.d.ts",
14
+ "default": "./dist/respawn.js"
15
+ },
16
+ "./theme": {
17
+ "types": "./dist/types/theme.d.ts",
18
+ "default": "./dist/theme.js"
19
+ },
20
+ "./nurvus.css": "./dist/nurvus.css",
21
+ "./themes/*": "./dist/themes/*",
22
+ "./package.json": "./package.json",
23
+ "./dist/*": "./dist/*",
24
+ "./src/*": "./src/*"
25
+ },
26
+ "sideEffects": [
27
+ "*.css",
28
+ "*.scss",
29
+ "./src/theme.ts",
30
+ "./dist/*.js"
31
+ ],
6
32
  "publishConfig": {
7
33
  "access": "public"
8
34
  },
9
35
  "scripts": {
10
- "build": "rimraf dist && npm run build:tokens && webpack --mode=production --json > stats.json",
36
+ "build": "rimraf dist && npm run build:tokens && webpack --mode=production && node tools/finish-build.mjs && npm run build:types",
11
37
  "build:tokens": "node ./tools/build-tokens.js",
12
38
  "prepare": "npm run build",
13
39
  "styleguide": "npm run docs",
14
40
  "styleguide:build": "npm run docs:build",
15
41
  "docs": "npm run build:tokens && vite --config docs/vite.config.js",
16
- "docs:build": "npm run build:tokens && vite build --config docs/vite.config.js"
42
+ "docs:build": "npm run build:tokens && vite build --config docs/vite.config.js",
43
+ "build:types": "tsc -p tsconfig.build.json && node tools/clean-types.mjs",
44
+ "typecheck": "tsc -p tsconfig.json"
17
45
  },
18
46
  "files": [
19
47
  "dist",
20
48
  "src"
21
49
  ],
22
50
  "dependencies": {
23
- "@material-ui/core": "^4.12.3",
24
- "@material-ui/icons": "^4.11.2",
25
- "classnames": "^2.3.1",
26
- "clsx": "^1.2.1",
27
- "lodash": "^4.17.20",
28
- "prop-types": "^15.7.2"
51
+ "classnames": "^2.3.1"
29
52
  },
30
53
  "peerDependencies": {
31
- "react": "^16.8.0",
32
- "react-dom": "^16.8.0"
54
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
55
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
33
56
  },
34
57
  "devDependencies": {
35
58
  "@babel/core": "^7.12.3",
@@ -45,12 +68,17 @@
45
68
  "@fontsource/inter": "^5.3.0",
46
69
  "@fontsource/jetbrains-mono": "^5.3.0",
47
70
  "@lezer/highlight": "^1.2.5",
71
+ "@material-ui/core": "^4.12.3",
72
+ "@material-ui/icons": "^4.11.2",
73
+ "@types/react": "^17.0.94",
74
+ "@types/react-dom": "^17.0.26",
48
75
  "@vitejs/plugin-react": "^6.3.0",
49
76
  "babel-loader": "^8.1.0",
50
77
  "cross-env": "^7.0.3",
51
78
  "css-loader": "^5.0.0",
52
79
  "file-loader": "^6.2.0",
53
80
  "marked": "^18.3.0",
81
+ "mini-css-extract-plugin": "^2.10.2",
54
82
  "postcss": "^8.4.14",
55
83
  "react": "^16.8.0",
56
84
  "react-docgen": "^8.0.4",
@@ -61,7 +89,7 @@
61
89
  "sass-loader": "^10.0.4",
62
90
  "style-loader": "^2.0.0",
63
91
  "sucrase": "^3.35.1",
64
- "typescript": "^4.4.3",
92
+ "typescript": "^5.9.3",
65
93
  "vite": "^8.3.8",
66
94
  "webpack": "^5.113.0",
67
95
  "webpack-cli": "^5.1.4"
@@ -3,14 +3,14 @@ Basic Example
3
3
  import React from 'react';
4
4
  import { Button, Layout } from '@nurvus/ui';
5
5
 
6
- <Layout display="flex" itemSpacing={ 40 }>
6
+ <Layout display="flex" itemSpacing={ 32 }>
7
7
  <Layout display="flex">
8
8
  <Layout
9
9
  display="flex"
10
10
  flexDirection="column"
11
11
  alignItems="center"
12
12
  justifyContent="center"
13
- itemSpacing={ 13 }
13
+ itemSpacing={ 12 }
14
14
  >
15
15
  <Button type="primary" size="extra-large">Hello</Button>
16
16
  <Button type="primary" size="large">Hello</Button>
@@ -23,7 +23,7 @@ import { Button, Layout } from '@nurvus/ui';
23
23
  flexDirection="column"
24
24
  alignItems="center"
25
25
  justifyContent="center"
26
- itemSpacing={ 13 }
26
+ itemSpacing={ 12 }
27
27
  >
28
28
  <Button type="primary" disabled={ true } size="extra-large">Hello</Button>
29
29
  <Button type="primary" disabled={ true } size="large">Hello</Button>
@@ -38,7 +38,7 @@ import { Button, Layout } from '@nurvus/ui';
38
38
  flexDirection="column"
39
39
  alignItems="center"
40
40
  justifyContent="center"
41
- itemSpacing={ 13 }
41
+ itemSpacing={ 12 }
42
42
  >
43
43
  <Button type="secondary" size="extra-large">Hello</Button>
44
44
  <Button type="secondary" size="large">Hello</Button>
@@ -51,7 +51,7 @@ import { Button, Layout } from '@nurvus/ui';
51
51
  flexDirection="column"
52
52
  alignItems="center"
53
53
  justifyContent="center"
54
- itemSpacing={ 13 }
54
+ itemSpacing={ 12 }
55
55
  >
56
56
  <Button type="secondary" disabled={ true } size="extra-large">Hello</Button>
57
57
  <Button type="secondary" disabled={ true } size="large">Hello</Button>
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import CONSTANT from '../../constants';
4
+ import './Button.scss';
5
+
6
+ export type ButtonSize = 'extra-large' | 'large' | 'medium' | 'small' | 'mini';
7
+ export type ButtonType = 'primary' | 'secondary';
8
+
9
+ export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
10
+ /** Size of the button. */
11
+ size?: ButtonSize;
12
+ /** Look: primary (filled with the accent) or secondary (quiet). Not the HTML type attribute. */
13
+ type?: ButtonType;
14
+ /** Content to render inside the button. */
15
+ children?: React.ReactNode;
16
+ /** Custom class name. */
17
+ className?: string;
18
+ }
19
+
20
+ /**
21
+ * A button. Any other prop (onClick, disabled, aria-*) goes on the `<button>`,
22
+ * and a ref reaches it too.
23
+ */
24
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button({
25
+ className,
26
+ children,
27
+ size = 'medium',
28
+ type = 'primary',
29
+ ...restProps
30
+ }, ref) {
31
+ return (
32
+ <button
33
+ className={ classNames(className, 'button', CONSTANT.CLASS_PREFIX) }
34
+ data-size={ size }
35
+ data-type={ type }
36
+ ref={ ref }
37
+ { ...restProps }
38
+ >
39
+ { children }
40
+ </button>
41
+ );
42
+ });
43
+
44
+ export default Button;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import CONSTANT from '../../constants';
4
+ import './ButtonGroup.scss';
5
+
6
+ export interface ButtonGroupProps extends React.HTMLAttributes<HTMLDivElement> {
7
+ /** The Buttons to join. */
8
+ children?: React.ReactNode;
9
+ /** Custom class name. */
10
+ className?: string;
11
+ }
12
+
13
+ /**
14
+ * Joins Buttons into one row: square corners where they meet, rounded at the
15
+ * two outer ends. Any other prop goes on the wrapping `<div>`.
16
+ */
17
+ export default function ButtonGroup({ className, ...restProps }: ButtonGroupProps) {
18
+ return (
19
+ <div
20
+ className={ classNames(className, 'button-group', CONSTANT.CLASS_PREFIX) }
21
+ { ...restProps } />
22
+ );
23
+ }
@@ -57,7 +57,8 @@
57
57
  right: 0;
58
58
  bottom: 0;
59
59
  z-index: $modal-z-index;
60
- background-color: rgb(64 57 96 / 50%);
60
+ // A dimmed page behind the modal, in every theme.
61
+ background-color: color-mix(in srgb, var(--nv-bg-deep) 60%, transparent);
61
62
  transition: all 0.3s ease;
62
63
 
63
64
  &[data-animate="reveal-in"] {
@@ -78,12 +79,15 @@
78
79
  right: 0;
79
80
  bottom: 0;
80
81
  z-index: $modal-z-index;
81
- background-color: #403960;
82
+ // Theme roles (it had fixed purples, so its title was dark on dark in light themes).
83
+ background-color: var(--nv-bg);
84
+ color: var(--nv-text);
82
85
 
83
86
  .header {
84
- background-color: rgb(46, 36, 66);
85
- color: $white;
86
- padding: 10px;
87
+ padding: var(--space--12) var(--space--16);
88
+ border-bottom: 1px solid var(--nv-border);
89
+ background-color: var(--nv-bg-alt);
90
+ color: var(--nv-text);
87
91
  }
88
92
 
89
93
  &[data-animate="reveal-in"] {
@@ -0,0 +1,74 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import classNames from 'classnames';
4
+ import CONSTANT from '../../constants';
5
+ import Layout from '../Layout/Layout';
6
+ import Title from '../Title/Title';
7
+ import './FullPageModal.scss';
8
+
9
+ export interface FullPageModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
10
+ /** Shows the modal (animates in), or hides it (animates out). */
11
+ visible?: boolean;
12
+ /** Title in the modal's header. */
13
+ title?: React.ReactNode;
14
+ /** Buttons at the right of the header, e.g. Close. */
15
+ headerActions?: React.ReactNode;
16
+ /** The modal's content. */
17
+ children?: React.ReactNode;
18
+ /** Custom class name. */
19
+ className?: string;
20
+ }
21
+
22
+ /** Shows additional content over the whole screen, rendered into `<body>`. */
23
+ export default function FullPageModal({
24
+ children,
25
+ className,
26
+ headerActions,
27
+ title,
28
+ visible = false,
29
+ ...restProps
30
+ }: FullPageModalProps) {
31
+ const [animationState, setAnimationState] = useState('');
32
+ const [isVisible, setIsVisible] = useState(visible);
33
+
34
+ // Clear animation and sync visibility states
35
+ function clearAnimation() {
36
+ if (animationState && visible !== isVisible) {
37
+ setIsVisible(visible);
38
+ setAnimationState('');
39
+ }
40
+ }
41
+
42
+ // Trigger animation when visibility changes
43
+ useEffect(() => {
44
+ if (visible !== isVisible) {
45
+ setAnimationState(visible ? 'reveal-in' : 'reveal-out');
46
+ }
47
+ if (visible && !animationState) {
48
+ setIsVisible(visible);
49
+ }
50
+ }, [visible]); // eslint-disable-line react-hooks/exhaustive-deps
51
+
52
+ const modalEl = (
53
+ <div className={ `portal ${CONSTANT.CLASS_PREFIX}` } data-visible={ visible }>
54
+ { isVisible ? <div className="mask" data-animate={ animationState } /> : null }
55
+ <div
56
+ className={ classNames(className, 'modal', CONSTANT.CLASS_PREFIX) }
57
+ data-visible={ isVisible }
58
+ data-animate={ animationState }
59
+ onAnimationEnd={ clearAnimation }
60
+ { ...restProps }
61
+ >
62
+ <div className="header">
63
+ <Layout display="flex" alignItems="center" justifyContent="space-between">
64
+ <Title>{ title }</Title>
65
+ <div className="header-actions">{ headerActions }</div>
66
+ </Layout>
67
+ </div>
68
+ { children }
69
+ </div>
70
+ </div>
71
+ );
72
+
73
+ return <React.Fragment>{ ReactDOM.createPortal(modalEl, document.body) }</React.Fragment>;
74
+ }