@supersoniks/concorde 5.0.4 → 5.1.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/.agents/skills/concorde-component-docs/SKILL.md +194 -0
- package/.agents/skills/concorde-component-docs/template.md +45 -0
- package/.tmp-cem/custom-elements.json +13705 -0
- package/ai/cursor/rules/concorde-theme.mdc +1 -1
- package/ai/cursor/rules/concorde.mdc +1 -1
- package/ai/skills/concorde/SKILL.md +1 -1
- package/ai/skills/concorde-theme/SKILL.md +21 -10
- package/build-infos.json +1 -1
- package/concorde-3d.bundle.js +3960 -0
- package/concorde-3d.es.js +33433 -0
- package/concorde-core.bundle.js +507 -513
- package/concorde-core.es.js +4027 -3702
- package/concorde-hugging-face-infer.bundle.js +32 -0
- package/concorde-hugging-face-infer.es.js +2952 -0
- package/concorde-interactive.bundle.js +1157 -0
- package/concorde-interactive.es.js +10734 -0
- package/concorde-shader.bundle.js +116 -0
- package/concorde-shader.es.js +8353 -0
- package/concorde-webgpu.bundle.js +307 -0
- package/concorde-webgpu.es.js +8627 -0
- package/custom-elements-manifest.config.mjs +14 -0
- package/dist/concorde-core.bundle.js +507 -513
- package/dist/concorde-core.es.js +4027 -3702
- package/dist/docs-mock-api-sw.js +2 -0
- package/dist/docs-mock-api-sw.js.map +2 -2
- package/gitlab/job_tests.sh +0 -0
- package/index.html +4 -2
- package/package.json +42 -2
- package/public/docs-mock-api-sw.js +2 -0
- package/public/docs-mock-api-sw.js.map +2 -2
- package/scripts/generate-sdui-catalog.mjs +250 -0
- package/scripts/generate-sdui-catalog.spec.ts +91 -0
- package/scripts/pre-build.mjs +15 -0
- package/src/core/components/functional/if/if.ts +0 -0
- package/src/core/components/functional/sdui/SDUIDescriptorTransformer.ts +5 -5
- package/src/core/components/functional/sdui/__fixtures__/descriptors.ts +251 -0
- package/src/core/components/functional/sdui/__snapshots__/sdui-action.spec.ts.snap +73 -0
- package/src/core/components/functional/sdui/__snapshots__/sdui-incremental.spec.ts.snap +50 -0
- package/src/core/components/functional/sdui/__snapshots__/sdui-partial.spec.ts.snap +50 -0
- package/src/core/components/functional/sdui/__snapshots__/sdui.regression.spec.ts.snap +461 -0
- package/src/core/components/functional/sdui/component-catalog.gaps.json +511 -0
- package/src/core/components/functional/sdui/component-catalog.json +3103 -0
- package/src/core/components/functional/sdui/component-catalog.spec.ts +23 -0
- package/src/core/components/functional/sdui/sdui-action.spec.ts +99 -0
- package/src/core/components/functional/sdui/sdui-dom-snapshot.ts +61 -0
- package/src/core/components/functional/sdui/sdui-extension-points.md +94 -0
- package/src/core/components/functional/sdui/sdui-incremental.spec.ts +137 -0
- package/src/core/components/functional/sdui/sdui-partial.spec.ts +83 -0
- package/src/core/components/functional/sdui/sdui-partial.ts +19 -0
- package/src/core/components/functional/sdui/sdui-safe.spec.ts +188 -0
- package/src/core/components/functional/sdui/sdui-safe.ts +100 -0
- package/src/core/components/functional/sdui/sdui.md +122 -0
- package/src/core/components/functional/sdui/sdui.regression.spec.ts +64 -0
- package/src/core/components/functional/sdui/sdui.ts +442 -34
- package/src/core/components/functional/sdui/types.ts +49 -0
- package/src/core/components/functional/value/value.ts +0 -0
- package/src/core/components/ui/_css/align.ts +1 -0
- package/src/core/components/ui/_css/type.ts +86 -8
- package/src/core/components/ui/_i18n/ui-aria-labels.ts +8 -0
- package/src/core/components/ui/alert/alert.md +21 -2
- package/src/core/components/ui/alert-messages/alert-messages.md +85 -0
- package/src/core/components/ui/badge/badge.md +19 -6
- package/src/core/components/ui/badge/badge.ts +8 -9
- package/src/core/components/ui/button/button.ts +5 -15
- package/src/core/components/ui/captcha/captcha.md +65 -6
- package/src/core/components/ui/card/card.md +73 -10
- package/src/core/components/ui/card/card.ts +24 -22
- package/src/core/components/ui/divider/divider.md +107 -13
- package/src/core/components/ui/divider/divider.ts +40 -33
- package/src/core/components/ui/form/fieldset/fieldset.md +175 -99
- package/src/core/components/ui/form/fieldset/fieldset.ts +15 -28
- package/src/core/components/ui/form/fieldset/legend.ts +13 -13
- package/src/core/components/ui/form/form-actions/form-actions.md +75 -52
- package/src/core/components/ui/form/form-actions/form-actions.ts +7 -5
- package/src/core/components/ui/form/form-layout/form-layout.md +109 -34
- package/src/core/components/ui/form/form-layout/form-layout.ts +27 -24
- package/src/core/components/ui/form/textarea/textarea.ts +4 -3
- package/src/core/components/ui/group/group.md +36 -36
- package/src/core/components/ui/group/group.ts +5 -10
- package/src/core/components/ui/icon/icon.md +132 -43
- package/src/core/components/ui/image/image.md +35 -3
- package/src/core/components/ui/link/link.md +43 -5
- package/src/core/components/ui/loader/loader.md +79 -22
- package/src/core/components/ui/loader/loader.ts +67 -27
- package/src/core/components/ui/loader/styles/fixed.ts +6 -11
- package/src/core/components/ui/menu/menu.md +133 -92
- package/src/core/components/ui/menu/menu.ts +53 -58
- package/src/core/components/ui/modal/modal.md +163 -47
- package/src/core/components/ui/modal/modal.ts +2 -4
- package/src/core/components/ui/pop/pop.md +217 -123
- package/src/core/components/ui/pop/pop.ts +0 -1
- package/src/core/components/ui/progress/progress.md +76 -30
- package/src/core/components/ui/progress/progress.ts +25 -56
- package/src/core/components/ui/table/table-caption.ts +2 -2
- package/src/core/components/ui/table/table-tbody.ts +3 -3
- package/src/core/components/ui/table/table-td.ts +23 -18
- package/src/core/components/ui/table/table-th.ts +8 -8
- package/src/core/components/ui/table/table-tr.ts +4 -4
- package/src/core/components/ui/table/table.md +147 -171
- package/src/core/components/ui/table/table.ts +20 -19
- package/src/core/components/ui/theme/theme-collection/auto.ts +15 -0
- package/src/core/components/ui/theme/theme-collection/core-variables.ts +8 -31
- package/src/core/components/ui/theme/theme-collection/dark.ts +1 -7
- package/src/core/components/ui/theme/theme-collection/light.ts +30 -26
- package/src/core/components/ui/theme/theme.md +122 -0
- package/src/core/components/ui/theme/theme.ts +30 -7
- package/src/core/components/ui/toast/toast-item.ts +6 -9
- package/src/core/components/ui/toast/toast.md +108 -58
- package/src/core/components/ui/toast/types.ts +1 -1
- package/src/core/components/ui/tooltip/tooltip.md +68 -26
- package/src/docs/_getting-started/start.md +1 -1
- package/src/docs/_getting-started/theming.md +223 -61
- package/src/docs/code.ts +125 -58
- package/src/docs/header/header.ts +62 -54
- package/src/docs/mock-api/router.ts +2 -0
- package/src/docs/navigation/navigation.ts +6 -3
- package/src/docs/search/docs-search.json +2504 -399
- package/src/docs/search/markdown-renderer.ts +6 -6
- package/src/docs/search/search.ts +4 -4
- package/src/docs/tailwind/css/tailwind.css +6 -5
- package/src/tsconfig.json +108 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/tailwind.config.js +19 -0
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import { css } from "lit";
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export const lightCss = css`
|
|
4
|
+
/*Boutons*/
|
|
5
|
+
--sc-primary: var(--sc-base-800);
|
|
6
|
+
--sc-info: #2563eb;
|
|
7
|
+
--sc-danger: #f43f5e;
|
|
8
|
+
--sc-warning: #f97316;
|
|
9
|
+
--sc-success: #14b8a6;
|
|
10
|
+
|
|
11
|
+
--sc-primary-content: var(--sc-base, #fff);
|
|
12
|
+
--sc-info-content: var(--sc-base, #fff);
|
|
13
|
+
--sc-danger-content: var(--sc-base, #fff);
|
|
14
|
+
--sc-warning-content: var(--sc-base, #fff);
|
|
15
|
+
--sc-success-content: var(--sc-base, #fff);
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
/*Bases*/
|
|
18
|
+
--sc-base: #fff;
|
|
19
|
+
--sc-base-50: #f8fafc;
|
|
20
|
+
--sc-base-100: #f1f5f9;
|
|
21
|
+
--sc-base-200: #e2e8f0;
|
|
22
|
+
--sc-base-300: #cbd5e1;
|
|
23
|
+
--sc-base-400: #94a3b8;
|
|
24
|
+
--sc-base-500: #64748b;
|
|
25
|
+
--sc-base-600: #475569;
|
|
26
|
+
--sc-base-700: #334155;
|
|
27
|
+
--sc-base-800: #1e293b;
|
|
28
|
+
--sc-base-900: #0f172a;
|
|
29
|
+
--sc-base-content: var(--sc-base-700);
|
|
30
|
+
`;
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
--sc-base-100: #f1f5f9;
|
|
22
|
-
--sc-base-200: #e2e8f0;
|
|
23
|
-
--sc-base-300: #cbd5e1;
|
|
24
|
-
--sc-base-400: #94a3b8;
|
|
25
|
-
--sc-base-500: #64748b;
|
|
26
|
-
--sc-base-600: #475569;
|
|
27
|
-
--sc-base-700: #334155;
|
|
28
|
-
--sc-base-800: #1e293b;
|
|
29
|
-
--sc-base-900: #0f172a;
|
|
30
|
-
--sc-base-content: var(--sc-base-700);
|
|
32
|
+
export const light = css`
|
|
33
|
+
:host([theme="light"]) {
|
|
34
|
+
${lightCss}
|
|
31
35
|
}
|
|
32
36
|
`;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Theme
|
|
2
|
+
|
|
3
|
+
**`sonic-theme`** wraps a Concorde UI: it registers **`--sc-*`** design tokens and provides the default slot for your app. With no **`theme`** attribute (or **`theme="custom"`**), only shared primitives and your overrides apply—built-in **`light`** / **`dark`** / **`auto`** palettes are opt-in. Set **`color`** and **`font`** when the host should carry base text and typography; add Tailwind **`bg-base`** and **`block`** (or **`min-h-screen`**) on the tag for a full surface fill. **Popovers**, **modals**, and **toasts** mount under the nearest connected theme (see [Pop container](#pop-container)). Import **`@supersoniks/concorde/theme`** once at the app entry. For the full public token list and brand overrides, see [Customization](#docs/_getting-started/theming.md/theming).
|
|
4
|
+
|
|
5
|
+
## Basic example
|
|
6
|
+
|
|
7
|
+
Wrap interactive components so tokens and overlays resolve from one root.
|
|
8
|
+
|
|
9
|
+
<sonic-code>
|
|
10
|
+
<template>
|
|
11
|
+
<sonic-theme color font class="block bg-base p-6 rounded-lg">
|
|
12
|
+
<sonic-button type="primary">Save changes</sonic-button>
|
|
13
|
+
</sonic-theme>
|
|
14
|
+
</template>
|
|
15
|
+
</sonic-code>
|
|
16
|
+
|
|
17
|
+
## Theme mode
|
|
18
|
+
|
|
19
|
+
**Default:** omit **`theme`** or set **`theme="custom"`**. The host loads core tokens (`--sc-rounded`, shadows, form defaults, …) and any **`--sc-*`** you set; it does **not** apply the built-in light or dark palette.
|
|
20
|
+
|
|
21
|
+
Set **`theme`** to **`light`** or **`dark`** for Concorde’s preset palettes. Set **`theme="auto"`** to follow **`prefers-color-scheme`** (light palette until the OS prefers dark).
|
|
22
|
+
|
|
23
|
+
<sonic-code>
|
|
24
|
+
<template>
|
|
25
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
26
|
+
<sonic-theme theme="light" color font class="block bg-base p-4 rounded-md border border-neutral-200">
|
|
27
|
+
<p class="text-sm mb-3 opacity-80">theme="light"</p>
|
|
28
|
+
<div class="flex flex-wrap gap-2">
|
|
29
|
+
<sonic-badge type="primary">Primary</sonic-badge>
|
|
30
|
+
<sonic-badge type="success">Success</sonic-badge>
|
|
31
|
+
<sonic-badge type="danger">Danger</sonic-badge>
|
|
32
|
+
</div>
|
|
33
|
+
</sonic-theme>
|
|
34
|
+
<sonic-theme theme="dark" color font class="block bg-base p-4 rounded-md">
|
|
35
|
+
<p class="text-sm mb-3 opacity-80">theme="dark"</p>
|
|
36
|
+
<div class="flex flex-wrap gap-2">
|
|
37
|
+
<sonic-badge type="primary">Primary</sonic-badge>
|
|
38
|
+
<sonic-badge type="success">Success</sonic-badge>
|
|
39
|
+
<sonic-badge type="danger">Danger</sonic-badge>
|
|
40
|
+
</div>
|
|
41
|
+
</sonic-theme>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
</sonic-code>
|
|
45
|
+
|
|
46
|
+
## Presentation
|
|
47
|
+
|
|
48
|
+
**`color`** sets text from **`--sc-base-content`**. **`font`** applies **`--sc-font-family-base`**, **`--sc-font-weight-base`**, and **`--sc-font-style-base`**. For the page or shell background, use **`bg-base`** on **`sonic-theme`** (maps to **`--sc-base`** in Tailwind) with **`block`** so the host paints the surface. Components keep their own fallbacks when **`color`** / **`font`** are omitted.
|
|
49
|
+
|
|
50
|
+
<sonic-code>
|
|
51
|
+
<template>
|
|
52
|
+
<sonic-theme theme="light" color font class="block bg-base p-6 min-h-[8rem] rounded-lg">
|
|
53
|
+
<p>Body copy inherits base content color and font from the theme host.</p>
|
|
54
|
+
</sonic-theme>
|
|
55
|
+
</template>
|
|
56
|
+
</sonic-code>
|
|
57
|
+
|
|
58
|
+
## Custom tokens
|
|
59
|
+
|
|
60
|
+
Override **primitives** on **`sonic-theme`** (or **`:root`** / a project stylesheet). Derived radii, shadows, and control rounding are computed from tokens such as **`--sc-rounded`**—avoid copying long lists of internal variables unless you have a specific need.
|
|
61
|
+
|
|
62
|
+
<sonic-code>
|
|
63
|
+
<template>
|
|
64
|
+
<sonic-theme
|
|
65
|
+
theme="custom"
|
|
66
|
+
color
|
|
67
|
+
font
|
|
68
|
+
class="block bg-base p-6 rounded-lg"
|
|
69
|
+
style="--sc-primary: #353429; --sc-rounded: 0.25rem;"
|
|
70
|
+
>
|
|
71
|
+
<sonic-button type="primary">Brand primary</sonic-button>
|
|
72
|
+
</sonic-theme>
|
|
73
|
+
</template>
|
|
74
|
+
</sonic-code>
|
|
75
|
+
|
|
76
|
+
## Pop container
|
|
77
|
+
|
|
78
|
+
**`Theme.getPopContainer()`** returns the last connected **`sonic-theme`**, or **`document.body`** if none is connected. When a theme disconnects, the previous connected instance is adopted. Imperative **`Modal.create()`** and declarative **`sonic-modal`** use the same container.
|
|
79
|
+
|
|
80
|
+
<sonic-code>
|
|
81
|
+
<template>
|
|
82
|
+
<sonic-theme theme="light" color font class="block bg-base p-4 rounded-lg">
|
|
83
|
+
<sonic-button onclick="document.getElementById('themePopModal').show()">
|
|
84
|
+
Open modal
|
|
85
|
+
</sonic-button>
|
|
86
|
+
<sonic-modal id="themePopModal">
|
|
87
|
+
<sonic-modal-title>Mounted on theme</sonic-modal-title>
|
|
88
|
+
<sonic-modal-content>
|
|
89
|
+
This dialog is appended under the nearest sonic-theme pop container.
|
|
90
|
+
</sonic-modal-content>
|
|
91
|
+
<sonic-modal-actions>
|
|
92
|
+
<sonic-button hideModal>Close</sonic-button>
|
|
93
|
+
</sonic-modal-actions>
|
|
94
|
+
</sonic-modal>
|
|
95
|
+
</sonic-theme>
|
|
96
|
+
</template>
|
|
97
|
+
</sonic-code>
|
|
98
|
+
|
|
99
|
+
## Embedded iframes
|
|
100
|
+
|
|
101
|
+
On connect, the theme publishes resolved **`--sc-*`** values and linked font stylesheet URLs (Google Fonts / Adobe Fonts) to the **`sonic-theme`** data channel and **`postMessage`**s them to same-page iframes. Iframes can request a refresh by posting **`{ type: "GetSonicTheme" }`**.
|
|
102
|
+
|
|
103
|
+
<sonic-code language="javascript">
|
|
104
|
+
<template>
|
|
105
|
+
// Inside the iframe — ask the parent theme to rebroadcast tokens
|
|
106
|
+
window.parent.postMessage({ type: "GetSonicTheme" }, "*");
|
|
107
|
+
</template>
|
|
108
|
+
</sonic-code>
|
|
109
|
+
|
|
110
|
+
## API reference
|
|
111
|
+
|
|
112
|
+
| Attribute | Values | Description |
|
|
113
|
+
|----------|---------|-------------|
|
|
114
|
+
| `theme` | omitted · `custom` (default) · `light` · `dark` · `auto` | Omitted or `custom`: core tokens and your `--sc-*` only. `light` / `dark`: fixed presets. `auto`: presets follow `prefers-color-scheme` |
|
|
115
|
+
| `color` | boolean | Host text color uses `--sc-base-content` |
|
|
116
|
+
| `font` | boolean | Host font uses `--sc-font-family-base` and related base weight/style tokens |
|
|
117
|
+
|
|
118
|
+
| Slot | Description |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| *(default)* | Application markup and Concorde components |
|
|
121
|
+
|
|
122
|
+
Surface background: Tailwind **`bg-base`** on **`sonic-theme`** (requires Concorde Tailwind color **`base`** → **`--sc-base`**).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { html, LitElement, css } from "lit";
|
|
2
2
|
import { customElement, property } from "lit/decorators.js";
|
|
3
3
|
import { coreVariables } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/core-variables";
|
|
4
|
+
import { auto } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/auto";
|
|
4
5
|
import { light } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/light";
|
|
5
6
|
import { dark } from "@supersoniks/concorde/core/components/ui/theme/theme-collection/dark";
|
|
6
7
|
import { PublisherManager } from "@supersoniks/concorde/utils";
|
|
@@ -12,6 +13,7 @@ export class Theme extends LitElement {
|
|
|
12
13
|
static styles = [
|
|
13
14
|
light,
|
|
14
15
|
dark,
|
|
16
|
+
auto,
|
|
15
17
|
coreVariables,
|
|
16
18
|
css`
|
|
17
19
|
:host([color]) {
|
|
@@ -50,32 +52,53 @@ export class Theme extends LitElement {
|
|
|
50
52
|
|
|
51
53
|
static instance: Theme | undefined;
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
private readonly onWindowMessage = (event: MessageEvent) =>
|
|
56
|
+
this.receiveMessage(event);
|
|
57
|
+
|
|
58
|
+
/** Last connected `<sonic-theme>`; used as the portal root for overlays. */
|
|
59
|
+
private static adoptPopContainerInstance(exclude?: Theme) {
|
|
60
|
+
Theme.instance = undefined;
|
|
61
|
+
const themes = document.querySelectorAll(tagName);
|
|
62
|
+
for (let i = themes.length - 1; i >= 0; i--) {
|
|
63
|
+
const elt = themes[i];
|
|
64
|
+
if (elt !== exclude && elt instanceof Theme && elt.isConnected) {
|
|
65
|
+
Theme.instance = elt;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
/**
|
|
59
72
|
* retourne le conteneur de tout ce qui pop : popups / modale / tooltip? / dropdown / ...
|
|
60
73
|
*/
|
|
61
74
|
public static getPopContainer() {
|
|
62
|
-
|
|
75
|
+
if (Theme.instance?.isConnected) return Theme.instance;
|
|
76
|
+
Theme.adoptPopContainerInstance();
|
|
77
|
+
return Theme.instance ?? document.body;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
@property({ type: String, reflect: true })
|
|
66
|
-
theme?: "light" | "dark";
|
|
81
|
+
theme?: "light" | "dark" | "auto" | "custom";
|
|
67
82
|
|
|
68
|
-
@property({ type: Boolean, reflect: true }) background = false;
|
|
69
83
|
@property({ type: Boolean, reflect: true }) color = false;
|
|
70
84
|
@property({ type: Boolean, reflect: true }) font = false;
|
|
71
85
|
|
|
72
86
|
connectedCallback(): void {
|
|
73
87
|
super.connectedCallback();
|
|
74
|
-
|
|
88
|
+
Theme.instance = this;
|
|
89
|
+
window.addEventListener("message", this.onWindowMessage, false);
|
|
75
90
|
window.dispatchEvent(new CustomEvent("SonicThemeReady"));
|
|
76
91
|
this.postCSSVars();
|
|
77
92
|
}
|
|
78
93
|
|
|
94
|
+
disconnectedCallback(): void {
|
|
95
|
+
window.removeEventListener("message", this.onWindowMessage, false);
|
|
96
|
+
if (Theme.instance === this) {
|
|
97
|
+
Theme.adoptPopContainerInstance(this);
|
|
98
|
+
}
|
|
99
|
+
super.disconnectedCallback();
|
|
100
|
+
}
|
|
101
|
+
|
|
79
102
|
postCSSVars() {
|
|
80
103
|
const stylesheets = document.styleSheets;
|
|
81
104
|
const ssLength = stylesheets.length;
|
|
@@ -148,19 +148,16 @@ export class SonicToastItem extends LitElement {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/*STATUS — accent via statusColor (--sc-_color) */
|
|
151
|
-
:host([status]) .sonic-toast
|
|
151
|
+
:host([status="success"]) .sonic-toast,
|
|
152
|
+
:host([status="error"]) .sonic-toast,
|
|
153
|
+
:host([status="info"]) .sonic-toast,
|
|
154
|
+
:host([status="warning"]) .sonic-toast {
|
|
152
155
|
border-top: 3px solid var(--sc-_color);
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
:host([status="success"]) .sonic-toast:before,
|
|
156
|
-
:host([status="error"]) .sonic-toast:before,
|
|
157
|
-
:host([status="info"]) .sonic-toast:before,
|
|
158
|
-
:host([status="warning"]) .sonic-toast:before {
|
|
159
|
-
background-color: var(--sc-_color);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
158
|
.sonic-toast:before {
|
|
163
159
|
content: "";
|
|
160
|
+
background-color: var(--sc-_color);
|
|
164
161
|
display: block;
|
|
165
162
|
position: absolute;
|
|
166
163
|
left: 0;
|
|
@@ -192,7 +189,7 @@ export class SonicToastItem extends LitElement {
|
|
|
192
189
|
@property() label: ToastContent = "";
|
|
193
190
|
@property({ type: String }) id = "";
|
|
194
191
|
@property() text: ToastContent = "";
|
|
195
|
-
@property({ type: String, reflect: true }) status
|
|
192
|
+
@property({ type: String, reflect: true }) status?: ToastStatus;
|
|
196
193
|
@property({ type: Boolean }) ghost = false;
|
|
197
194
|
@property({ type: Boolean }) preserve = false;
|
|
198
195
|
@property({ type: Boolean }) dismissForever = false;
|
|
@@ -1,166 +1,216 @@
|
|
|
1
1
|
# Toast
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Toasts surface **short-lived feedback** in a fixed stack (bottom-right in the main window). Queue messages with **`SonicToast.add()`** on the global **`SonicToast`** class—the host **`sonic-toast`** is created automatically. Prefer **`label`** for a heading; use **`preserve`** or interactive **`text`** when the user must read or act before dismiss.
|
|
4
|
+
|
|
5
|
+
## Basic example
|
|
6
|
+
|
|
7
|
+
Click the button to show a toast.
|
|
4
8
|
|
|
5
9
|
<sonic-code>
|
|
6
10
|
<template>
|
|
7
|
-
<sonic-button onclick="
|
|
8
|
-
|
|
11
|
+
<sonic-button onclick="SonicToast.add({ text: 'Simple notification' })">
|
|
12
|
+
Show toast
|
|
9
13
|
</sonic-button>
|
|
10
14
|
</template>
|
|
11
15
|
</sonic-code>
|
|
12
16
|
|
|
13
|
-
##
|
|
17
|
+
## Status
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
**`status`** drives color, icon, and live-region behavior. Omit **`status`** or pass an empty string for a neutral toast.
|
|
16
20
|
|
|
17
21
|
<sonic-code>
|
|
18
22
|
<template>
|
|
19
23
|
<div class="flex flex-wrap gap-2">
|
|
20
|
-
<sonic-button onclick="
|
|
24
|
+
<sonic-button onclick="SonicToast.add({ text: 'Default message', status: '' })">
|
|
21
25
|
Default
|
|
22
26
|
</sonic-button>
|
|
23
|
-
<sonic-button onclick="
|
|
27
|
+
<sonic-button onclick="SonicToast.add({ text: 'Operation succeeded', status: 'success' })">
|
|
24
28
|
Success
|
|
25
29
|
</sonic-button>
|
|
26
|
-
<sonic-button onclick="
|
|
30
|
+
<sonic-button onclick="SonicToast.add({ text: 'Something went wrong', status: 'error' })">
|
|
27
31
|
Error
|
|
28
32
|
</sonic-button>
|
|
29
|
-
<sonic-button onclick="
|
|
33
|
+
<sonic-button onclick="SonicToast.add({ text: 'Check this detail', status: 'warning' })">
|
|
30
34
|
Warning
|
|
31
35
|
</sonic-button>
|
|
32
|
-
<sonic-button onclick="
|
|
36
|
+
<sonic-button onclick="SonicToast.add({ text: 'Helpful context', status: 'info' })">
|
|
33
37
|
Info
|
|
34
38
|
</sonic-button>
|
|
35
39
|
</div>
|
|
36
40
|
</template>
|
|
37
41
|
</sonic-code>
|
|
38
42
|
|
|
39
|
-
##
|
|
43
|
+
## Label
|
|
44
|
+
|
|
45
|
+
Set **`label`** for a bold title above **`text`**. **`title`** still works but is deprecated—use **`label`** in new code.
|
|
40
46
|
|
|
41
47
|
<sonic-code>
|
|
42
48
|
<template>
|
|
43
49
|
<div class="flex flex-wrap gap-2">
|
|
44
|
-
<sonic-button
|
|
45
|
-
|
|
50
|
+
<sonic-button
|
|
51
|
+
onclick="SonicToast.add({ label: 'Success', text: 'Your request was processed.', status: 'success' })"
|
|
52
|
+
>
|
|
53
|
+
Toast with label
|
|
46
54
|
</sonic-button>
|
|
47
|
-
<sonic-button
|
|
48
|
-
|
|
55
|
+
<sonic-button
|
|
56
|
+
onclick="SonicToast.add({ label: 'Error', text: 'Processing failed. Try again.', status: 'error' })"
|
|
57
|
+
>
|
|
58
|
+
Error with label
|
|
49
59
|
</sonic-button>
|
|
50
60
|
</div>
|
|
51
61
|
</template>
|
|
52
62
|
</sonic-code>
|
|
53
63
|
|
|
54
|
-
##
|
|
64
|
+
## HTML in text
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
**`text`** (and **`label`**) can include HTML strings. Links and controls in **`text`** automatically enable **`preserve`** so the toast does not auto-hide while the user interacts.
|
|
57
67
|
|
|
58
68
|
<sonic-code>
|
|
59
69
|
<template>
|
|
60
|
-
<sonic-button
|
|
61
|
-
|
|
70
|
+
<sonic-button
|
|
71
|
+
onclick="SonicToast.add({ text: 'Message with <strong>HTML</strong> and an <a href="#">action link</a>', status: 'info' })"
|
|
72
|
+
>
|
|
73
|
+
Toast with HTML
|
|
62
74
|
</sonic-button>
|
|
63
75
|
</template>
|
|
64
76
|
</sonic-code>
|
|
65
77
|
|
|
78
|
+
## Preserve
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Par défaut, les toasts disparaissent automatiquement. Avec `preserve: true`, le toast reste affiché jusqu'à ce qu'il soit fermé manuellement.
|
|
80
|
+
Without **`preserve`**, toasts auto-hide after about six seconds (timer pauses on hover or focus). Set **`preserve`** to keep the toast until the user closes it.
|
|
70
81
|
|
|
71
82
|
<sonic-code>
|
|
72
83
|
<template>
|
|
73
|
-
<sonic-button
|
|
74
|
-
|
|
84
|
+
<sonic-button
|
|
85
|
+
onclick="SonicToast.add({ text: 'This toast stays until you dismiss it', status: 'info', preserve: true })"
|
|
86
|
+
>
|
|
87
|
+
Persistent toast
|
|
75
88
|
</sonic-button>
|
|
76
89
|
</template>
|
|
77
90
|
</sonic-code>
|
|
78
91
|
|
|
79
|
-
##
|
|
92
|
+
## Dismiss forever
|
|
80
93
|
|
|
81
|
-
|
|
94
|
+
With **`dismissForever`** and a stable **`id`**, closing the toast stores dismissal in **`localStorage`**—**`SonicToast.add`** skips it on later visits. Duplicate payloads (same fields, ignoring **`id`**) are not queued twice.
|
|
82
95
|
|
|
83
96
|
<sonic-code>
|
|
84
97
|
<template>
|
|
85
|
-
<sonic-button
|
|
86
|
-
|
|
98
|
+
<sonic-button
|
|
99
|
+
onclick="SonicToast.add({ id: 'unique-toast-id', text: 'Dismiss forever hides this across reloads', status: 'info', dismissForever: true })"
|
|
100
|
+
>
|
|
101
|
+
Dismiss forever
|
|
87
102
|
</sonic-button>
|
|
88
103
|
</template>
|
|
89
104
|
</sonic-code>
|
|
90
105
|
|
|
91
|
-
##
|
|
106
|
+
## Ghost
|
|
92
107
|
|
|
93
|
-
|
|
108
|
+
**`ghost`** renders a semi-transparent, non-interactive toast—useful for loading or background states. **`SonicToast.removeAll`** leaves ghost toasts in place.
|
|
94
109
|
|
|
95
110
|
<sonic-code>
|
|
96
111
|
<template>
|
|
97
|
-
<sonic-button
|
|
98
|
-
|
|
112
|
+
<sonic-button
|
|
113
|
+
onclick="SonicToast.add({ text: 'Ghost toast (non-interactive)', status: 'info', ghost: true })"
|
|
114
|
+
>
|
|
115
|
+
Ghost toast
|
|
99
116
|
</sonic-button>
|
|
100
117
|
</template>
|
|
101
118
|
</sonic-code>
|
|
102
119
|
|
|
120
|
+
## Dismissal
|
|
103
121
|
|
|
104
|
-
|
|
122
|
+
Use static helpers to clear the stack from app logic (for example after navigation).
|
|
105
123
|
|
|
106
|
-
###
|
|
124
|
+
### Remove all
|
|
107
125
|
|
|
108
|
-
|
|
126
|
+
Removes every toast except **`ghost`** items.
|
|
109
127
|
|
|
110
128
|
<sonic-code>
|
|
111
129
|
<template>
|
|
112
130
|
<div class="flex flex-wrap gap-2">
|
|
113
|
-
<sonic-button onclick="
|
|
114
|
-
<sonic-button onclick="
|
|
115
|
-
<sonic-button onclick="
|
|
116
|
-
<sonic-button onclick="
|
|
131
|
+
<sonic-button onclick="SonicToast.add({ text: 'Toast 1', status: 'info' })">Add toast 1</sonic-button>
|
|
132
|
+
<sonic-button onclick="SonicToast.add({ text: 'Toast 2', status: 'success' })">Add toast 2</sonic-button>
|
|
133
|
+
<sonic-button onclick="SonicToast.add({ text: 'Toast 3', status: 'warning' })">Add toast 3</sonic-button>
|
|
134
|
+
<sonic-button onclick="SonicToast.removeAll()">Remove all</sonic-button>
|
|
117
135
|
</div>
|
|
118
136
|
</template>
|
|
119
137
|
</sonic-code>
|
|
120
138
|
|
|
121
|
-
###
|
|
122
|
-
|
|
123
|
-
Supprime tous les toasts d'un statut spécifique.
|
|
139
|
+
### Remove by status
|
|
124
140
|
|
|
125
141
|
<sonic-code>
|
|
126
142
|
<template>
|
|
127
143
|
<div class="flex flex-wrap gap-2">
|
|
128
|
-
<sonic-button onclick="
|
|
129
|
-
<sonic-button onclick="
|
|
130
|
-
<sonic-button onclick="
|
|
131
|
-
<sonic-button onclick="
|
|
132
|
-
<sonic-button onclick="
|
|
144
|
+
<sonic-button onclick="SonicToast.add({ text: 'Success toast', status: 'success' })">Success</sonic-button>
|
|
145
|
+
<sonic-button onclick="SonicToast.add({ text: 'Error toast', status: 'error' })">Error</sonic-button>
|
|
146
|
+
<sonic-button onclick="SonicToast.add({ text: 'Warning toast', status: 'warning' })">Warning</sonic-button>
|
|
147
|
+
<sonic-button onclick="SonicToast.removeItemsByStatus('success')">Remove success</sonic-button>
|
|
148
|
+
<sonic-button onclick="SonicToast.removeItemsByStatus('error')">Remove error</sonic-button>
|
|
133
149
|
</div>
|
|
134
150
|
</template>
|
|
135
151
|
</sonic-code>
|
|
136
152
|
|
|
137
|
-
###
|
|
153
|
+
### Remove temporary items
|
|
138
154
|
|
|
139
|
-
|
|
155
|
+
Removes toasts that are not **`preserve`**.
|
|
140
156
|
|
|
141
157
|
<sonic-code>
|
|
142
158
|
<template>
|
|
143
159
|
<div class="flex flex-wrap gap-2">
|
|
144
|
-
<sonic-button onclick="
|
|
145
|
-
<sonic-button onclick="
|
|
146
|
-
|
|
160
|
+
<sonic-button onclick="SonicToast.add({ text: 'Temporary toast', status: 'info' })">Temporary</sonic-button>
|
|
161
|
+
<sonic-button onclick="SonicToast.add({ text: 'Persistent toast', status: 'success', preserve: true })">
|
|
162
|
+
Persistent
|
|
163
|
+
</sonic-button>
|
|
164
|
+
<sonic-button onclick="SonicToast.removeTemporaryItems()">Remove temporary</sonic-button>
|
|
147
165
|
</div>
|
|
148
166
|
</template>
|
|
149
167
|
</sonic-code>
|
|
150
168
|
|
|
151
|
-
##
|
|
169
|
+
## Combined options
|
|
152
170
|
|
|
153
171
|
<sonic-code>
|
|
154
172
|
<template>
|
|
155
|
-
<sonic-button
|
|
173
|
+
<sonic-button
|
|
174
|
+
onclick="SonicToast.add({
|
|
156
175
|
id: 'welcome-toast',
|
|
157
|
-
|
|
158
|
-
text: '
|
|
176
|
+
label: 'Welcome',
|
|
177
|
+
text: 'Welcome to the platform. Explore the docs to get started.',
|
|
159
178
|
status: 'success',
|
|
160
179
|
dismissForever: true
|
|
161
|
-
})"
|
|
162
|
-
|
|
180
|
+
})"
|
|
181
|
+
>
|
|
182
|
+
Full example
|
|
163
183
|
</sonic-button>
|
|
164
184
|
</template>
|
|
165
185
|
</sonic-code>
|
|
166
186
|
|
|
187
|
+
## Accessibility
|
|
188
|
+
|
|
189
|
+
Each toast uses **`role="alert"`** for **`error`** and **`role="status"`** otherwise (with **`aria-live="polite"`** when applicable). Status icons are decorative (**`aria-hidden`**). The close control has an i18n **`aria-label`**. When there is no **`label`**, a truncated string **`aria-label`** may be derived from plain **`text`**.
|
|
190
|
+
|
|
191
|
+
## API reference
|
|
192
|
+
|
|
193
|
+
Options passed to **`SonicToast.add(conf)`**:
|
|
194
|
+
|
|
195
|
+
| Option | Values | Description |
|
|
196
|
+
|----------|---------|-------------|
|
|
197
|
+
| `text` | string · Lit template | Main body; HTML strings are supported |
|
|
198
|
+
| `label` | string · Lit template | Optional heading above **`text`** |
|
|
199
|
+
| `title` | string · Lit template | Deprecated alias for **`label`** |
|
|
200
|
+
| `status` | `success` · `error` · `warning` · `info` · `` (empty) | Semantic styling and live region behavior |
|
|
201
|
+
| `id` | string · number | Stable id for deduplication and **`dismissForever`** (defaults to timestamp) |
|
|
202
|
+
| `preserve` | boolean | Skip auto-hide; forced when **`text`** contains interactive markup |
|
|
203
|
+
| `ghost` | boolean | Semi-transparent and non-interactive; kept by **`removeAll`** |
|
|
204
|
+
| `dismissForever` | boolean | Persist dismissal in **`localStorage`** when closed (requires stable **`id`**) |
|
|
205
|
+
| `styleSheet` | modal style input | Extra adopted styles on the toast item shadow root |
|
|
206
|
+
| `useSlot` | boolean | Legacy: project **`text`** into the light DOM slot |
|
|
207
|
+
|
|
208
|
+
| Method | Description |
|
|
209
|
+
|--------|-------------|
|
|
210
|
+
| `SonicToast.add(conf)` | Append a toast; returns the config or **`null`** if skipped (dismissed forever or duplicate) |
|
|
211
|
+
| `SonicToast.removeAll()` | Remove all non-**`ghost`** toasts |
|
|
212
|
+
| `SonicToast.removeItemsByStatus(status)` | Remove toasts matching **`status`** |
|
|
213
|
+
| `SonicToast.removeItemById(id)` | Remove a single toast by **`id`** |
|
|
214
|
+
| `SonicToast.removeTemporaryItems()` | Remove toasts without **`preserve`** |
|
|
215
|
+
|
|
216
|
+
**`sonic-toast`** is mounted automatically; **`sonic-toast-item`** is internal. In iframes, toasts can delegate to the parent window via **`postMessage`**.
|
|
@@ -3,7 +3,7 @@ import { TemplateResult } from "lit";
|
|
|
3
3
|
import { DirectiveResult } from "lit/directive.js";
|
|
4
4
|
import { ModalStyleSheetInput } from "@supersoniks/concorde/core/components/ui/modal/modal-utils";
|
|
5
5
|
|
|
6
|
-
export type ToastStatus = Message["status"] | "" | "
|
|
6
|
+
export type ToastStatus = Message["status"] | "" | "default";
|
|
7
7
|
|
|
8
8
|
export type ToastContent = string | TemplateResult | DirectiveResult;
|
|
9
9
|
|