shelving 1.207.0 → 1.208.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ui/app/App.module.css +0 -55
- package/ui/docs/DocumentationCard.d.ts +1 -1
- package/ui/docs/DocumentationCard.js +3 -2
- package/ui/docs/DocumentationCard.tsx +3 -1
- package/ui/docs/DocumentationKind.d.ts +13 -0
- package/ui/docs/DocumentationKind.js +22 -0
- package/ui/docs/DocumentationKind.tsx +31 -0
- package/ui/docs/DocumentationPage.d.ts +1 -1
- package/ui/docs/DocumentationPage.js +3 -2
- package/ui/docs/DocumentationPage.tsx +3 -0
- package/ui/docs/index.d.ts +1 -0
- package/ui/docs/index.js +1 -0
- package/ui/docs/index.ts +1 -0
- package/ui/form/Button.d.ts +3 -2
- package/ui/form/Button.js +4 -2
- package/ui/form/Button.tsx +4 -2
- package/ui/form/SubmitButton.js +1 -1
- package/ui/form/SubmitButton.tsx +1 -1
- package/ui/misc/Color.d.ts +25 -0
- package/ui/misc/Color.js +7 -0
- package/ui/misc/Color.module.css +105 -0
- package/ui/misc/Color.tsx +32 -0
- package/ui/{notice → misc}/Status.module.css +65 -0
- package/ui/{notice → misc}/StatusIcon.js +1 -1
- package/ui/{notice → misc}/StatusIcon.tsx +1 -1
- package/ui/misc/Tag.d.ts +23 -0
- package/ui/misc/Tag.js +18 -0
- package/ui/misc/Tag.module.css +29 -0
- package/ui/misc/Tag.tsx +38 -0
- package/ui/misc/index.d.ts +4 -0
- package/ui/misc/index.js +4 -0
- package/ui/misc/index.tsx +4 -0
- package/ui/notice/Message.d.ts +3 -2
- package/ui/notice/Message.js +3 -2
- package/ui/notice/Message.tsx +4 -2
- package/ui/notice/Notice.d.ts +3 -2
- package/ui/notice/Notice.js +5 -3
- package/ui/notice/Notice.tsx +6 -4
- package/ui/notice/NoticesStore.d.ts +1 -1
- package/ui/notice/NoticesStore.ts +1 -1
- package/ui/notice/index.d.ts +0 -2
- package/ui/notice/index.js +0 -2
- package/ui/notice/index.ts +0 -2
- package/ui/util/notice.d.ts +1 -1
- package/ui/util/notice.ts +1 -1
- /package/ui/{notice → misc}/Status.d.ts +0 -0
- /package/ui/{notice → misc}/Status.js +0 -0
- /package/ui/{notice → misc}/Status.tsx +0 -0
- /package/ui/{notice → misc}/StatusIcon.d.ts +0 -0
- /package/ui/{notice → misc}/StatusIcon.module.css +0 -0
package/package.json
CHANGED
package/ui/app/App.module.css
CHANGED
|
@@ -102,65 +102,10 @@
|
|
|
102
102
|
--shadow-element: 0 3px 16px -8px var(--color-overlay);
|
|
103
103
|
--shadow-block: 0 4px 24px -12px var(--color-overlay);
|
|
104
104
|
|
|
105
|
-
/* Primary colors */
|
|
106
|
-
--primary-text: var(--color-blue);
|
|
107
|
-
--primary-contrast: var(--color-white);
|
|
108
|
-
--primary-surface: color-mix(in srgb, var(--primary-text) 12%, white);
|
|
109
|
-
|
|
110
|
-
/* Secondary colors */
|
|
111
|
-
--secondary-text: var(--color-purple);
|
|
112
|
-
--secondary-contrast: var(--color-white);
|
|
113
|
-
--secondary-surface: color-mix(in srgb, var(--secondary-text) 12%, white);
|
|
114
|
-
|
|
115
|
-
/* Tertiary colors */
|
|
116
|
-
--tertiary-text: var(--color-cyan);
|
|
117
|
-
--tertiary-contrast: var(--color-white);
|
|
118
|
-
--tertiary-surface: color-mix(in srgb, var(--tertiary-text) 12%, white);
|
|
119
|
-
|
|
120
|
-
/* Quiet colors */
|
|
121
|
-
--quiet-text: var(--color-quiet);
|
|
122
|
-
--quiet-contrast: var(--color-contrast);
|
|
123
|
-
--quiet-surface: var(--color-surface);
|
|
124
|
-
|
|
125
105
|
/* Focus colors */
|
|
126
106
|
--focus-text: var(--color-focus);
|
|
127
107
|
--focus-contrast: var(--color-white);
|
|
128
108
|
--focus-surface: color-mix(in srgb, var(--focus-text) 12%, white);
|
|
129
|
-
|
|
130
|
-
/* Loading colors */
|
|
131
|
-
--loading-text: var(--color-loading);
|
|
132
|
-
--loading-contrast: var(--color-contrast);
|
|
133
|
-
--loading-surface: var(--color-surface);
|
|
134
|
-
|
|
135
|
-
/* Info colors */
|
|
136
|
-
--info-text: var(--color-blue);
|
|
137
|
-
--info-contrast: var(--color-white);
|
|
138
|
-
--info-surface: color-mix(in srgb, var(--info-text) 12%, white);
|
|
139
|
-
|
|
140
|
-
/* Success colors */
|
|
141
|
-
--success-text: var(--color-green);
|
|
142
|
-
--success-contrast: var(--color-white);
|
|
143
|
-
--success-surface: color-mix(in srgb, var(--success-text) 12%, white);
|
|
144
|
-
|
|
145
|
-
/* Warning colors */
|
|
146
|
-
--warning-text: var(--color-orange);
|
|
147
|
-
--warning-contrast: var(--color-white);
|
|
148
|
-
--warning-surface: color-mix(in srgb, var(--warning-text) 12%, white);
|
|
149
|
-
|
|
150
|
-
/* Error colors */
|
|
151
|
-
--error-text: var(--color-red);
|
|
152
|
-
--error-contrast: var(--color-white);
|
|
153
|
-
--error-surface: color-mix(in srgb, var(--error-text) 12%, white);
|
|
154
|
-
|
|
155
|
-
/* Danger colors */
|
|
156
|
-
--danger-text: var(--color-red);
|
|
157
|
-
--danger-contrast: var(--color-white);
|
|
158
|
-
--danger-surface: color-mix(in srgb, var(--danger-text) 12%, white);
|
|
159
|
-
|
|
160
|
-
/* Highlight colors */
|
|
161
|
-
--highlight-text: var(--color-yellow);
|
|
162
|
-
--highlight-contrast: var(--color-black);
|
|
163
|
-
--highlight-surface: color-mix(in srgb, var(--highlight-text) 12%, white);
|
|
164
109
|
}
|
|
165
110
|
|
|
166
111
|
.app {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
3
|
/** Card renderer for a `tree-documentation` element. */
|
|
4
|
-
export declare function DocumentationCard({ title, name, description, signatures }: DocumentationElementProps): ReactNode;
|
|
4
|
+
export declare function DocumentationCard({ title, name, kind, description, signatures }: DocumentationElementProps): ReactNode;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../index.js";
|
|
3
3
|
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
4
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
4
5
|
/** Card renderer for a `tree-documentation` element. */
|
|
5
|
-
export function DocumentationCard({ title, name, description, signatures }) {
|
|
6
|
+
export function DocumentationCard({ title, name, kind, description, signatures }) {
|
|
6
7
|
const href = requireTreeHref();
|
|
7
|
-
return (_jsxs("a", { className: TREE_CARD_CLASS, href: href, children: [_jsx("h3", { className: TREE_CARD_TITLE_CLASS, children: _jsx("code", { children: title ?? name }) }), signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { className: TREE_CARD_DESCRIPTION_CLASS, children: description })] }));
|
|
8
|
+
return (_jsxs("a", { className: TREE_CARD_CLASS, href: href, children: [_jsx("h3", { className: TREE_CARD_TITLE_CLASS, children: _jsx("code", { children: title ?? name }) }), kind && _jsx(DocumentationKind, { kind: kind }), signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { className: TREE_CARD_DESCRIPTION_CLASS, children: description })] }));
|
|
8
9
|
}
|
|
@@ -2,15 +2,17 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
3
|
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../index.js";
|
|
4
4
|
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
5
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
5
6
|
|
|
6
7
|
/** Card renderer for a `tree-documentation` element. */
|
|
7
|
-
export function DocumentationCard({ title, name, description, signatures }: DocumentationElementProps): ReactNode {
|
|
8
|
+
export function DocumentationCard({ title, name, kind, description, signatures }: DocumentationElementProps): ReactNode {
|
|
8
9
|
const href = requireTreeHref();
|
|
9
10
|
return (
|
|
10
11
|
<a className={TREE_CARD_CLASS} href={href}>
|
|
11
12
|
<h3 className={TREE_CARD_TITLE_CLASS}>
|
|
12
13
|
<code>{title ?? name}</code>
|
|
13
14
|
</h3>
|
|
15
|
+
{kind && <DocumentationKind kind={kind} />}
|
|
14
16
|
{signatures?.map(sig => (
|
|
15
17
|
<pre key={sig}>
|
|
16
18
|
<code>{sig}</code>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/** Props for `DocumentationKind`. */
|
|
3
|
+
export interface DocumentationKindProps {
|
|
4
|
+
/** The documentation kind (e.g. `"function"`, `"class"`, `"interface"`, `"type"`, `"constant"`, `"method"`, `"property"`). */
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
9
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
10
|
+
*
|
|
11
|
+
* @example <DocumentationKind kind="function" />
|
|
12
|
+
*/
|
|
13
|
+
export declare function DocumentationKind({ kind }: DocumentationKindProps): ReactElement;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tag } from "../misc/Tag.js";
|
|
3
|
+
/** Mapping from a documented symbol's `kind` to its tag colour. */
|
|
4
|
+
const KIND_COLOR = {
|
|
5
|
+
function: "blue",
|
|
6
|
+
class: "purple",
|
|
7
|
+
interface: "cyan",
|
|
8
|
+
type: "pink",
|
|
9
|
+
constant: "green",
|
|
10
|
+
method: "orange",
|
|
11
|
+
property: "yellow",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
15
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
16
|
+
*
|
|
17
|
+
* @example <DocumentationKind kind="function" />
|
|
18
|
+
*/
|
|
19
|
+
export function DocumentationKind({ kind }) {
|
|
20
|
+
const color = KIND_COLOR[kind];
|
|
21
|
+
return _jsx(Tag, { ...(color ? { [color]: true } : {}), children: kind });
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { Color } from "../misc/Color.js";
|
|
3
|
+
import { Tag } from "../misc/Tag.js";
|
|
4
|
+
|
|
5
|
+
/** Props for `DocumentationKind`. */
|
|
6
|
+
export interface DocumentationKindProps {
|
|
7
|
+
/** The documentation kind (e.g. `"function"`, `"class"`, `"interface"`, `"type"`, `"constant"`, `"method"`, `"property"`). */
|
|
8
|
+
readonly kind: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Mapping from a documented symbol's `kind` to its tag colour. */
|
|
12
|
+
const KIND_COLOR: { readonly [K in string]?: Color } = {
|
|
13
|
+
function: "blue",
|
|
14
|
+
class: "purple",
|
|
15
|
+
interface: "cyan",
|
|
16
|
+
type: "pink",
|
|
17
|
+
constant: "green",
|
|
18
|
+
method: "orange",
|
|
19
|
+
property: "yellow",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
24
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
25
|
+
*
|
|
26
|
+
* @example <DocumentationKind kind="function" />
|
|
27
|
+
*/
|
|
28
|
+
export function DocumentationKind({ kind }: DocumentationKindProps): ReactElement {
|
|
29
|
+
const color = KIND_COLOR[kind];
|
|
30
|
+
return <Tag {...(color ? { [color]: true } : {})}>{kind}</Tag>;
|
|
31
|
+
}
|
|
@@ -5,4 +5,4 @@ import type { DocumentationElementProps } from "../../util/element.js";
|
|
|
5
5
|
* - Renders title, signatures (one per overload), description, parameters, returns, throws, examples, and child symbols.
|
|
6
6
|
* - All sections are conditional — only render when their array has entries.
|
|
7
7
|
*/
|
|
8
|
-
export declare function DocumentationPage({ title, name, description, signatures, params, returns, throws, examples, children, }: DocumentationElementProps): ReactNode;
|
|
8
|
+
export declare function DocumentationPage({ title, name, kind, description, signatures, params, returns, throws, examples, children, }: DocumentationElementProps): ReactNode;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Page } from "../page/Page.js";
|
|
3
3
|
import { TreeCards } from "../tree/TreeCards.js";
|
|
4
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
4
5
|
const DEFAULT_TYPE = "unknown";
|
|
5
6
|
/**
|
|
6
7
|
* Page renderer for a `tree-documentation` element.
|
|
7
8
|
* - Renders title, signatures (one per overload), description, parameters, returns, throws, examples, and child symbols.
|
|
8
9
|
* - All sections are conditional — only render when their array has entries.
|
|
9
10
|
*/
|
|
10
|
-
export function DocumentationPage({ title, name, description, signatures, params, returns, throws, examples, children, }) {
|
|
11
|
-
return (_jsxs(Page, { title: title ?? name, children: [signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { children: description }), params?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Parameters" }), _jsx("dl", { children: params.map(({ name, type = DEFAULT_TYPE, description = "", optional }) => (_jsxs("div", { children: [_jsxs("dt", { children: [_jsx("code", { children: name }), ": ", _jsx("code", { children: type ?? DEFAULT_TYPE }), optional && _jsx(_Fragment, { children: " (optional)" })] }), description && _jsx("dd", { children: description })] }, `${name}-${type}-${description}`))) })] })), returns?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Returns" }), _jsx("dl", { children: returns.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), throws?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Throws" }), _jsx("dl", { children: throws.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), examples?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Examples" }), examples.map(({ description }) => (_jsx("pre", { children: _jsx("code", { children: description }) }, description)))] })), children && _jsx(TreeCards, { children: children })] }));
|
|
11
|
+
export function DocumentationPage({ title, name, kind, description, signatures, params, returns, throws, examples, children, }) {
|
|
12
|
+
return (_jsxs(Page, { title: title ?? name, children: [kind && _jsx(DocumentationKind, { kind: kind }), signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { children: description }), params?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Parameters" }), _jsx("dl", { children: params.map(({ name, type = DEFAULT_TYPE, description = "", optional }) => (_jsxs("div", { children: [_jsxs("dt", { children: [_jsx("code", { children: name }), ": ", _jsx("code", { children: type ?? DEFAULT_TYPE }), optional && _jsx(_Fragment, { children: " (optional)" })] }), description && _jsx("dd", { children: description })] }, `${name}-${type}-${description}`))) })] })), returns?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Returns" }), _jsx("dl", { children: returns.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), throws?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Throws" }), _jsx("dl", { children: throws.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), examples?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Examples" }), examples.map(({ description }) => (_jsx("pre", { children: _jsx("code", { children: description }) }, description)))] })), children && _jsx(TreeCards, { children: children })] }));
|
|
12
13
|
}
|
|
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
3
|
import { Page } from "../page/Page.js";
|
|
4
4
|
import { TreeCards } from "../tree/TreeCards.js";
|
|
5
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_TYPE = "unknown";
|
|
7
8
|
|
|
@@ -13,6 +14,7 @@ const DEFAULT_TYPE = "unknown";
|
|
|
13
14
|
export function DocumentationPage({
|
|
14
15
|
title,
|
|
15
16
|
name,
|
|
17
|
+
kind,
|
|
16
18
|
description,
|
|
17
19
|
signatures,
|
|
18
20
|
params,
|
|
@@ -23,6 +25,7 @@ export function DocumentationPage({
|
|
|
23
25
|
}: DocumentationElementProps): ReactNode {
|
|
24
26
|
return (
|
|
25
27
|
<Page title={title ?? name}>
|
|
28
|
+
{kind && <DocumentationKind kind={kind} />}
|
|
26
29
|
{signatures?.map(sig => (
|
|
27
30
|
<pre key={sig}>
|
|
28
31
|
<code>{sig}</code>
|
package/ui/docs/index.d.ts
CHANGED
package/ui/docs/index.js
CHANGED
package/ui/docs/index.ts
CHANGED
package/ui/form/Button.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type ElementsVariants } from "../block/Elements.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type ColorVariants } from "../misc/Color.js";
|
|
4
|
+
import { type StatusVariants } from "../misc/Status.js";
|
|
4
5
|
import BUTTON_CSS from "./Button.module.css";
|
|
5
6
|
import { type ClickableProps } from "./Clickable.js";
|
|
6
7
|
/** Variants for buttons. */
|
|
7
|
-
export interface ButtonVariants extends ElementsVariants, StatusVariants {
|
|
8
|
+
export interface ButtonVariants extends ElementsVariants, StatusVariants, ColorVariants {
|
|
8
9
|
/** This is the default button in a form and should be displayed stronger. */
|
|
9
10
|
strong?: boolean | undefined;
|
|
10
11
|
/** Add plain styling (background only appears on hover or focus). */
|
package/ui/form/Button.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ELEMENTS_CSS } from "../block/Elements.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getColorClass } from "../misc/Color.js";
|
|
3
|
+
import { getStatusClass } from "../misc/Status.js";
|
|
3
4
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
4
5
|
import BUTTON_CSS from "./Button.module.css";
|
|
5
6
|
import { getClickable } from "./Clickable.js";
|
|
@@ -16,6 +17,7 @@ export function Button({ disabled, href, onClick, title, target, download, child
|
|
|
16
17
|
download,
|
|
17
18
|
children,
|
|
18
19
|
}, getClass(ELEMENTS_BUTTON_CLASS, //
|
|
19
|
-
getModuleClass(BUTTON_CSS, variants), getModuleClass(ELEMENTS_CSS, variants), getStatusClass(variants)
|
|
20
|
+
getModuleClass(BUTTON_CSS, variants), getModuleClass(ELEMENTS_CSS, variants), getStatusClass(variants), // Buttons have status colours.
|
|
21
|
+
getColorClass(variants)));
|
|
20
22
|
}
|
|
21
23
|
export { BUTTON_CSS };
|
package/ui/form/Button.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { ELEMENTS_CSS, type ElementsVariants } from "../block/Elements.js";
|
|
3
|
-
import {
|
|
3
|
+
import { type ColorVariants, getColorClass } from "../misc/Color.js";
|
|
4
|
+
import { getStatusClass, type StatusVariants } from "../misc/Status.js";
|
|
4
5
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
6
|
import BUTTON_CSS from "./Button.module.css";
|
|
6
7
|
import { type ClickableProps, getClickable } from "./Clickable.js";
|
|
7
8
|
|
|
8
9
|
/** Variants for buttons. */
|
|
9
|
-
export interface ButtonVariants extends ElementsVariants, StatusVariants {
|
|
10
|
+
export interface ButtonVariants extends ElementsVariants, StatusVariants, ColorVariants {
|
|
10
11
|
/** This is the default button in a form and should be displayed stronger. */
|
|
11
12
|
strong?: boolean | undefined;
|
|
12
13
|
/** Add plain styling (background only appears on hover or focus). */
|
|
@@ -41,6 +42,7 @@ export function Button({ disabled, href, onClick, title, target, download, child
|
|
|
41
42
|
getModuleClass(BUTTON_CSS, variants),
|
|
42
43
|
getModuleClass(ELEMENTS_CSS, variants),
|
|
43
44
|
getStatusClass(variants), // Buttons have status colours.
|
|
45
|
+
getColorClass(variants), // Buttons can also have raw colour overrides.
|
|
44
46
|
),
|
|
45
47
|
);
|
|
46
48
|
}
|
package/ui/form/SubmitButton.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { ArrowRightIcon } from "@heroicons/react/24/solid";
|
|
3
3
|
import { useStore } from "../../react/useStore.js";
|
|
4
4
|
import { Loading } from "../misc/Loading.js";
|
|
5
|
-
import { getStatusClass } from "../
|
|
5
|
+
import { getStatusClass } from "../misc/Status.js";
|
|
6
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
7
7
|
import { BUTTON_CSS, ELEMENTS_BUTTON_CLASS } from "./Button.js";
|
|
8
8
|
import { requireForm } from "./FormContext.js";
|
package/ui/form/SubmitButton.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { ArrowRightIcon } from "@heroicons/react/24/solid";
|
|
|
2
2
|
import type { ReactElement, ReactNode } from "react";
|
|
3
3
|
import { useStore } from "../../react/useStore.js";
|
|
4
4
|
import { Loading } from "../misc/Loading.js";
|
|
5
|
-
import { getStatusClass } from "../
|
|
5
|
+
import { getStatusClass } from "../misc/Status.js";
|
|
6
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
7
7
|
import { BUTTON_CSS, type ButtonVariants, ELEMENTS_BUTTON_CLASS } from "./Button.js";
|
|
8
8
|
import { requireForm } from "./FormContext.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import COLOR_CSS from "./Color.module.css";
|
|
2
|
+
/** Variants for raw colours — pure hue overrides independent of semantic status. */
|
|
3
|
+
export type ColorVariants = {
|
|
4
|
+
/** Element has red colours. */
|
|
5
|
+
red?: boolean | undefined;
|
|
6
|
+
/** Element has orange colours. */
|
|
7
|
+
orange?: boolean | undefined;
|
|
8
|
+
/** Element has yellow colours. */
|
|
9
|
+
yellow?: boolean | undefined;
|
|
10
|
+
/** Element has green colours. */
|
|
11
|
+
green?: boolean | undefined;
|
|
12
|
+
/** Element has cyan colours. */
|
|
13
|
+
cyan?: boolean | undefined;
|
|
14
|
+
/** Element has blue colours. */
|
|
15
|
+
blue?: boolean | undefined;
|
|
16
|
+
/** Element has purple colours. */
|
|
17
|
+
purple?: boolean | undefined;
|
|
18
|
+
/** Element has pink colours. */
|
|
19
|
+
pink?: boolean | undefined;
|
|
20
|
+
};
|
|
21
|
+
/** Possible colour strings. */
|
|
22
|
+
export type Color = keyof ColorVariants;
|
|
23
|
+
/** Get a class for a colour. */
|
|
24
|
+
export declare function getColorClass(color: Color | ColorVariants): string | undefined;
|
|
25
|
+
export { COLOR_CSS };
|
package/ui/misc/Color.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* Red */
|
|
3
|
+
--red-text: var(--color-red);
|
|
4
|
+
--red-contrast: var(--color-white);
|
|
5
|
+
--red-surface: color-mix(in srgb, var(--red-text) 12%, white);
|
|
6
|
+
|
|
7
|
+
/* Orange */
|
|
8
|
+
--orange-text: var(--color-orange);
|
|
9
|
+
--orange-contrast: var(--color-black);
|
|
10
|
+
--orange-surface: color-mix(in srgb, var(--orange-text) 12%, white);
|
|
11
|
+
|
|
12
|
+
/* Yellow */
|
|
13
|
+
--yellow-text: var(--color-yellow);
|
|
14
|
+
--yellow-contrast: var(--color-black);
|
|
15
|
+
--yellow-surface: color-mix(in srgb, var(--yellow-text) 12%, white);
|
|
16
|
+
|
|
17
|
+
/* Green */
|
|
18
|
+
--green-text: var(--color-green);
|
|
19
|
+
--green-contrast: var(--color-black);
|
|
20
|
+
--green-surface: color-mix(in srgb, var(--green-text) 12%, white);
|
|
21
|
+
|
|
22
|
+
/* Cyan */
|
|
23
|
+
--cyan-text: var(--color-cyan);
|
|
24
|
+
--cyan-contrast: var(--color-black);
|
|
25
|
+
--cyan-surface: color-mix(in srgb, var(--cyan-text) 12%, white);
|
|
26
|
+
|
|
27
|
+
/* Blue */
|
|
28
|
+
--blue-text: var(--color-blue);
|
|
29
|
+
--blue-contrast: var(--color-white);
|
|
30
|
+
--blue-surface: color-mix(in srgb, var(--blue-text) 12%, white);
|
|
31
|
+
|
|
32
|
+
/* Purple */
|
|
33
|
+
--purple-text: var(--color-purple);
|
|
34
|
+
--purple-contrast: var(--color-white);
|
|
35
|
+
--purple-surface: color-mix(in srgb, var(--purple-text) 12%, white);
|
|
36
|
+
|
|
37
|
+
/* Pink */
|
|
38
|
+
--pink-text: var(--color-pink);
|
|
39
|
+
--pink-contrast: var(--color-white);
|
|
40
|
+
--pink-surface: color-mix(in srgb, var(--pink-text) 12%, white);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.red {
|
|
44
|
+
--color-text: var(--red-text);
|
|
45
|
+
--color-contrast: var(--red-contrast);
|
|
46
|
+
--color-link: var(--red-text);
|
|
47
|
+
--color-quiet: var(--red-text);
|
|
48
|
+
--color-surface: var(--red-surface);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.orange {
|
|
52
|
+
--color-text: var(--orange-text);
|
|
53
|
+
--color-contrast: var(--orange-contrast);
|
|
54
|
+
--color-link: var(--orange-text);
|
|
55
|
+
--color-quiet: var(--orange-text);
|
|
56
|
+
--color-surface: var(--orange-surface);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.yellow {
|
|
60
|
+
--color-text: var(--yellow-text);
|
|
61
|
+
--color-contrast: var(--yellow-contrast);
|
|
62
|
+
--color-link: var(--yellow-text);
|
|
63
|
+
--color-quiet: var(--yellow-text);
|
|
64
|
+
--color-surface: var(--yellow-surface);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.green {
|
|
68
|
+
--color-text: var(--green-text);
|
|
69
|
+
--color-contrast: var(--green-contrast);
|
|
70
|
+
--color-link: var(--green-text);
|
|
71
|
+
--color-quiet: var(--green-text);
|
|
72
|
+
--color-surface: var(--green-surface);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cyan {
|
|
76
|
+
--color-text: var(--cyan-text);
|
|
77
|
+
--color-contrast: var(--cyan-contrast);
|
|
78
|
+
--color-link: var(--cyan-text);
|
|
79
|
+
--color-quiet: var(--cyan-text);
|
|
80
|
+
--color-surface: var(--cyan-surface);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.blue {
|
|
84
|
+
--color-text: var(--blue-text);
|
|
85
|
+
--color-contrast: var(--blue-contrast);
|
|
86
|
+
--color-link: var(--blue-text);
|
|
87
|
+
--color-quiet: var(--blue-text);
|
|
88
|
+
--color-surface: var(--blue-surface);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.purple {
|
|
92
|
+
--color-text: var(--purple-text);
|
|
93
|
+
--color-contrast: var(--purple-contrast);
|
|
94
|
+
--color-link: var(--purple-text);
|
|
95
|
+
--color-quiet: var(--purple-text);
|
|
96
|
+
--color-surface: var(--purple-surface);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.pink {
|
|
100
|
+
--color-text: var(--pink-text);
|
|
101
|
+
--color-contrast: var(--pink-contrast);
|
|
102
|
+
--color-link: var(--pink-text);
|
|
103
|
+
--color-quiet: var(--pink-text);
|
|
104
|
+
--color-surface: var(--pink-surface);
|
|
105
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import COLOR_CSS from "./Color.module.css";
|
|
3
|
+
|
|
4
|
+
/** Variants for raw colours — pure hue overrides independent of semantic status. */
|
|
5
|
+
export type ColorVariants = {
|
|
6
|
+
/** Element has red colours. */
|
|
7
|
+
red?: boolean | undefined;
|
|
8
|
+
/** Element has orange colours. */
|
|
9
|
+
orange?: boolean | undefined;
|
|
10
|
+
/** Element has yellow colours. */
|
|
11
|
+
yellow?: boolean | undefined;
|
|
12
|
+
/** Element has green colours. */
|
|
13
|
+
green?: boolean | undefined;
|
|
14
|
+
/** Element has cyan colours. */
|
|
15
|
+
cyan?: boolean | undefined;
|
|
16
|
+
/** Element has blue colours. */
|
|
17
|
+
blue?: boolean | undefined;
|
|
18
|
+
/** Element has purple colours. */
|
|
19
|
+
purple?: boolean | undefined;
|
|
20
|
+
/** Element has pink colours. */
|
|
21
|
+
pink?: boolean | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Possible colour strings. */
|
|
25
|
+
export type Color = keyof ColorVariants;
|
|
26
|
+
|
|
27
|
+
/** Get a class for a colour. */
|
|
28
|
+
export function getColorClass(color: Color | ColorVariants): string | undefined {
|
|
29
|
+
return getModuleClass(COLOR_CSS, color);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { COLOR_CSS };
|
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* Primary colors */
|
|
3
|
+
--primary-text: var(--color-blue);
|
|
4
|
+
--primary-contrast: var(--color-white);
|
|
5
|
+
--primary-surface: color-mix(in srgb, var(--primary-text) 12%, white);
|
|
6
|
+
|
|
7
|
+
/* Secondary colors */
|
|
8
|
+
--secondary-text: var(--color-purple);
|
|
9
|
+
--secondary-contrast: var(--color-white);
|
|
10
|
+
--secondary-surface: color-mix(in srgb, var(--secondary-text) 12%, white);
|
|
11
|
+
|
|
12
|
+
/* Tertiary colors */
|
|
13
|
+
--tertiary-text: var(--color-cyan);
|
|
14
|
+
--tertiary-contrast: var(--color-white);
|
|
15
|
+
--tertiary-surface: color-mix(in srgb, var(--tertiary-text) 12%, white);
|
|
16
|
+
|
|
17
|
+
/* Quiet colors */
|
|
18
|
+
--quiet-text: var(--color-quiet);
|
|
19
|
+
--quiet-contrast: var(--color-contrast);
|
|
20
|
+
--quiet-surface: var(--color-surface);
|
|
21
|
+
|
|
22
|
+
/* Loading colors */
|
|
23
|
+
--loading-text: var(--color-loading);
|
|
24
|
+
--loading-contrast: var(--color-contrast);
|
|
25
|
+
--loading-surface: var(--color-surface);
|
|
26
|
+
|
|
27
|
+
/* Info colors */
|
|
28
|
+
--info-text: var(--color-blue);
|
|
29
|
+
--info-contrast: var(--color-white);
|
|
30
|
+
--info-surface: color-mix(in srgb, var(--info-text) 12%, white);
|
|
31
|
+
|
|
32
|
+
/* Success colors */
|
|
33
|
+
--success-text: var(--color-green);
|
|
34
|
+
--success-contrast: var(--color-white);
|
|
35
|
+
--success-surface: color-mix(in srgb, var(--success-text) 12%, white);
|
|
36
|
+
|
|
37
|
+
/* Warning colors */
|
|
38
|
+
--warning-text: var(--color-orange);
|
|
39
|
+
--warning-contrast: var(--color-white);
|
|
40
|
+
--warning-surface: color-mix(in srgb, var(--warning-text) 12%, white);
|
|
41
|
+
|
|
42
|
+
/* Error colors */
|
|
43
|
+
--error-text: var(--color-red);
|
|
44
|
+
--error-contrast: var(--color-white);
|
|
45
|
+
--error-surface: color-mix(in srgb, var(--error-text) 12%, white);
|
|
46
|
+
|
|
47
|
+
/* Danger colors */
|
|
48
|
+
--danger-text: var(--color-red);
|
|
49
|
+
--danger-contrast: var(--color-white);
|
|
50
|
+
--danger-surface: color-mix(in srgb, var(--danger-text) 12%, white);
|
|
51
|
+
|
|
52
|
+
/* Highlight colors */
|
|
53
|
+
--highlight-text: var(--color-yellow);
|
|
54
|
+
--highlight-contrast: var(--color-black);
|
|
55
|
+
--highlight-surface: color-mix(in srgb, var(--highlight-text) 12%, white);
|
|
56
|
+
}
|
|
57
|
+
|
|
1
58
|
.primary {
|
|
2
59
|
--color-text: var(--primary-text);
|
|
3
60
|
--color-contrast: var(--primary-contrast);
|
|
@@ -30,6 +87,14 @@
|
|
|
30
87
|
--color-surface: var(--quiet-surface);
|
|
31
88
|
}
|
|
32
89
|
|
|
90
|
+
.loading {
|
|
91
|
+
--color-text: var(--loading-text);
|
|
92
|
+
--color-contrast: var(--loading-contrast);
|
|
93
|
+
--color-link: var(--loading-text);
|
|
94
|
+
--color-quiet: var(--loading-text);
|
|
95
|
+
--color-surface: var(--loading-surface);
|
|
96
|
+
}
|
|
97
|
+
|
|
33
98
|
.info {
|
|
34
99
|
--color-text: var(--info-text);
|
|
35
100
|
--color-contrast: var(--info-contrast);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CheckCircleIcon, ExclamationTriangleIcon, InformationCircleIcon, XCircleIcon } from "@heroicons/react/24/solid";
|
|
3
|
-
import { Loading } from "../misc/Loading.js";
|
|
4
3
|
import { getModuleClass } from "../util/css.js";
|
|
4
|
+
import { Loading } from "./Loading.js";
|
|
5
5
|
import statusStyles from "./Status.module.css";
|
|
6
6
|
import styles from "./StatusIcon.module.css";
|
|
7
7
|
const STATUS_ICONS = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckCircleIcon, ExclamationTriangleIcon, InformationCircleIcon, XCircleIcon } from "@heroicons/react/24/solid";
|
|
2
2
|
import type { ComponentType, ReactElement } from "react";
|
|
3
|
-
import { Loading } from "../misc/Loading.js";
|
|
4
3
|
import { getModuleClass } from "../util/css.js";
|
|
4
|
+
import { Loading } from "./Loading.js";
|
|
5
5
|
import type { Status } from "./Status.js";
|
|
6
6
|
import statusStyles from "./Status.module.css";
|
|
7
7
|
import styles from "./StatusIcon.module.css";
|
package/ui/misc/Tag.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { type ClickableProps } from "../form/Clickable.js";
|
|
3
|
+
import { type ColorVariants } from "./Color.js";
|
|
4
|
+
import { type StatusVariants } from "./Status.js";
|
|
5
|
+
import TAG_CSS from "./Tag.module.css";
|
|
6
|
+
/** Variants for tags — accepts both status and raw colour variants. */
|
|
7
|
+
export interface TagVariants extends StatusVariants, ColorVariants {
|
|
8
|
+
/** Make the tag appear smaller. */
|
|
9
|
+
small?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface TagProps extends TagVariants, ClickableProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Small inline label used to annotate other content.
|
|
16
|
+
* - Delegates to `getClickable()` — renders as `<a>` when `href` is set, otherwise `<button>`.
|
|
17
|
+
* - Accepts a status variant (`success`, `info`, `error`, etc.) _or_ a raw colour variant (`red`, `blue`, `purple`, etc.).
|
|
18
|
+
*
|
|
19
|
+
* @example <Tag success>Active</Tag>
|
|
20
|
+
* @example <Tag purple href="/beta">Beta</Tag>
|
|
21
|
+
*/
|
|
22
|
+
export declare function Tag({ disabled, href, onClick, title, target, download, children, ...variants }: TagProps): ReactElement;
|
|
23
|
+
export { TAG_CSS };
|
package/ui/misc/Tag.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getClickable } from "../form/Clickable.js";
|
|
2
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
|
+
import { getColorClass } from "./Color.js";
|
|
4
|
+
import { getStatusClass } from "./Status.js";
|
|
5
|
+
import TAG_CSS from "./Tag.module.css";
|
|
6
|
+
/**
|
|
7
|
+
* Small inline label used to annotate other content.
|
|
8
|
+
* - Delegates to `getClickable()` — renders as `<a>` when `href` is set, otherwise `<button>`.
|
|
9
|
+
* - Accepts a status variant (`success`, `info`, `error`, etc.) _or_ a raw colour variant (`red`, `blue`, `purple`, etc.).
|
|
10
|
+
*
|
|
11
|
+
* @example <Tag success>Active</Tag>
|
|
12
|
+
* @example <Tag purple href="/beta">Beta</Tag>
|
|
13
|
+
*/
|
|
14
|
+
export function Tag({ disabled, href, onClick, title, target, download, children, ...variants }) {
|
|
15
|
+
return getClickable({ disabled, href, onClick, title, target, download, children }, getClass(TAG_CSS.tag, //
|
|
16
|
+
getModuleClass(TAG_CSS, variants), getStatusClass(variants), getColorClass(variants)));
|
|
17
|
+
}
|
|
18
|
+
export { TAG_CSS };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.tag {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
padding: 0 var(--spacing-small);
|
|
4
|
+
border: 0;
|
|
5
|
+
border-radius: var(--radius-inline);
|
|
6
|
+
background: var(--color-surface);
|
|
7
|
+
color: var(--color-text);
|
|
8
|
+
font-family: var(--font-body);
|
|
9
|
+
font-size: var(--size-small);
|
|
10
|
+
font-weight: var(--weight-strong);
|
|
11
|
+
line-height: var(--leading-tight);
|
|
12
|
+
text-transform: uppercase;
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
letter-spacing: 0.05em;
|
|
15
|
+
|
|
16
|
+
&.small {
|
|
17
|
+
font-size: calc(var(--size-small) * 0.85);
|
|
18
|
+
padding: 0 calc(var(--spacing-small) * 0.75);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
filter: brightness(0.95);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:focus-visible {
|
|
26
|
+
outline: var(--border-focus) solid var(--color-focus);
|
|
27
|
+
outline-offset: 2px;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/ui/misc/Tag.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { type ClickableProps, getClickable } from "../form/Clickable.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
4
|
+
import { type ColorVariants, getColorClass } from "./Color.js";
|
|
5
|
+
import { getStatusClass, type StatusVariants } from "./Status.js";
|
|
6
|
+
import TAG_CSS from "./Tag.module.css";
|
|
7
|
+
|
|
8
|
+
/** Variants for tags — accepts both status and raw colour variants. */
|
|
9
|
+
export interface TagVariants extends StatusVariants, ColorVariants {
|
|
10
|
+
/** Make the tag appear smaller. */
|
|
11
|
+
small?: boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TagProps extends TagVariants, ClickableProps {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Small inline label used to annotate other content.
|
|
20
|
+
* - Delegates to `getClickable()` — renders as `<a>` when `href` is set, otherwise `<button>`.
|
|
21
|
+
* - Accepts a status variant (`success`, `info`, `error`, etc.) _or_ a raw colour variant (`red`, `blue`, `purple`, etc.).
|
|
22
|
+
*
|
|
23
|
+
* @example <Tag success>Active</Tag>
|
|
24
|
+
* @example <Tag purple href="/beta">Beta</Tag>
|
|
25
|
+
*/
|
|
26
|
+
export function Tag({ disabled, href, onClick, title, target, download, children, ...variants }: TagProps): ReactElement {
|
|
27
|
+
return getClickable(
|
|
28
|
+
{ disabled, href, onClick, title, target, download, children },
|
|
29
|
+
getClass(
|
|
30
|
+
TAG_CSS.tag, //
|
|
31
|
+
getModuleClass(TAG_CSS, variants),
|
|
32
|
+
getStatusClass(variants),
|
|
33
|
+
getColorClass(variants),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { TAG_CSS };
|
package/ui/misc/index.d.ts
CHANGED
package/ui/misc/index.js
CHANGED
package/ui/misc/index.tsx
CHANGED
package/ui/notice/Message.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { type ParagraphProps } from "../block/Paragraph.js";
|
|
3
|
-
import { type
|
|
4
|
-
|
|
3
|
+
import { type ColorVariants } from "../misc/Color.js";
|
|
4
|
+
import { type Status } from "../misc/Status.js";
|
|
5
|
+
export interface MessageProps extends ParagraphProps, ColorVariants {
|
|
5
6
|
children?: ReactNode;
|
|
6
7
|
/** Status of the message (defaults to "error") */
|
|
7
8
|
status?: Status | undefined;
|
package/ui/notice/Message.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { PARAGRAPH_CSS } from "../block/Paragraph.js";
|
|
3
|
+
import { getColorClass } from "../misc/Color.js";
|
|
3
4
|
import { LOADING } from "../misc/Loading.js";
|
|
5
|
+
import { getStatusClass } from "../misc/Status.js";
|
|
4
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
7
|
import MESSAGE_CSS from "./Message.module.css";
|
|
6
|
-
import { getStatusClass } from "./Status.js";
|
|
7
8
|
/** Paragraph with status colours. */
|
|
8
9
|
export function Message({ children, status = "info", ...variants }) {
|
|
9
10
|
return (_jsx("p", { role: status === "error" || status === "danger" ? "alert" : "status", className: getClass(getModuleClass(PARAGRAPH_CSS, "paragraph", variants), //
|
|
10
|
-
MESSAGE_CSS.message, getStatusClass(status)), children: children }));
|
|
11
|
+
MESSAGE_CSS.message, getStatusClass(status), getColorClass(variants)), children: children }));
|
|
11
12
|
}
|
|
12
13
|
export const LOADING_MESSAGE = _jsx(Message, { status: "loading", children: LOADING });
|
package/ui/notice/Message.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { PARAGRAPH_CSS, type ParagraphProps } from "../block/Paragraph.js";
|
|
3
|
+
import { type ColorVariants, getColorClass } from "../misc/Color.js";
|
|
3
4
|
import { LOADING } from "../misc/Loading.js";
|
|
5
|
+
import { getStatusClass, type Status } from "../misc/Status.js";
|
|
4
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
7
|
import MESSAGE_CSS from "./Message.module.css";
|
|
6
|
-
import { getStatusClass, type Status } from "./Status.js";
|
|
7
8
|
|
|
8
|
-
export interface MessageProps extends ParagraphProps {
|
|
9
|
+
export interface MessageProps extends ParagraphProps, ColorVariants {
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
/** Status of the message (defaults to "error") */
|
|
11
12
|
status?: Status | undefined;
|
|
@@ -20,6 +21,7 @@ export function Message({ children, status = "info", ...variants }: MessageProps
|
|
|
20
21
|
getModuleClass(PARAGRAPH_CSS, "paragraph", variants), //
|
|
21
22
|
MESSAGE_CSS.message,
|
|
22
23
|
getStatusClass(status),
|
|
24
|
+
getColorClass(variants),
|
|
23
25
|
)}
|
|
24
26
|
>
|
|
25
27
|
{children}
|
package/ui/notice/Notice.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { type ElementsVariants } from "../block/Elements.js";
|
|
3
|
+
import { type ColorVariants } from "../misc/Color.js";
|
|
4
|
+
import { type Status } from "../misc/Status.js";
|
|
3
5
|
import NOTICE_CSS from "./Notice.module.css";
|
|
4
|
-
|
|
5
|
-
export interface NoticeProps extends ElementsVariants {
|
|
6
|
+
export interface NoticeProps extends ElementsVariants, ColorVariants {
|
|
6
7
|
/** Status for the notice. */
|
|
7
8
|
status?: Status | undefined;
|
|
8
9
|
/** Children for the notice. */
|
package/ui/notice/Notice.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ELEMENT_CSS } from "../block/Element.js";
|
|
3
3
|
import { ELEMENTS_CSS } from "../block/Elements.js";
|
|
4
|
+
import { getColorClass } from "../misc/Color.js";
|
|
5
|
+
import { getStatusClass } from "../misc/Status.js";
|
|
6
|
+
import { StatusIcon } from "../misc/StatusIcon.js";
|
|
4
7
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
8
|
import NOTICE_CSS from "./Notice.module.css";
|
|
6
|
-
import { getStatusClass } from "./Status.js";
|
|
7
|
-
import { StatusIcon } from "./StatusIcon.js";
|
|
8
9
|
export function Notice({ children, status = children ? "info" : "loading", icon = _jsx(StatusIcon, { status: status }), ...variants }) {
|
|
9
10
|
return (_jsxs("aside", { role: status === "danger" || status === "error" ? "alert" : "status", className: getClass(ELEMENT_CSS.element, getModuleClass(NOTICE_CSS, "notice", variants), //
|
|
10
|
-
getModuleClass(ELEMENTS_CSS, "elements", variants), getStatusClass(status)
|
|
11
|
+
getModuleClass(ELEMENTS_CSS, "elements", variants), getStatusClass(status), // Notices have status colours.
|
|
12
|
+
getColorClass(variants)), children: [icon, children] }));
|
|
11
13
|
}
|
|
12
14
|
export const LOADING_NOTICE = _jsx(Notice, { status: "loading" });
|
|
13
15
|
export { NOTICE_CSS };
|
package/ui/notice/Notice.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { ELEMENT_CSS } from "../block/Element.js";
|
|
3
3
|
import { ELEMENTS_CSS, type ElementsVariants } from "../block/Elements.js";
|
|
4
|
+
import { type ColorVariants, getColorClass } from "../misc/Color.js";
|
|
5
|
+
import { getStatusClass, type Status } from "../misc/Status.js";
|
|
6
|
+
import { StatusIcon } from "../misc/StatusIcon.js";
|
|
4
7
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
8
|
import NOTICE_CSS from "./Notice.module.css";
|
|
6
|
-
import { getStatusClass, type Status } from "./Status.js";
|
|
7
|
-
import { StatusIcon } from "./StatusIcon.js";
|
|
8
9
|
|
|
9
|
-
export interface NoticeProps extends ElementsVariants {
|
|
10
|
+
export interface NoticeProps extends ElementsVariants, ColorVariants {
|
|
10
11
|
/** Status for the notice. */
|
|
11
12
|
status?: Status | undefined;
|
|
12
13
|
/** Children for the notice. */
|
|
@@ -28,7 +29,8 @@ export function Notice({
|
|
|
28
29
|
ELEMENT_CSS.element,
|
|
29
30
|
getModuleClass(NOTICE_CSS, "notice", variants), //
|
|
30
31
|
getModuleClass(ELEMENTS_CSS, "elements", variants),
|
|
31
|
-
getStatusClass(status), //
|
|
32
|
+
getStatusClass(status), // Notices have status colours.
|
|
33
|
+
getColorClass(variants), // Notices can also have raw colour overrides.
|
|
32
34
|
)}
|
|
33
35
|
>
|
|
34
36
|
{icon}
|
|
@@ -8,4 +8,4 @@ export declare class NoticesStore<S extends string> extends ArrayStore<NoticeSto
|
|
|
8
8
|
[Symbol.asyncDispose](): Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
/** Create a global list of shown notices allowing any of the default statuses. */
|
|
11
|
-
export declare const NOTICES: NoticesStore<keyof import("
|
|
11
|
+
export declare const NOTICES: NoticesStore<keyof import("../misc/Status.js").StatusVariants>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { ArrayStore } from "../../store/ArrayStore.js";
|
|
3
3
|
import { awaitDispose } from "../../util/dispose.js";
|
|
4
|
+
import type { Status } from "../misc/Status.js";
|
|
4
5
|
import { NoticeStore } from "./NoticeStore.js";
|
|
5
|
-
import type { Status } from "./Status.js";
|
|
6
6
|
|
|
7
7
|
/** Store a list of notices. */
|
|
8
8
|
export class NoticesStore<S extends string> extends ArrayStore<NoticeStore<S>> {
|
package/ui/notice/index.d.ts
CHANGED
package/ui/notice/index.js
CHANGED
package/ui/notice/index.ts
CHANGED
package/ui/util/notice.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { Arguments } from "../../util/function.js";
|
|
3
|
-
import type { Status } from "../
|
|
3
|
+
import type { Status } from "../misc/Status.js";
|
|
4
4
|
/**
|
|
5
5
|
* Notify the user with a message by dispatching a notice event.
|
|
6
6
|
* - This is how e.g. `<Button>` and `<FormNotify>` components send notices to the `<Notices>` list of global notices.
|
package/ui/util/notice.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import { isAsync } from "../../util/async.js";
|
|
3
3
|
import { getMessage } from "../../util/error.js";
|
|
4
4
|
import type { Arguments } from "../../util/function.js";
|
|
5
|
-
import type { Status } from "../
|
|
5
|
+
import type { Status } from "../misc/Status.js";
|
|
6
6
|
|
|
7
7
|
// Constants.
|
|
8
8
|
const NOTICE_EVENT = "notice";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|