@f-ewald/components 1.25.0 → 1.26.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/README.md +4 -3
- package/custom-elements.json +24 -5
- package/dist/comment-composer.d.ts +15 -1
- package/dist/comment-composer.d.ts.map +1 -1
- package/dist/comment-composer.js +25 -3
- package/dist/comment-composer.js.map +1 -1
- package/dist/toast-notification.d.ts +14 -0
- package/dist/toast-notification.d.ts.map +1 -1
- package/dist/toast-notification.js +23 -8
- package/dist/toast-notification.js.map +1 -1
- package/dist/tokens.css +15 -3
- package/dist/tokens.d.ts +9 -8
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +43 -15
- package/dist/tokens.js.map +1 -1
- package/docs/comment-composer.md +5 -1
- package/docs/toast-notification.md +23 -0
- package/llms.txt +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,10 +166,11 @@ set. Don't reintroduce that pattern.)
|
|
|
166
166
|
### Gradient theme
|
|
167
167
|
|
|
168
168
|
Setting `data-theme="gradient"` on `<html>` layers a glossy gradient look
|
|
169
|
-
onto `ui-button` (primary, danger, and secondary variants)
|
|
170
|
-
|
|
169
|
+
onto `ui-button` (primary, danger, and secondary variants) and
|
|
170
|
+
`toast-notification` (all four variants: success, error, info, warning) on
|
|
171
|
+
top of the flat light palette — see `gradientTokenValues` in
|
|
171
172
|
[`src/tokens.ts`](./src/tokens.ts). Every other token stays at its light-mode
|
|
172
|
-
value
|
|
173
|
+
value. It takes precedence over the
|
|
173
174
|
OS dark preference (like `data-theme="light"` does), since the gradient's
|
|
174
175
|
color stops are hardcoded for a light surface.
|
|
175
176
|
|
package/custom-elements.json
CHANGED
|
@@ -3570,7 +3570,7 @@
|
|
|
3570
3570
|
"declarations": [
|
|
3571
3571
|
{
|
|
3572
3572
|
"kind": "class",
|
|
3573
|
-
"description": "GitHub/Slack-style comment composer: a one-line text field that expands\ninto a multi-line textarea with a bottom-right Cancel/Submit footer\n(`form-actions`) as soon as it's focused or clicked. Submitting fires\n`submit` with the trimmed value, then clears the field and collapses back\nto one line — it's meant for posting one comment at a time, not editing a\npersistent value in place (see `editable-text` for that). Canceling (the\nCancel button or `Escape`) discards the draft and collapses without\nfiring `submit`. Clicking away (blur) does neither — the composer stays\nexpanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`\nsubmits from the textarea, matching `editable-text`'s multiline shortcut.\nPurely token-styled (no bespoke colors), so it's themeable via the same\n`--ui-*` custom properties as every other value-entry field.",
|
|
3573
|
+
"description": "GitHub/Slack-style comment composer: a one-line text field that expands\ninto a multi-line textarea with a bottom-right Cancel/Submit footer\n(`form-actions`) as soon as it's focused or clicked. Submitting fires\n`submit` with the trimmed value, then clears the field and collapses back\nto one line — it's meant for posting one comment at a time, not editing a\npersistent value in place (see `editable-text` for that). Canceling (the\nCancel button or `Escape`) discards the draft and collapses without\nfiring `submit`. Clicking away (blur) does neither — the composer stays\nexpanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`\nsubmits from the textarea, matching `editable-text`'s multiline shortcut —\nthe Submit button always shows a `kbd-hint` for it, so the shortcut is\ndiscoverable rather than a hidden power-user feature. Calling the standard\n`.focus()` method expands the composer (if collapsed) and focuses its\nfield, for an ancestor that wants to drive it programmatically.\nPurely token-styled (no bespoke colors), so it's themeable via the same\n`--ui-*` custom properties as every other value-entry field.",
|
|
3574
3574
|
"name": "CommentComposer",
|
|
3575
3575
|
"members": [
|
|
3576
3576
|
{
|
|
@@ -3679,6 +3679,25 @@
|
|
|
3679
3679
|
}
|
|
3680
3680
|
}
|
|
3681
3681
|
},
|
|
3682
|
+
{
|
|
3683
|
+
"kind": "method",
|
|
3684
|
+
"name": "focus",
|
|
3685
|
+
"return": {
|
|
3686
|
+
"type": {
|
|
3687
|
+
"text": "void"
|
|
3688
|
+
}
|
|
3689
|
+
},
|
|
3690
|
+
"parameters": [
|
|
3691
|
+
{
|
|
3692
|
+
"name": "options",
|
|
3693
|
+
"optional": true,
|
|
3694
|
+
"type": {
|
|
3695
|
+
"text": "FocusOptions"
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
],
|
|
3699
|
+
"description": "Expands the composer (if collapsed) and focuses its field, so an\nancestor can drive it programmatically — e.g. a \"reply\" affordance\nelsewhere on the page that should land the user in this composer\nalready expanded, not just visually scrolled to a one-line input.\nA no-op while `disabled`. Expanding re-renders asynchronously; the\nactual focus happens in `updated()` once the textarea exists."
|
|
3700
|
+
},
|
|
3682
3701
|
{
|
|
3683
3702
|
"kind": "method",
|
|
3684
3703
|
"name": "_onInput",
|
|
@@ -16019,7 +16038,7 @@
|
|
|
16019
16038
|
"declarations": [
|
|
16020
16039
|
{
|
|
16021
16040
|
"kind": "class",
|
|
16022
|
-
"description": "Fixed-position stack of dismissible notifications, anchored top-right\n(top-full-width on mobile). Every toast shares one fixed width so entries\nnever appear narrower or wider than one another. Not wired to any app state\nyet — callers add toasts imperatively via the `show()` method on a live\nelement reference,\ne.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\nor via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\nexported from this file. The first argument is the required bold headline; an\noptional `description` renders a smaller, non-bold second line. Each variant\nleads with a matching status icon (success → check, error → exclamation\ncircle, info → information circle, warning → exclamation triangle). Each toast\nauto-dismisses after `duration` ms and can also be dismissed via its ✕\nbutton. Appears/disappears instantly — no slide/fade transitions.",
|
|
16041
|
+
"description": "Fixed-position stack of dismissible notifications, anchored top-right\n(top-full-width on mobile). Every toast shares one fixed width so entries\nnever appear narrower or wider than one another. Not wired to any app state\nyet — callers add toasts imperatively via the `show()` method on a live\nelement reference,\ne.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\nor via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\nexported from this file. The first argument is the required bold headline; an\noptional `description` renders a smaller, non-bold second line. Each variant\nleads with a matching status icon (success → check, error → exclamation\ncircle, info → information circle, warning → exclamation triangle). Each toast\nauto-dismisses after `duration` ms and can also be dismissed via its ✕\nbutton. Appears/disappears instantly — no slide/fade transitions.\n\nEach variant's background reads a dedicated `--ui-toast-*-background` hook\n(`success`/`error`/`info`/`warning`), which defaults to the flat\n`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —\nso those stay the single source of truth for every other component. A\nconsumer can override just these toast-specific tokens with a\n`linear-gradient(...)` to opt every toast into a gradient look without\ntouching component markup — `gradientTokenValues` in `tokens.ts` ships\nexactly this, wired up via `data-theme=\"gradient\"` (see `tokens.css`'s\n\"Gradient theme\" section), the same mechanism `ui-button` uses.\n`--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the\nexisting elevation shadow) and `--ui-toast-text-shadow` (legibility\nagainst the gradient's lighter stop) round out the effect, mirroring\n`ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.",
|
|
16023
16042
|
"name": "ToastNotification",
|
|
16024
16043
|
"members": [
|
|
16025
16044
|
{
|
|
@@ -16252,7 +16271,7 @@
|
|
|
16252
16271
|
"type": {
|
|
16253
16272
|
"text": "Record<string, string>"
|
|
16254
16273
|
},
|
|
16255
|
-
"default": "{ // Colors \"--ui-primary\": \"#4f46e5\", // indigo-600 \"--ui-primary-hover\": \"#4338ca\", // indigo-700 // Button-specific background/border hooks: default to the flat --ui-primary // / --ui-danger tokens above unchanged, so those stay the single source of // truth for every other component. Overriding just these lets a theme opt // ui-button into a gradient (or any other) background without touching // component markup; --ui-button-border/--ui-button-danger-border default // to transparent (today's look) and are meant to be paired with a shade // darker than the gradient's dark stop when one is set. The `-active` // variants default to whatever `-background` already resolved to (so a // solid override still applies while pressed) — a gradient theme should // set them to the same stops in reverse, for a pressed/\"indented\" look. \"--ui-button-background\": \"var(--ui-primary, #4f46e5)\", \"--ui-button-background-hover\": \"var(--ui-primary-hover, #4338ca)\", \"--ui-button-background-active\": \"var(--ui-button-background, var(--ui-primary, #4f46e5))\", \"--ui-button-border\": \"transparent\", // The bordered, transparent-background secondary variant's equivalents — // shared with confirm-dialog's Cancel button, which is the same visual // pattern. Defaults reproduce today's literal secondary styling exactly // (no background at any state, border colors matching --ui-border / // --ui-text-muted), so a theme only needs to override these to make // secondary/Cancel buttons match a primary/danger gradient theme. \"--ui-button-secondary-background\": \"none\", \"--ui-button-secondary-background-hover\": \"none\", \"--ui-button-secondary-background-active\": \"var(--ui-button-secondary-background, none)\", \"--ui-button-secondary-border\": \"var(--ui-border, #e2e8f0)\", \"--ui-button-secondary-border-hover\": \"var(--ui-text-muted, #64748b)\", // A muted-gray surface used wherever something already paints // --ui-surface-muted as a state indicator in flat mode — button-group's // unchecked-segment hover, pagination-nav's button hover, and // radio-cards/radio-pills' checked background — which is a genuinely // different default than secondary's borderless flat hover, so it can't // reuse --ui-button-secondary-background-hover's \"none\" default. \"--ui-button-secondary-surface-muted\": \"var(--ui-surface-muted, #f8fafc)\", // Shared by both primary/danger — a purely cosmetic gloss/legibility pair, // not color-specific, so one token covers both variants. `-highlight` is a // full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for // a glossy top edge, defaulting to a fully transparent (so invisible) // shadow rather than the keyword `none` — some usages combine it with // another literal shadow in a comma-separated list, where a bare `none` // item is invalid CSS and would zero out the *whole* declaration. // `-text-shadow` is a full text-shadow value for label legibility against // a gradient's lighter stop, always used standalone, so it keeps `none`. \"--ui-button-highlight\": \"0 0 0 0 transparent\", \"--ui-button-text-shadow\": \"none\", // A solid stand-in for the same accent, for spots that can't render a // background gradient at all — a native <input>'s accent-color only // accepts a plain color, and a hard-stop background gradient (e.g. // range-slider's filled track) can't nest another gradient inside its own // color-stop list. Consumers that theme the buttons into a gradient should // set this to the gradient's dark stop, so these non-button accents (radio // selection indicators, the range-slider track/thumb) stay visually // coordinated with it even though they can't literally paint a gradient. \"--ui-button-accent\": \"var(--ui-primary, #4f46e5)\", \"--ui-info\": \"#0ea5e9\", // sky-500 \"--ui-info-hover\": \"#0284c7\", // sky-600 \"--ui-danger\": \"#dc2626\", // red-600 \"--ui-danger-hover\": \"#b91c1c\", // red-700 \"--ui-button-danger-background\": \"var(--ui-danger, #dc2626)\", \"--ui-button-danger-background-hover\": \"var(--ui-danger-hover, #b91c1c)\", \"--ui-button-danger-background-active\": \"var(--ui-button-danger-background, var(--ui-danger, #dc2626))\", \"--ui-button-danger-border\": \"transparent\", \"--ui-success\": \"#16a34a\", // green-600 \"--ui-warning\": \"#d97706\", // amber-600 \"--ui-warning-hover\": \"#b45309\", // amber-700 \"--ui-on-accent\": \"#ffffff\", \"--ui-text\": \"#0f172a\", // slate-900 \"--ui-text-muted\": \"#64748b\", // slate-500 \"--ui-border\": \"#e2e8f0\", // slate-200 \"--ui-surface\": \"#ffffff\", // white \"--ui-surface-muted\": \"#f8fafc\", // slate-50 \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash \"--ui-tooltip\": \"#0f172a\", // slate-900 \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\", \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45% // Shape / depth \"--ui-radius\": \"0.5rem\", // rounded-lg \"--ui-radius-sm\": \"0.25rem\", // rounded \"--ui-shadow\": \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md \"--ui-shadow-lg\": \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\", // Type \"--ui-font\": 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"', \"--ui-font-mono\": \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\", \"--ui-font-size-lg\": \"1rem\", // text-base \"--ui-font-size\": \"0.875rem\", // text-sm \"--ui-font-size-sm\": \"0.75rem\", // text-xs \"--ui-font-size-xs\": \"0.6875rem\", // Font weights — the only four weights the system uses. \"--ui-font-weight-regular\": \"400\", \"--ui-font-weight-medium\": \"500\", \"--ui-font-weight-semibold\": \"600\", \"--ui-font-weight-bold\": \"700\", // Line heights — glyph (icon/marker box), tight (headings), normal (body). \"--ui-line-height-glyph\": \"1\", \"--ui-line-height-tight\": \"1.25\", \"--ui-line-height-normal\": \"1.5\", // Letter spacing / tracking — default and the single widened step. \"--ui-tracking-normal\": \"0\", \"--ui-tracking-wide\": \"0.04em\", }",
|
|
16274
|
+
"default": "{ // Colors \"--ui-primary\": \"#4f46e5\", // indigo-600 \"--ui-primary-hover\": \"#4338ca\", // indigo-700 // Button-specific background/border hooks: default to the flat --ui-primary // / --ui-danger tokens above unchanged, so those stay the single source of // truth for every other component. Overriding just these lets a theme opt // ui-button into a gradient (or any other) background without touching // component markup; --ui-button-border/--ui-button-danger-border default // to transparent (today's look) and are meant to be paired with a shade // darker than the gradient's dark stop when one is set. The `-active` // variants default to whatever `-background` already resolved to (so a // solid override still applies while pressed) — a gradient theme should // set them to the same stops in reverse, for a pressed/\"indented\" look. \"--ui-button-background\": \"var(--ui-primary, #4f46e5)\", \"--ui-button-background-hover\": \"var(--ui-primary-hover, #4338ca)\", \"--ui-button-background-active\": \"var(--ui-button-background, var(--ui-primary, #4f46e5))\", \"--ui-button-border\": \"transparent\", // The bordered, transparent-background secondary variant's equivalents — // shared with confirm-dialog's Cancel button, which is the same visual // pattern. Defaults reproduce today's literal secondary styling exactly // (no background at any state, border colors matching --ui-border / // --ui-text-muted), so a theme only needs to override these to make // secondary/Cancel buttons match a primary/danger gradient theme. \"--ui-button-secondary-background\": \"none\", \"--ui-button-secondary-background-hover\": \"none\", \"--ui-button-secondary-background-active\": \"var(--ui-button-secondary-background, none)\", \"--ui-button-secondary-border\": \"var(--ui-border, #e2e8f0)\", \"--ui-button-secondary-border-hover\": \"var(--ui-text-muted, #64748b)\", // A muted-gray surface used wherever something already paints // --ui-surface-muted as a state indicator in flat mode — button-group's // unchecked-segment hover, pagination-nav's button hover, and // radio-cards/radio-pills' checked background — which is a genuinely // different default than secondary's borderless flat hover, so it can't // reuse --ui-button-secondary-background-hover's \"none\" default. \"--ui-button-secondary-surface-muted\": \"var(--ui-surface-muted, #f8fafc)\", // Shared by both primary/danger — a purely cosmetic gloss/legibility pair, // not color-specific, so one token covers both variants. `-highlight` is a // full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for // a glossy top edge, defaulting to a fully transparent (so invisible) // shadow rather than the keyword `none` — some usages combine it with // another literal shadow in a comma-separated list, where a bare `none` // item is invalid CSS and would zero out the *whole* declaration. // `-text-shadow` is a full text-shadow value for label legibility against // a gradient's lighter stop, always used standalone, so it keeps `none`. \"--ui-button-highlight\": \"0 0 0 0 transparent\", \"--ui-button-text-shadow\": \"none\", // A solid stand-in for the same accent, for spots that can't render a // background gradient at all — a native <input>'s accent-color only // accepts a plain color, and a hard-stop background gradient (e.g. // range-slider's filled track) can't nest another gradient inside its own // color-stop list. Consumers that theme the buttons into a gradient should // set this to the gradient's dark stop, so these non-button accents (radio // selection indicators, the range-slider track/thumb) stay visually // coordinated with it even though they can't literally paint a gradient. \"--ui-button-accent\": \"var(--ui-primary, #4f46e5)\", \"--ui-info\": \"#0ea5e9\", // sky-500 \"--ui-info-hover\": \"#0284c7\", // sky-600 \"--ui-danger\": \"#dc2626\", // red-600 \"--ui-danger-hover\": \"#b91c1c\", // red-700 \"--ui-button-danger-background\": \"var(--ui-danger, #dc2626)\", \"--ui-button-danger-background-hover\": \"var(--ui-danger-hover, #b91c1c)\", \"--ui-button-danger-background-active\": \"var(--ui-button-danger-background, var(--ui-danger, #dc2626))\", \"--ui-button-danger-border\": \"transparent\", \"--ui-success\": \"#16a34a\", // green-600 \"--ui-warning\": \"#d97706\", // amber-600 \"--ui-warning-hover\": \"#b45309\", // amber-700 // toast-notification's per-variant background hooks: default to the flat // --ui-success/--ui-danger/--ui-info/--ui-warning tokens unchanged, so // those stay the single source of truth for every other component — // the same pattern as --ui-button-background/--ui-button-danger-background // above. `-highlight`/`-text-shadow` are the same glossy-top-edge / // legibility-shadow pair as --ui-button-highlight/--ui-button-text-shadow, // kept as separate tokens so a theme can gloss toasts and buttons // independently. \"--ui-toast-success-background\": \"var(--ui-success, #16a34a)\", \"--ui-toast-error-background\": \"var(--ui-danger, #dc2626)\", \"--ui-toast-info-background\": \"var(--ui-info, #0ea5e9)\", \"--ui-toast-warning-background\": \"var(--ui-warning, #d97706)\", \"--ui-toast-highlight\": \"0 0 0 0 transparent\", \"--ui-toast-text-shadow\": \"none\", \"--ui-on-accent\": \"#ffffff\", \"--ui-text\": \"#0f172a\", // slate-900 \"--ui-text-muted\": \"#64748b\", // slate-500 \"--ui-border\": \"#e2e8f0\", // slate-200 \"--ui-surface\": \"#ffffff\", // white \"--ui-surface-muted\": \"#f8fafc\", // slate-50 \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash \"--ui-tooltip\": \"#0f172a\", // slate-900 \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\", \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45% // Shape / depth \"--ui-radius\": \"0.5rem\", // rounded-lg \"--ui-radius-sm\": \"0.25rem\", // rounded \"--ui-shadow\": \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md \"--ui-shadow-lg\": \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\", // Type \"--ui-font\": 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"', \"--ui-font-mono\": \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\", \"--ui-font-size-lg\": \"1rem\", // text-base \"--ui-font-size\": \"0.875rem\", // text-sm \"--ui-font-size-sm\": \"0.75rem\", // text-xs \"--ui-font-size-xs\": \"0.6875rem\", // Font weights — the only four weights the system uses. \"--ui-font-weight-regular\": \"400\", \"--ui-font-weight-medium\": \"500\", \"--ui-font-weight-semibold\": \"600\", \"--ui-font-weight-bold\": \"700\", // Line heights — glyph (icon/marker box), tight (headings), normal (body). \"--ui-line-height-glyph\": \"1\", \"--ui-line-height-tight\": \"1.25\", \"--ui-line-height-normal\": \"1.5\", // Letter spacing / tracking — default and the single widened step. \"--ui-tracking-normal\": \"0\", \"--ui-tracking-wide\": \"0.04em\", }",
|
|
16256
16275
|
"description": "Design token values, sourced from Tailwind v4's default theme palette.\nEach entry maps a `--ui-*` custom property name to its default value.\nThese are the same values baked in as `var(--ui-*, <fallback>)` fallbacks\nthroughout component styles, so components render correctly with zero\nexternal CSS. Consumers may override any of these by setting the custom\nproperty on `:root` or an ancestor element (see `tokens.css`)."
|
|
16257
16276
|
},
|
|
16258
16277
|
{
|
|
@@ -16270,8 +16289,8 @@
|
|
|
16270
16289
|
"type": {
|
|
16271
16290
|
"text": "Record<string, string>"
|
|
16272
16291
|
},
|
|
16273
|
-
"default": "{ \"--ui-button-background\": \"linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)\", // indigo-500 -> 600 \"--ui-button-background-hover\": \"linear-gradient(180deg, #818cf8 0%, #6366f1 100%)\", // indigo-400 -> 500 \"--ui-button-background-active\": \"linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)\", // reversed 600 -> 500 \"--ui-button-border\": \"#4338ca\", // indigo-700 \"--ui-button-danger-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600 \"--ui-button-danger-background-hover\": \"linear-gradient(180deg, #f87171 0%, #ef4444 100%)\", // red-400 -> 500 \"--ui-button-danger-background-active\": \"linear-gradient(180deg, #dc2626 0%, #ef4444 100%)\", // reversed 600 -> 500 \"--ui-button-danger-border\": \"#b91c1c\", // red-700 // Secondary stays
|
|
16274
|
-
"description": "\"Gradient\" theme overrides, applied via `data-theme=\"gradient\"` on `<html>`\n(see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the\n`\"light\"` override and layers a glossy gradient look on top of the flat\nlight palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/\n`--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that\nfile's doc comment). Every other token (`--ui-text`, `--ui-surface
|
|
16292
|
+
"default": "{ \"--ui-button-background\": \"linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)\", // indigo-500 -> 600 \"--ui-button-background-hover\": \"linear-gradient(180deg, #818cf8 0%, #6366f1 100%)\", // indigo-400 -> 500 \"--ui-button-background-active\": \"linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)\", // reversed 600 -> 500 \"--ui-button-border\": \"#4338ca\", // indigo-700 \"--ui-button-danger-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600 \"--ui-button-danger-background-hover\": \"linear-gradient(180deg, #f87171 0%, #ef4444 100%)\", // red-400 -> 500 \"--ui-button-danger-background-active\": \"linear-gradient(180deg, #dc2626 0%, #ef4444 100%)\", // reversed 600 -> 500 \"--ui-button-danger-border\": \"#b91c1c\", // red-700 // Secondary stays neutral gray rather than a saturated hue, matching its // flat \"not the primary action\" role, but one shade darker than the // original white -> slate-50 pairing: at a small button size, that pair // read as flat white with no visible gradient at all. slate-50 -> 100 // keeps enough contrast to actually look like a gradient while still // being clearly lighter/quieter than primary/danger. Border stays // slate-300 (a step past the flat slate-200) so its edge still reads // against the fill. \"--ui-button-secondary-background\": \"linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)\", // slate-50 -> 100 \"--ui-button-secondary-background-hover\": \"linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%)\", // slate-100 -> 200 \"--ui-button-secondary-background-active\": \"linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%)\", // reversed 100 -> 50 \"--ui-button-secondary-border\": \"#cbd5e1\", // slate-300 \"--ui-button-secondary-border-hover\": \"#94a3b8\", // slate-400 \"--ui-button-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge \"--ui-button-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility on primary/danger \"--ui-button-accent\": \"#4338ca\", // indigo-700, matches --ui-button-border // toast-notification: same light-to-dark, one-shade-step gradient // convention as the button variants above; the bottom stop always matches // the flat --ui-success/--ui-danger/--ui-info/--ui-warning value exactly. \"--ui-toast-success-background\": \"linear-gradient(180deg, #22c55e 0%, #16a34a 100%)\", // green-500 -> 600 \"--ui-toast-error-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600 \"--ui-toast-info-background\": \"linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%)\", // sky-400 -> 500 \"--ui-toast-warning-background\": \"linear-gradient(180deg, #f59e0b 0%, #d97706 100%)\", // amber-500 -> 600 \"--ui-toast-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge, same as --ui-button-highlight \"--ui-toast-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility, same as --ui-button-text-shadow }",
|
|
16293
|
+
"description": "\"Gradient\" theme overrides, applied via `data-theme=\"gradient\"` on `<html>`\n(see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the\n`\"light\"` override and layers a glossy gradient look on top of the flat\nlight palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/\n`--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that\nfile's doc comment), plus the `--ui-toast-*` hooks `toast-notification.ts`\nreads (see its doc comment). Every other token (`--ui-text`, `--ui-surface`,\n…) is left at its light-mode default — this theme only glosses buttons and\ntoasts by design. Each variant's gradient runs light-to-dark top-to-bottom\n(`180deg`) across one Tailwind shade step lighter/darker than the flat\ntoken so it still reads as \"the same color, glossy\" rather than a\ndifferent hue; `-hover` shifts the whole pair one shade lighter, `-active`\nreverses the two stops for a pressed/\"indented\" look, and `-border` is a\nshade darker than the gradient's dark stop for a defining edge."
|
|
16275
16294
|
},
|
|
16276
16295
|
{
|
|
16277
16296
|
"kind": "variable",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import "./form-actions.js";
|
|
3
|
+
import "./kbd-hint.js";
|
|
3
4
|
import "./ui-button.js";
|
|
4
5
|
/**
|
|
5
6
|
* GitHub/Slack-style comment composer: a one-line text field that expands
|
|
@@ -11,7 +12,11 @@ import "./ui-button.js";
|
|
|
11
12
|
* Cancel button or `Escape`) discards the draft and collapses without
|
|
12
13
|
* firing `submit`. Clicking away (blur) does neither — the composer stays
|
|
13
14
|
* expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`
|
|
14
|
-
* submits from the textarea, matching `editable-text`'s multiline shortcut
|
|
15
|
+
* submits from the textarea, matching `editable-text`'s multiline shortcut —
|
|
16
|
+
* the Submit button always shows a `kbd-hint` for it, so the shortcut is
|
|
17
|
+
* discoverable rather than a hidden power-user feature. Calling the standard
|
|
18
|
+
* `.focus()` method expands the composer (if collapsed) and focuses its
|
|
19
|
+
* field, for an ancestor that wants to drive it programmatically.
|
|
15
20
|
* Purely token-styled (no bespoke colors), so it's themeable via the same
|
|
16
21
|
* `--ui-*` custom properties as every other value-entry field.
|
|
17
22
|
*
|
|
@@ -39,6 +44,15 @@ export declare class CommentComposer extends LitElement {
|
|
|
39
44
|
private _draft;
|
|
40
45
|
private _textarea?;
|
|
41
46
|
private _expand;
|
|
47
|
+
/**
|
|
48
|
+
* Expands the composer (if collapsed) and focuses its field, so an
|
|
49
|
+
* ancestor can drive it programmatically — e.g. a "reply" affordance
|
|
50
|
+
* elsewhere on the page that should land the user in this composer
|
|
51
|
+
* already expanded, not just visually scrolled to a one-line input.
|
|
52
|
+
* A no-op while `disabled`. Expanding re-renders asynchronously; the
|
|
53
|
+
* actual focus happens in `updated()` once the textarea exists.
|
|
54
|
+
*/
|
|
55
|
+
focus(options?: FocusOptions): void;
|
|
42
56
|
private _onInput;
|
|
43
57
|
private _cancel;
|
|
44
58
|
private _submit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-composer.d.ts","sourceRoot":"","sources":["../src/comment-composer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"comment-composer.d.ts","sourceRoot":"","sources":["../src/comment-composer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,MAAM,4BAkEpB;IAEF,6DAA6D;IACjD,KAAK,SAAM;IACvB,yCAAyC;IAC7B,WAAW,SAAoB;IAC3C,qDAAqD;IACzC,KAAK,SAAa;IAC9B,uCAAuC;IACX,IAAI,SAAK;IACrC,2CAA2C;IACF,WAAW,SAAY;IAChE,6CAA6C;IACJ,WAAW,SAAY;IAChE,mCAAmC;IACN,QAAQ,UAAS;IAErC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAM;IAEV,OAAO,CAAC,SAAS,CAAC,CAAsB;IAE3D,OAAO,CAAC,OAAO;IAMf;;;;;;;OAOG;IACM,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAO3C;IAED,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,UAAU;IAUlB,UAAmB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQ9D;IAEQ,MAAM,yCAgDd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,eAAe,CAAC;KACrC;CACF"}
|
package/dist/comment-composer.js
CHANGED
|
@@ -8,6 +8,7 @@ import { LitElement, css, html } from "lit";
|
|
|
8
8
|
import { customElement, property, query, state } from "lit/decorators.js";
|
|
9
9
|
import { tokens } from "./tokens.js";
|
|
10
10
|
import "./form-actions.js";
|
|
11
|
+
import "./kbd-hint.js";
|
|
11
12
|
import "./ui-button.js";
|
|
12
13
|
/**
|
|
13
14
|
* GitHub/Slack-style comment composer: a one-line text field that expands
|
|
@@ -19,7 +20,11 @@ import "./ui-button.js";
|
|
|
19
20
|
* Cancel button or `Escape`) discards the draft and collapses without
|
|
20
21
|
* firing `submit`. Clicking away (blur) does neither — the composer stays
|
|
21
22
|
* expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`
|
|
22
|
-
* submits from the textarea, matching `editable-text`'s multiline shortcut
|
|
23
|
+
* submits from the textarea, matching `editable-text`'s multiline shortcut —
|
|
24
|
+
* the Submit button always shows a `kbd-hint` for it, so the shortcut is
|
|
25
|
+
* discoverable rather than a hidden power-user feature. Calling the standard
|
|
26
|
+
* `.focus()` method expands the composer (if collapsed) and focuses its
|
|
27
|
+
* field, for an ancestor that wants to drive it programmatically.
|
|
23
28
|
* Purely token-styled (no bespoke colors), so it's themeable via the same
|
|
24
29
|
* `--ui-*` custom properties as every other value-entry field.
|
|
25
30
|
*
|
|
@@ -120,6 +125,23 @@ let CommentComposer = class CommentComposer extends LitElement {
|
|
|
120
125
|
this._draft = this.value;
|
|
121
126
|
this._expanded = true;
|
|
122
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Expands the composer (if collapsed) and focuses its field, so an
|
|
130
|
+
* ancestor can drive it programmatically — e.g. a "reply" affordance
|
|
131
|
+
* elsewhere on the page that should land the user in this composer
|
|
132
|
+
* already expanded, not just visually scrolled to a one-line input.
|
|
133
|
+
* A no-op while `disabled`. Expanding re-renders asynchronously; the
|
|
134
|
+
* actual focus happens in `updated()` once the textarea exists.
|
|
135
|
+
*/
|
|
136
|
+
focus(options) {
|
|
137
|
+
if (this.disabled)
|
|
138
|
+
return;
|
|
139
|
+
if (!this._expanded) {
|
|
140
|
+
this._expand();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this._textarea?.focus(options);
|
|
144
|
+
}
|
|
123
145
|
_onInput(e) {
|
|
124
146
|
this._draft = e.target.value;
|
|
125
147
|
}
|
|
@@ -187,8 +209,8 @@ let CommentComposer = class CommentComposer extends LitElement {
|
|
|
187
209
|
size="sm"
|
|
188
210
|
?disabled=${!canSubmit}
|
|
189
211
|
@click=${this._submit}
|
|
190
|
-
>${this.submitLabel}
|
|
191
|
-
>
|
|
212
|
+
>${this.submitLabel} <kbd-hint keys="Mod+Enter"></kbd-hint
|
|
213
|
+
></ui-button>
|
|
192
214
|
</form-actions>
|
|
193
215
|
</div>
|
|
194
216
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-composer.js","sourceRoot":"","sources":["../src/comment-composer.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QAqEL,6DAA6D;QACjD,UAAK,GAAG,EAAE,CAAC;QACvB,yCAAyC;QAC7B,gBAAW,GAAG,gBAAgB,CAAC;QAC3C,qDAAqD;QACzC,UAAK,GAAG,S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IAAI,CAAC,WAAW;6BACjB,IAAI,CAAC,KAAK;4BACX,IAAI,CAAC,QAAQ;yBAChB,IAAI,CAAC,QAAQ;2BACX,IAAI,CAAC,UAAU;;;;;;;;6BAQb,IAAI,CAAC,OAAO;uBAClB,IAAI,CAAC,WAAW;;;;;;gCAMP,CAAC,SAAS;6BACb,IAAI,CAAC,OAAO;uBAClB,IAAI,CAAC,WAAW;;;;aAI1B;YACH,CAAC,CAAC,IAAI,CAAA;;;yBAGS,IAAI,CAAC,KAAK;8BACL,IAAI,CAAC,WAAW;6BACjB,IAAI,CAAC,KAAK;4BACX,IAAI,CAAC,QAAQ;yBAChB,IAAI,CAAC,OAAO;yBACZ,IAAI,CAAC,OAAO;;aAExB;;KAER,CAAC;IACJ,CAAC;CACF,CAAA;AAnHa;IAAX,QAAQ,EAAE;8CAAY;AAEX;IAAX,QAAQ,EAAE;oDAAgC;AAE/B;IAAX,QAAQ,EAAE;8CAAmB;AAEF;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAU;AAEI;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAAwB;AAEvB;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAAwB;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAkB;AAE7B;IAAhB,KAAK,EAAE;kDAA2B;AAClB;IAAhB,KAAK,EAAE;+CAAqB;AAEF;IAA1B,KAAK,CAAC,UAAU,CAAC;kDAAyC;AAvFhD,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAyL3B","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport \"./form-actions.js\";\nimport \"./ui-button.js\";\n\n/**\n * GitHub/Slack-style comment composer: a one-line text field that expands\n * into a multi-line textarea with a bottom-right Cancel/Submit footer\n * (`form-actions`) as soon as it's focused or clicked. Submitting fires\n * `submit` with the trimmed value, then clears the field and collapses back\n * to one line — it's meant for posting one comment at a time, not editing a\n * persistent value in place (see `editable-text` for that). Canceling (the\n * Cancel button or `Escape`) discards the draft and collapses without\n * firing `submit`. Clicking away (blur) does neither — the composer stays\n * expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`\n * submits from the textarea, matching `editable-text`'s multiline shortcut.\n * Purely token-styled (no bespoke colors), so it's themeable via the same\n * `--ui-*` custom properties as every other value-entry field.\n *\n * @element comment-composer\n * @fires submit - User submitted a non-empty comment; detail: `{ value: string }`.\n * @fires cancel - User discarded the draft via the Cancel button or `Escape`.\n */\n@customElement(\"comment-composer\")\nexport class CommentComposer extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .shell {\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-surface, #ffffff);\n }\n .shell.expanded {\n border-radius: var(--ui-radius, 0.5rem);\n }\n input,\n textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n background: none;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n padding: 0.5rem 0.75rem;\n outline: none;\n }\n textarea {\n resize: none;\n }\n input:focus-visible,\n .shell:not(.expanded):focus-within {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n textarea:focus-visible {\n outline: none;\n }\n .footer {\n display: flex;\n justify-content: flex-end;\n padding: 0.5rem 0.75rem 0.75rem;\n }\n input:disabled,\n textarea:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n @media (forced-colors: active) {\n .shell:not(.expanded):focus-within {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Committed value shown in the collapsed one-line field. */\n @property() value = \"\";\n /** Placeholder text shown when empty. */\n @property() placeholder = \"Add a comment…\";\n /** Accessible name applied to the input/textarea. */\n @property() label = \"Comment\";\n /** Visible row count once expanded. */\n @property({ type: Number }) rows = 4;\n /** Label for the primary submit button. */\n @property({ attribute: \"submit-label\" }) submitLabel = \"Submit\";\n /** Label for the secondary cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Disables the field entirely. */\n @property({ type: Boolean }) disabled = false;\n\n @state() private _expanded = false;\n @state() private _draft = \"\";\n\n @query(\"textarea\") private _textarea?: HTMLTextAreaElement;\n\n private _expand(): void {\n if (this.disabled || this._expanded) return;\n this._draft = this.value;\n this._expanded = true;\n }\n\n private _onInput(e: Event): void {\n this._draft = (e.target as HTMLInputElement | HTMLTextAreaElement).value;\n }\n\n private _cancel(): void {\n this._draft = this.value;\n this._expanded = false;\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _submit(): void {\n const trimmed = this._draft.trim();\n if (trimmed === \"\") return;\n this.value = \"\";\n this._draft = \"\";\n this._expanded = false;\n this.dispatchEvent(\n new CustomEvent(\"submit\", { detail: { value: trimmed }, bubbles: true, composed: true }),\n );\n }\n\n private _onKeydown(e: KeyboardEvent): void {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n } else if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n this._submit();\n }\n }\n\n protected override updated(changed: Map<string, unknown>): void {\n if (changed.has(\"_expanded\") && this._expanded) {\n const field = this._textarea;\n if (!field) return;\n field.focus();\n const end = field.value.length;\n field.setSelectionRange(end, end);\n }\n }\n\n override render() {\n const canSubmit = this._draft.trim() !== \"\";\n return html`\n <div class=\"shell ${this._expanded ? \"expanded\" : \"\"}\">\n ${this._expanded\n ? html`\n <textarea\n rows=${this.rows}\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @input=${this._onInput}\n @keydown=${this._onKeydown}\n ></textarea>\n <div class=\"footer\">\n <form-actions>\n <ui-button\n slot=\"secondary\"\n variant=\"secondary\"\n size=\"sm\"\n @click=${this._cancel}\n >${this.cancelLabel}</ui-button\n >\n <ui-button\n slot=\"primary\"\n variant=\"primary\"\n size=\"sm\"\n ?disabled=${!canSubmit}\n @click=${this._submit}\n >${this.submitLabel}</ui-button\n >\n </form-actions>\n </div>\n `\n : html`\n <input\n type=\"text\"\n .value=${this.value}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @focus=${this._expand}\n @click=${this._expand}\n />\n `}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"comment-composer\": CommentComposer;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"comment-composer.js","sourceRoot":"","sources":["../src/comment-composer.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QAqEL,6DAA6D;QACjD,UAAK,GAAG,EAAE,CAAC;QACvB,yCAAyC;QAC7B,gBAAW,GAAG,gBAAgB,CAAC;QAC3C,qDAAqD;QACzC,UAAK,GAAG,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UAAU,CAAC;kDAAyC;AAvFhD,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CA0M3B","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport \"./form-actions.js\";\nimport \"./kbd-hint.js\";\nimport \"./ui-button.js\";\n\n/**\n * GitHub/Slack-style comment composer: a one-line text field that expands\n * into a multi-line textarea with a bottom-right Cancel/Submit footer\n * (`form-actions`) as soon as it's focused or clicked. Submitting fires\n * `submit` with the trimmed value, then clears the field and collapses back\n * to one line — it's meant for posting one comment at a time, not editing a\n * persistent value in place (see `editable-text` for that). Canceling (the\n * Cancel button or `Escape`) discards the draft and collapses without\n * firing `submit`. Clicking away (blur) does neither — the composer stays\n * expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`\n * submits from the textarea, matching `editable-text`'s multiline shortcut —\n * the Submit button always shows a `kbd-hint` for it, so the shortcut is\n * discoverable rather than a hidden power-user feature. Calling the standard\n * `.focus()` method expands the composer (if collapsed) and focuses its\n * field, for an ancestor that wants to drive it programmatically.\n * Purely token-styled (no bespoke colors), so it's themeable via the same\n * `--ui-*` custom properties as every other value-entry field.\n *\n * @element comment-composer\n * @fires submit - User submitted a non-empty comment; detail: `{ value: string }`.\n * @fires cancel - User discarded the draft via the Cancel button or `Escape`.\n */\n@customElement(\"comment-composer\")\nexport class CommentComposer extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .shell {\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-surface, #ffffff);\n }\n .shell.expanded {\n border-radius: var(--ui-radius, 0.5rem);\n }\n input,\n textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n background: none;\n color: var(--ui-text, #0f172a);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n padding: 0.5rem 0.75rem;\n outline: none;\n }\n textarea {\n resize: none;\n }\n input:focus-visible,\n .shell:not(.expanded):focus-within {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n textarea:focus-visible {\n outline: none;\n }\n .footer {\n display: flex;\n justify-content: flex-end;\n padding: 0.5rem 0.75rem 0.75rem;\n }\n input:disabled,\n textarea:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n @media (forced-colors: active) {\n .shell:not(.expanded):focus-within {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Committed value shown in the collapsed one-line field. */\n @property() value = \"\";\n /** Placeholder text shown when empty. */\n @property() placeholder = \"Add a comment…\";\n /** Accessible name applied to the input/textarea. */\n @property() label = \"Comment\";\n /** Visible row count once expanded. */\n @property({ type: Number }) rows = 4;\n /** Label for the primary submit button. */\n @property({ attribute: \"submit-label\" }) submitLabel = \"Submit\";\n /** Label for the secondary cancel button. */\n @property({ attribute: \"cancel-label\" }) cancelLabel = \"Cancel\";\n /** Disables the field entirely. */\n @property({ type: Boolean }) disabled = false;\n\n @state() private _expanded = false;\n @state() private _draft = \"\";\n\n @query(\"textarea\") private _textarea?: HTMLTextAreaElement;\n\n private _expand(): void {\n if (this.disabled || this._expanded) return;\n this._draft = this.value;\n this._expanded = true;\n }\n\n /**\n * Expands the composer (if collapsed) and focuses its field, so an\n * ancestor can drive it programmatically — e.g. a \"reply\" affordance\n * elsewhere on the page that should land the user in this composer\n * already expanded, not just visually scrolled to a one-line input.\n * A no-op while `disabled`. Expanding re-renders asynchronously; the\n * actual focus happens in `updated()` once the textarea exists.\n */\n override focus(options?: FocusOptions): void {\n if (this.disabled) return;\n if (!this._expanded) {\n this._expand();\n return;\n }\n this._textarea?.focus(options);\n }\n\n private _onInput(e: Event): void {\n this._draft = (e.target as HTMLInputElement | HTMLTextAreaElement).value;\n }\n\n private _cancel(): void {\n this._draft = this.value;\n this._expanded = false;\n this.dispatchEvent(new CustomEvent(\"cancel\", { bubbles: true, composed: true }));\n }\n\n private _submit(): void {\n const trimmed = this._draft.trim();\n if (trimmed === \"\") return;\n this.value = \"\";\n this._draft = \"\";\n this._expanded = false;\n this.dispatchEvent(\n new CustomEvent(\"submit\", { detail: { value: trimmed }, bubbles: true, composed: true }),\n );\n }\n\n private _onKeydown(e: KeyboardEvent): void {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n } else if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n this._submit();\n }\n }\n\n protected override updated(changed: Map<string, unknown>): void {\n if (changed.has(\"_expanded\") && this._expanded) {\n const field = this._textarea;\n if (!field) return;\n field.focus();\n const end = field.value.length;\n field.setSelectionRange(end, end);\n }\n }\n\n override render() {\n const canSubmit = this._draft.trim() !== \"\";\n return html`\n <div class=\"shell ${this._expanded ? \"expanded\" : \"\"}\">\n ${this._expanded\n ? html`\n <textarea\n rows=${this.rows}\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @input=${this._onInput}\n @keydown=${this._onKeydown}\n ></textarea>\n <div class=\"footer\">\n <form-actions>\n <ui-button\n slot=\"secondary\"\n variant=\"secondary\"\n size=\"sm\"\n @click=${this._cancel}\n >${this.cancelLabel}</ui-button\n >\n <ui-button\n slot=\"primary\"\n variant=\"primary\"\n size=\"sm\"\n ?disabled=${!canSubmit}\n @click=${this._submit}\n >${this.submitLabel} <kbd-hint keys=\"Mod+Enter\"></kbd-hint\n ></ui-button>\n </form-actions>\n </div>\n `\n : html`\n <input\n type=\"text\"\n .value=${this.value}\n placeholder=${this.placeholder}\n aria-label=${this.label}\n ?disabled=${this.disabled}\n @focus=${this._expand}\n @click=${this._expand}\n />\n `}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"comment-composer\": CommentComposer;\n }\n}\n"]}
|
|
@@ -26,6 +26,20 @@ interface ToastOptions {
|
|
|
26
26
|
* auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
27
27
|
* button. Appears/disappears instantly — no slide/fade transitions.
|
|
28
28
|
*
|
|
29
|
+
* Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
30
|
+
* (`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
31
|
+
* `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
32
|
+
* so those stay the single source of truth for every other component. A
|
|
33
|
+
* consumer can override just these toast-specific tokens with a
|
|
34
|
+
* `linear-gradient(...)` to opt every toast into a gradient look without
|
|
35
|
+
* touching component markup — `gradientTokenValues` in `tokens.ts` ships
|
|
36
|
+
* exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
|
|
37
|
+
* "Gradient theme" section), the same mechanism `ui-button` uses.
|
|
38
|
+
* `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
|
|
39
|
+
* existing elevation shadow) and `--ui-toast-text-shadow` (legibility
|
|
40
|
+
* against the gradient's lighter stop) round out the effect, mirroring
|
|
41
|
+
* `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
|
|
42
|
+
*
|
|
29
43
|
* @element toast-notification
|
|
30
44
|
*/
|
|
31
45
|
export declare class ToastNotification extends LitElement {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-notification.d.ts","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,OAAO,EAAE,MAAM,KAAK,CAAC;AAWrD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpE,UAAU,YAAY;IACpB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AO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAElE;AAED,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAE/D;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,QAElE"}
|
|
@@ -24,6 +24,20 @@ const DEFAULT_DURATION_MS = 5000;
|
|
|
24
24
|
* auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
25
25
|
* button. Appears/disappears instantly — no slide/fade transitions.
|
|
26
26
|
*
|
|
27
|
+
* Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
28
|
+
* (`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
29
|
+
* `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
30
|
+
* so those stay the single source of truth for every other component. A
|
|
31
|
+
* consumer can override just these toast-specific tokens with a
|
|
32
|
+
* `linear-gradient(...)` to opt every toast into a gradient look without
|
|
33
|
+
* touching component markup — `gradientTokenValues` in `tokens.ts` ships
|
|
34
|
+
* exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
|
|
35
|
+
* "Gradient theme" section), the same mechanism `ui-button` uses.
|
|
36
|
+
* `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
|
|
37
|
+
* existing elevation shadow) and `--ui-toast-text-shadow` (legibility
|
|
38
|
+
* against the gradient's lighter stop) round out the effect, mirroring
|
|
39
|
+
* `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
|
|
40
|
+
*
|
|
27
41
|
* @element toast-notification
|
|
28
42
|
*/
|
|
29
43
|
let ToastNotification = class ToastNotification extends LitElement {
|
|
@@ -55,10 +69,10 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
55
69
|
border-radius: var(--ui-radius, 0.5rem);
|
|
56
70
|
padding: 0.75rem;
|
|
57
71
|
box-shadow: var(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
--ui-shadow-lg,
|
|
73
|
+
0 20px 25px -5px rgb(0 0 0 / 0.1),
|
|
74
|
+
0 8px 10px -6px rgb(0 0 0 / 0.1)
|
|
75
|
+
), var(--ui-toast-highlight, 0 0 0 0 transparent);
|
|
62
76
|
font-family: var(
|
|
63
77
|
--ui-font,
|
|
64
78
|
ui-sans-serif,
|
|
@@ -73,18 +87,19 @@ let ToastNotification = class ToastNotification extends LitElement {
|
|
|
73
87
|
line-height: var(--ui-line-height-normal, 1.5);
|
|
74
88
|
color: var(--ui-on-accent, #ffffff);
|
|
75
89
|
background: var(--ui-text, #0f172a);
|
|
90
|
+
text-shadow: var(--ui-toast-text-shadow, none);
|
|
76
91
|
}
|
|
77
92
|
.toast.error {
|
|
78
|
-
background: var(--ui-danger, #dc2626);
|
|
93
|
+
background: var(--ui-toast-error-background, var(--ui-danger, #dc2626));
|
|
79
94
|
}
|
|
80
95
|
.toast.success {
|
|
81
|
-
background: var(--ui-success, #16a34a);
|
|
96
|
+
background: var(--ui-toast-success-background, var(--ui-success, #16a34a));
|
|
82
97
|
}
|
|
83
98
|
.toast.info {
|
|
84
|
-
background: var(--ui-info, #0ea5e9);
|
|
99
|
+
background: var(--ui-toast-info-background, var(--ui-info, #0ea5e9));
|
|
85
100
|
}
|
|
86
101
|
.toast.warning {
|
|
87
|
-
background: var(--ui-warning, #d97706);
|
|
102
|
+
background: var(--ui-toast-warning-background, var(--ui-warning, #d97706));
|
|
88
103
|
}
|
|
89
104
|
.icon {
|
|
90
105
|
flex: 0 0 auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa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,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, state } from \"lit/decorators.js\";\nimport {\n iconCheckCircle,\n iconExclamationCircle,\n iconExclamationTriangle,\n iconInfo,\n iconX,\n} from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ToastVariant = \"error\" | \"info\" | \"success\" | \"warning\";\n\ninterface ToastOptions {\n /** Visual style; also selects the accent color. Defaults to \"info\". */\n variant?: ToastVariant;\n /** Auto-dismiss delay in ms. Pass 0 to require a manual close. Defaults to 5000. */\n duration?: number;\n /**\n * Optional secondary line shown beneath the headline in smaller, non-bold\n * type. Omit for a single-line toast.\n */\n description?: string;\n}\n\ninterface Toast {\n id: number;\n message: string;\n variant: ToastVariant;\n description?: string;\n}\n\nconst DEFAULT_DURATION_MS = 5000;\n\n/**\n * Fixed-position stack of dismissible notifications, anchored top-right\n * (top-full-width on mobile). Every toast shares one fixed width so entries\n * never appear narrower or wider than one another. Not wired to any app state\n * yet — callers add toasts imperatively via the `show()` method on a live\n * element reference,\n * e.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\n * or via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\n * exported from this file. The first argument is the required bold headline; an\n * optional `description` renders a smaller, non-bold second line. Each variant\n * leads with a matching status icon (success → check, error → exclamation\n * circle, info → information circle, warning → exclamation triangle). Each toast\n * auto-dismisses after `duration` ms and can also be dismissed via its ✕\n * button. Appears/disappears instantly — no slide/fade transitions.\n *\n * @element toast-notification\n */\n@customElement(\"toast-notification\")\nexport class ToastNotification extends LitElement {\n @state() private _toasts: Toast[] = [];\n\n private _nextId = 0;\n private _timers = new Map<number, ReturnType<typeof setTimeout>>();\n\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 200;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n width: 22.5rem;\n pointer-events: none;\n }\n .toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n padding: 0.75rem;\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-text, #0f172a);\n }\n .toast.error {\n background: var(--ui-danger, #dc2626);\n }\n .toast.success {\n background: var(--ui-success, #16a34a);\n }\n .toast.info {\n background: var(--ui-info, #0ea5e9);\n }\n .toast.warning {\n background: var(--ui-warning, #d97706);\n }\n .icon {\n flex: 0 0 auto;\n margin-top: 0.125rem;\n line-height: var(--ui-line-height-glyph, 1);\n }\n .content {\n flex: 1 1 auto;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .message {\n font-weight: var(--ui-font-weight-semibold, 600);\n word-break: break-word;\n }\n .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n word-break: break-word;\n }\n .close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n background: none;\n border: none;\n padding: 0;\n margin: -0.25rem -0.25rem -0.25rem 0;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n line-height: var(--ui-line-height-glyph, 1);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .close:hover {\n opacity: 1;\n background: var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .close:focus-visible {\n outline: none;\n opacity: 1;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .toast {\n border: 1px solid CanvasText;\n forced-color-adjust: auto;\n }\n .close:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n :host {\n top: 0.75rem;\n right: 0.75rem;\n left: 0.75rem;\n width: auto;\n }\n }\n `,\n ];\n\n /**\n * Queues a toast for display.\n * @param message Text to show.\n * @param options Variant + auto-dismiss duration (see {@link ToastOptions}).\n * @returns The toast's id — pass to `dismiss()` to remove it early.\n */\n show(message: string, options: ToastOptions = {}): number {\n const id = this._nextId++;\n const variant = options.variant ?? \"info\";\n const duration = options.duration ?? DEFAULT_DURATION_MS;\n this._toasts = [...this._toasts, { id, message, variant, description: options.description }];\n if (duration > 0) {\n this._timers.set(\n id,\n setTimeout(() => this.dismiss(id), duration),\n );\n }\n return id;\n }\n\n /**\n * Removes a toast immediately, cancelling its pending auto-dismiss timer if any.\n * @param id The id returned by `show()`.\n */\n dismiss(id: number) {\n const timer = this._timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this._timers.delete(id);\n }\n this._toasts = this._toasts.filter((t) => t.id !== id);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n for (const timer of this._timers.values()) clearTimeout(timer);\n this._timers.clear();\n }\n\n /**\n * Returns the decorative status icon for a variant, sized as a standalone\n * 18px glyph to match the dismiss button.\n * @param variant The toast variant.\n */\n private _variantIcon(variant: ToastVariant) {\n switch (variant) {\n case \"success\":\n return iconCheckCircle(18);\n case \"error\":\n return iconExclamationCircle(18);\n case \"warning\":\n return iconExclamationTriangle(18);\n default:\n return iconInfo(18);\n }\n }\n\n override render() {\n if (this._toasts.length === 0) return nothing;\n return html`\n ${this._toasts.map(\n (t) => html`\n <div\n class=\"toast ${t.variant}\"\n role=${t.variant === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n >\n <span class=\"icon\" aria-hidden=\"true\">${this._variantIcon(t.variant)}</span>\n <div class=\"content\">\n <span class=\"message\">${t.message}</span>\n ${t.description ? html`<span class=\"description\">${t.description}</span>` : nothing}\n </div>\n <button class=\"close\" aria-label=\"Dismiss notification\" @click=${() => this.dismiss(t.id)}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n `,\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"toast-notification\": ToastNotification;\n }\n}\n\nfunction getToast(): ToastNotification | null {\n return document.querySelector(\"toast-notification\");\n}\n\n/** Shows an error toast. Use for connection/network failures, not validation errors. */\nexport function notifyError(message: string, description?: string) {\n getToast()?.show(message, { variant: \"error\", description });\n}\n\n/** Shows a success toast. */\nexport function notifySuccess(message: string, description?: string) {\n getToast()?.show(message, { variant: \"success\", description });\n}\n\n/** Shows an info toast. */\nexport function notifyInfo(message: string, description?: string) {\n getToast()?.show(message, { variant: \"info\", description });\n}\n\n/** Shows a warning toast. */\nexport function notifyWarning(message: string, description?: string) {\n getToast()?.show(message, { variant: \"warning\", description });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../src/toast-notification.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,QAAQ,EACR,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuBrC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG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,CAAC,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,OAAO;;6EAEpB,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;yCAC5D,KAAK,CAAC,EAAE,CAAC;;;SAGzC,CACF;KACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjNkB;IAAhB,KAAK,EAAE;kDAA+B;AAD5B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CAkN7B;;AAQD,SAAS,QAAQ;IACf,OAAO,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,WAAoB;IAC/D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,WAAoB;IAC9D,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,WAAoB;IACjE,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, state } from \"lit/decorators.js\";\nimport {\n iconCheckCircle,\n iconExclamationCircle,\n iconExclamationTriangle,\n iconInfo,\n iconX,\n} from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport type ToastVariant = \"error\" | \"info\" | \"success\" | \"warning\";\n\ninterface ToastOptions {\n /** Visual style; also selects the accent color. Defaults to \"info\". */\n variant?: ToastVariant;\n /** Auto-dismiss delay in ms. Pass 0 to require a manual close. Defaults to 5000. */\n duration?: number;\n /**\n * Optional secondary line shown beneath the headline in smaller, non-bold\n * type. Omit for a single-line toast.\n */\n description?: string;\n}\n\ninterface Toast {\n id: number;\n message: string;\n variant: ToastVariant;\n description?: string;\n}\n\nconst DEFAULT_DURATION_MS = 5000;\n\n/**\n * Fixed-position stack of dismissible notifications, anchored top-right\n * (top-full-width on mobile). Every toast shares one fixed width so entries\n * never appear narrower or wider than one another. Not wired to any app state\n * yet — callers add toasts imperatively via the `show()` method on a live\n * element reference,\n * e.g. `document.querySelector('toast-notification')?.show('Offline', { variant: 'error' })`,\n * or via the `notifySuccess`/`notifyError`/`notifyInfo` module-level helpers\n * exported from this file. The first argument is the required bold headline; an\n * optional `description` renders a smaller, non-bold second line. Each variant\n * leads with a matching status icon (success → check, error → exclamation\n * circle, info → information circle, warning → exclamation triangle). Each toast\n * auto-dismisses after `duration` ms and can also be dismissed via its ✕\n * button. Appears/disappears instantly — no slide/fade transitions.\n *\n * Each variant's background reads a dedicated `--ui-toast-*-background` hook\n * (`success`/`error`/`info`/`warning`), which defaults to the flat\n * `--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —\n * so those stay the single source of truth for every other component. A\n * consumer can override just these toast-specific tokens with a\n * `linear-gradient(...)` to opt every toast into a gradient look without\n * touching component markup — `gradientTokenValues` in `tokens.ts` ships\n * exactly this, wired up via `data-theme=\"gradient\"` (see `tokens.css`'s\n * \"Gradient theme\" section), the same mechanism `ui-button` uses.\n * `--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the\n * existing elevation shadow) and `--ui-toast-text-shadow` (legibility\n * against the gradient's lighter stop) round out the effect, mirroring\n * `ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.\n *\n * @element toast-notification\n */\n@customElement(\"toast-notification\")\nexport class ToastNotification extends LitElement {\n @state() private _toasts: Toast[] = [];\n\n private _nextId = 0;\n private _timers = new Map<number, ReturnType<typeof setTimeout>>();\n\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 200;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n width: 22.5rem;\n pointer-events: none;\n }\n .toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n padding: 0.75rem;\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n ), var(--ui-toast-highlight, 0 0 0 0 transparent);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-text, #0f172a);\n text-shadow: var(--ui-toast-text-shadow, none);\n }\n .toast.error {\n background: var(--ui-toast-error-background, var(--ui-danger, #dc2626));\n }\n .toast.success {\n background: var(--ui-toast-success-background, var(--ui-success, #16a34a));\n }\n .toast.info {\n background: var(--ui-toast-info-background, var(--ui-info, #0ea5e9));\n }\n .toast.warning {\n background: var(--ui-toast-warning-background, var(--ui-warning, #d97706));\n }\n .icon {\n flex: 0 0 auto;\n margin-top: 0.125rem;\n line-height: var(--ui-line-height-glyph, 1);\n }\n .content {\n flex: 1 1 auto;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .message {\n font-weight: var(--ui-font-weight-semibold, 600);\n word-break: break-word;\n }\n .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n word-break: break-word;\n }\n .close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n background: none;\n border: none;\n padding: 0;\n margin: -0.25rem -0.25rem -0.25rem 0;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n line-height: var(--ui-line-height-glyph, 1);\n border-radius: var(--ui-radius-sm, 0.25rem);\n }\n .close:hover {\n opacity: 1;\n background: var(--ui-hover-overlay, rgb(255 255 255 / 0.32));\n }\n .close:focus-visible {\n outline: none;\n opacity: 1;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .toast {\n border: 1px solid CanvasText;\n forced-color-adjust: auto;\n }\n .close:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n :host {\n top: 0.75rem;\n right: 0.75rem;\n left: 0.75rem;\n width: auto;\n }\n }\n `,\n ];\n\n /**\n * Queues a toast for display.\n * @param message Text to show.\n * @param options Variant + auto-dismiss duration (see {@link ToastOptions}).\n * @returns The toast's id — pass to `dismiss()` to remove it early.\n */\n show(message: string, options: ToastOptions = {}): number {\n const id = this._nextId++;\n const variant = options.variant ?? \"info\";\n const duration = options.duration ?? DEFAULT_DURATION_MS;\n this._toasts = [...this._toasts, { id, message, variant, description: options.description }];\n if (duration > 0) {\n this._timers.set(\n id,\n setTimeout(() => this.dismiss(id), duration),\n );\n }\n return id;\n }\n\n /**\n * Removes a toast immediately, cancelling its pending auto-dismiss timer if any.\n * @param id The id returned by `show()`.\n */\n dismiss(id: number) {\n const timer = this._timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this._timers.delete(id);\n }\n this._toasts = this._toasts.filter((t) => t.id !== id);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n for (const timer of this._timers.values()) clearTimeout(timer);\n this._timers.clear();\n }\n\n /**\n * Returns the decorative status icon for a variant, sized as a standalone\n * 18px glyph to match the dismiss button.\n * @param variant The toast variant.\n */\n private _variantIcon(variant: ToastVariant) {\n switch (variant) {\n case \"success\":\n return iconCheckCircle(18);\n case \"error\":\n return iconExclamationCircle(18);\n case \"warning\":\n return iconExclamationTriangle(18);\n default:\n return iconInfo(18);\n }\n }\n\n override render() {\n if (this._toasts.length === 0) return nothing;\n return html`\n ${this._toasts.map(\n (t) => html`\n <div\n class=\"toast ${t.variant}\"\n role=${t.variant === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n >\n <span class=\"icon\" aria-hidden=\"true\">${this._variantIcon(t.variant)}</span>\n <div class=\"content\">\n <span class=\"message\">${t.message}</span>\n ${t.description ? html`<span class=\"description\">${t.description}</span>` : nothing}\n </div>\n <button class=\"close\" aria-label=\"Dismiss notification\" @click=${() => this.dismiss(t.id)}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n `,\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"toast-notification\": ToastNotification;\n }\n}\n\nfunction getToast(): ToastNotification | null {\n return document.querySelector(\"toast-notification\");\n}\n\n/** Shows an error toast. Use for connection/network failures, not validation errors. */\nexport function notifyError(message: string, description?: string) {\n getToast()?.show(message, { variant: \"error\", description });\n}\n\n/** Shows a success toast. */\nexport function notifySuccess(message: string, description?: string) {\n getToast()?.show(message, { variant: \"success\", description });\n}\n\n/** Shows an info toast. */\nexport function notifyInfo(message: string, description?: string) {\n getToast()?.show(message, { variant: \"info\", description });\n}\n\n/** Shows a warning toast. */\nexport function notifyWarning(message: string, description?: string) {\n getToast()?.show(message, { variant: \"warning\", description });\n}\n"]}
|
package/dist/tokens.css
CHANGED
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
--ui-success: #16a34a;
|
|
27
27
|
--ui-warning: #d97706;
|
|
28
28
|
--ui-warning-hover: #b45309;
|
|
29
|
+
--ui-toast-success-background: var(--ui-success, #16a34a);
|
|
30
|
+
--ui-toast-error-background: var(--ui-danger, #dc2626);
|
|
31
|
+
--ui-toast-info-background: var(--ui-info, #0ea5e9);
|
|
32
|
+
--ui-toast-warning-background: var(--ui-warning, #d97706);
|
|
33
|
+
--ui-toast-highlight: 0 0 0 0 transparent;
|
|
34
|
+
--ui-toast-text-shadow: none;
|
|
29
35
|
--ui-on-accent: #ffffff;
|
|
30
36
|
--ui-text: #0f172a;
|
|
31
37
|
--ui-text-muted: #64748b;
|
|
@@ -122,12 +128,18 @@
|
|
|
122
128
|
--ui-button-danger-background-hover: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
|
|
123
129
|
--ui-button-danger-background-active: linear-gradient(180deg, #dc2626 0%, #ef4444 100%);
|
|
124
130
|
--ui-button-danger-border: #b91c1c;
|
|
125
|
-
--ui-button-secondary-background: linear-gradient(180deg, #
|
|
126
|
-
--ui-button-secondary-background-hover: linear-gradient(180deg, #
|
|
127
|
-
--ui-button-secondary-background-active: linear-gradient(180deg, #f1f5f9 0%, #
|
|
131
|
+
--ui-button-secondary-background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
|
|
132
|
+
--ui-button-secondary-background-hover: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
|
|
133
|
+
--ui-button-secondary-background-active: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
|
|
128
134
|
--ui-button-secondary-border: #cbd5e1;
|
|
129
135
|
--ui-button-secondary-border-hover: #94a3b8;
|
|
130
136
|
--ui-button-highlight: inset 0 1px 0 rgb(255 255 255 / 0.35);
|
|
131
137
|
--ui-button-text-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
|
|
132
138
|
--ui-button-accent: #4338ca;
|
|
139
|
+
--ui-toast-success-background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
|
|
140
|
+
--ui-toast-error-background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
|
|
141
|
+
--ui-toast-info-background: linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%);
|
|
142
|
+
--ui-toast-warning-background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
|
|
143
|
+
--ui-toast-highlight: inset 0 1px 0 rgb(255 255 255 / 0.35);
|
|
144
|
+
--ui-toast-text-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
|
|
133
145
|
}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -22,14 +22,15 @@ export declare const darkTokenValues: Record<string, string>;
|
|
|
22
22
|
* `"light"` override and layers a glossy gradient look on top of the flat
|
|
23
23
|
* light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/
|
|
24
24
|
* `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that
|
|
25
|
-
* file's doc comment)
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
25
|
+
* file's doc comment), plus the `--ui-toast-*` hooks `toast-notification.ts`
|
|
26
|
+
* reads (see its doc comment). Every other token (`--ui-text`, `--ui-surface`,
|
|
27
|
+
* …) is left at its light-mode default — this theme only glosses buttons and
|
|
28
|
+
* toasts by design. Each variant's gradient runs light-to-dark top-to-bottom
|
|
29
|
+
* (`180deg`) across one Tailwind shade step lighter/darker than the flat
|
|
30
|
+
* token so it still reads as "the same color, glossy" rather than a
|
|
31
|
+
* different hue; `-hover` shifts the whole pair one shade lighter, `-active`
|
|
32
|
+
* reverses the two stops for a pressed/"indented" look, and `-border` is a
|
|
33
|
+
* shade darker than the gradient's dark stop for a defining edge.
|
|
33
34
|
*/
|
|
34
35
|
export declare const gradientTokenValues: Record<string, string>;
|
|
35
36
|
/**
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8H9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkCtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,yBAAQ,CAAC"}
|
package/dist/tokens.js
CHANGED
|
@@ -74,6 +74,20 @@ export const tokenValues = {
|
|
|
74
74
|
"--ui-success": "#16a34a", // green-600
|
|
75
75
|
"--ui-warning": "#d97706", // amber-600
|
|
76
76
|
"--ui-warning-hover": "#b45309", // amber-700
|
|
77
|
+
// toast-notification's per-variant background hooks: default to the flat
|
|
78
|
+
// --ui-success/--ui-danger/--ui-info/--ui-warning tokens unchanged, so
|
|
79
|
+
// those stay the single source of truth for every other component —
|
|
80
|
+
// the same pattern as --ui-button-background/--ui-button-danger-background
|
|
81
|
+
// above. `-highlight`/`-text-shadow` are the same glossy-top-edge /
|
|
82
|
+
// legibility-shadow pair as --ui-button-highlight/--ui-button-text-shadow,
|
|
83
|
+
// kept as separate tokens so a theme can gloss toasts and buttons
|
|
84
|
+
// independently.
|
|
85
|
+
"--ui-toast-success-background": "var(--ui-success, #16a34a)",
|
|
86
|
+
"--ui-toast-error-background": "var(--ui-danger, #dc2626)",
|
|
87
|
+
"--ui-toast-info-background": "var(--ui-info, #0ea5e9)",
|
|
88
|
+
"--ui-toast-warning-background": "var(--ui-warning, #d97706)",
|
|
89
|
+
"--ui-toast-highlight": "0 0 0 0 transparent",
|
|
90
|
+
"--ui-toast-text-shadow": "none",
|
|
77
91
|
"--ui-on-accent": "#ffffff",
|
|
78
92
|
"--ui-text": "#0f172a", // slate-900
|
|
79
93
|
"--ui-text-muted": "#64748b", // slate-500
|
|
@@ -146,14 +160,15 @@ export const darkTokenValues = {
|
|
|
146
160
|
* `"light"` override and layers a glossy gradient look on top of the flat
|
|
147
161
|
* light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/
|
|
148
162
|
* `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that
|
|
149
|
-
* file's doc comment)
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
163
|
+
* file's doc comment), plus the `--ui-toast-*` hooks `toast-notification.ts`
|
|
164
|
+
* reads (see its doc comment). Every other token (`--ui-text`, `--ui-surface`,
|
|
165
|
+
* …) is left at its light-mode default — this theme only glosses buttons and
|
|
166
|
+
* toasts by design. Each variant's gradient runs light-to-dark top-to-bottom
|
|
167
|
+
* (`180deg`) across one Tailwind shade step lighter/darker than the flat
|
|
168
|
+
* token so it still reads as "the same color, glossy" rather than a
|
|
169
|
+
* different hue; `-hover` shifts the whole pair one shade lighter, `-active`
|
|
170
|
+
* reverses the two stops for a pressed/"indented" look, and `-border` is a
|
|
171
|
+
* shade darker than the gradient's dark stop for a defining edge.
|
|
157
172
|
*/
|
|
158
173
|
export const gradientTokenValues = {
|
|
159
174
|
"--ui-button-background": "linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)", // indigo-500 -> 600
|
|
@@ -164,18 +179,31 @@ export const gradientTokenValues = {
|
|
|
164
179
|
"--ui-button-danger-background-hover": "linear-gradient(180deg, #f87171 0%, #ef4444 100%)", // red-400 -> 500
|
|
165
180
|
"--ui-button-danger-background-active": "linear-gradient(180deg, #dc2626 0%, #ef4444 100%)", // reversed 600 -> 500
|
|
166
181
|
"--ui-button-danger-border": "#b91c1c", // red-700
|
|
167
|
-
// Secondary stays
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
// Secondary stays neutral gray rather than a saturated hue, matching its
|
|
183
|
+
// flat "not the primary action" role, but one shade darker than the
|
|
184
|
+
// original white -> slate-50 pairing: at a small button size, that pair
|
|
185
|
+
// read as flat white with no visible gradient at all. slate-50 -> 100
|
|
186
|
+
// keeps enough contrast to actually look like a gradient while still
|
|
187
|
+
// being clearly lighter/quieter than primary/danger. Border stays
|
|
188
|
+
// slate-300 (a step past the flat slate-200) so its edge still reads
|
|
189
|
+
// against the fill.
|
|
190
|
+
"--ui-button-secondary-background": "linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)", // slate-50 -> 100
|
|
191
|
+
"--ui-button-secondary-background-hover": "linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%)", // slate-100 -> 200
|
|
192
|
+
"--ui-button-secondary-background-active": "linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%)", // reversed 100 -> 50
|
|
174
193
|
"--ui-button-secondary-border": "#cbd5e1", // slate-300
|
|
175
194
|
"--ui-button-secondary-border-hover": "#94a3b8", // slate-400
|
|
176
195
|
"--ui-button-highlight": "inset 0 1px 0 rgb(255 255 255 / 0.35)", // glossy top edge
|
|
177
196
|
"--ui-button-text-shadow": "0 1px 1px rgb(0 0 0 / 0.25)", // legibility on primary/danger
|
|
178
197
|
"--ui-button-accent": "#4338ca", // indigo-700, matches --ui-button-border
|
|
198
|
+
// toast-notification: same light-to-dark, one-shade-step gradient
|
|
199
|
+
// convention as the button variants above; the bottom stop always matches
|
|
200
|
+
// the flat --ui-success/--ui-danger/--ui-info/--ui-warning value exactly.
|
|
201
|
+
"--ui-toast-success-background": "linear-gradient(180deg, #22c55e 0%, #16a34a 100%)", // green-500 -> 600
|
|
202
|
+
"--ui-toast-error-background": "linear-gradient(180deg, #ef4444 0%, #dc2626 100%)", // red-500 -> 600
|
|
203
|
+
"--ui-toast-info-background": "linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%)", // sky-400 -> 500
|
|
204
|
+
"--ui-toast-warning-background": "linear-gradient(180deg, #f59e0b 0%, #d97706 100%)", // amber-500 -> 600
|
|
205
|
+
"--ui-toast-highlight": "inset 0 1px 0 rgb(255 255 255 / 0.35)", // glossy top edge, same as --ui-button-highlight
|
|
206
|
+
"--ui-toast-text-shadow": "0 1px 1px rgb(0 0 0 / 0.25)", // legibility, same as --ui-button-text-shadow
|
|
179
207
|
};
|
|
180
208
|
/**
|
|
181
209
|
* Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,SAAS;IACT,cAAc,EAAE,SAAS,EAAE,aAAa;IACxC,oBAAoB,EAAE,SAAS,EAAE,aAAa;IAC9C,4EAA4E;IAC5E,2EAA2E;IAC3E,0EAA0E;IAC1E,uEAAuE;IACvE,yEAAyE;IACzE,wEAAwE;IACxE,sEAAsE;IACtE,uEAAuE;IACvE,wEAAwE;IACxE,wEAAwE;IACxE,wBAAwB,EAAE,4BAA4B;IACtD,8BAA8B,EAAE,kCAAkC;IAClE,+BAA+B,EAAE,yDAAyD;IAC1F,oBAAoB,EAAE,aAAa;IACnC,yEAAyE;IACzE,uEAAuE;IACvE,wEAAwE;IACxE,oEAAoE;IACpE,oEAAoE;IACpE,kEAAkE;IAClE,kCAAkC,EAAE,MAAM;IAC1C,wCAAwC,EAAE,MAAM;IAChD,yCAAyC,EAAE,6CAA6C;IACxF,8BAA8B,EAAE,2BAA2B;IAC3D,oCAAoC,EAAE,+BAA+B;IAC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EAAE,YAAY;IACvC,oBAAoB,EAAE,SAAS,EAAE,YAAY;IAC7C,gBAAgB,EAAE,SAAS,EAAE,qDAAqD;IAClF,cAAc,EAAE,SAAS,EAAE,YAAY;IACvC,oBAAoB,EAAE,yBAAyB;IAC/C,cAAc,EAAE,mBAAmB,EAAE,kBAAkB;IACvD,iBAAiB,EAAE,kCAAkC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,wBAAwB,EAAE,mDAAmD,EAAE,oBAAoB;IACnG,8BAA8B,EAAE,mDAAmD,EAAE,oBAAoB;IACzG,+BAA+B,EAAE,mDAAmD,EAAE,sBAAsB;IAC5G,oBAAoB,EAAE,SAAS,EAAE,aAAa;IAC9C,+BAA+B,EAAE,mDAAmD,EAAE,iBAAiB;IACvG,qCAAqC,EAAE,mDAAmD,EAAE,iBAAiB;IAC7G,sCAAsC,EAAE,mDAAmD,EAAE,sBAAsB;IACnH,2BAA2B,EAAE,SAAS,EAAE,UAAU;IAClD,0EAA0E;IAC1E,mEAAmE;IACnE,wEAAwE;IACxE,oDAAoD;IACpD,kCAAkC,EAAE,mDAAmD,EAAE,oBAAoB;IAC7G,wCAAwC,EAAE,mDAAmD,EAAE,kBAAkB;IACjH,yCAAyC,EAAE,mDAAmD,EAAE,wBAAwB;IACxH,8BAA8B,EAAE,SAAS,EAAE,YAAY;IACvD,oCAAoC,EAAE,SAAS,EAAE,YAAY;IAC7D,uBAAuB,EAAE,uCAAuC,EAAE,kBAAkB;IACpF,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B;IACzF,oBAAoB,EAAE,SAAS,EAAE,yCAAyC;CAC3E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,EAAE,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Design token values, sourced from Tailwind v4's default theme palette.\n * Each entry maps a `--ui-*` custom property name to its default value.\n * These are the same values baked in as `var(--ui-*, <fallback>)` fallbacks\n * throughout component styles, so components render correctly with zero\n * external CSS. Consumers may override any of these by setting the custom\n * property on `:root` or an ancestor element (see `tokens.css`).\n */\nexport const tokenValues: Record<string, string> = {\n // Colors\n \"--ui-primary\": \"#4f46e5\", // indigo-600\n \"--ui-primary-hover\": \"#4338ca\", // indigo-700\n // Button-specific background/border hooks: default to the flat --ui-primary\n // / --ui-danger tokens above unchanged, so those stay the single source of\n // truth for every other component. Overriding just these lets a theme opt\n // ui-button into a gradient (or any other) background without touching\n // component markup; --ui-button-border/--ui-button-danger-border default\n // to transparent (today's look) and are meant to be paired with a shade\n // darker than the gradient's dark stop when one is set. The `-active`\n // variants default to whatever `-background` already resolved to (so a\n // solid override still applies while pressed) — a gradient theme should\n // set them to the same stops in reverse, for a pressed/\"indented\" look.\n \"--ui-button-background\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-button-background-hover\": \"var(--ui-primary-hover, #4338ca)\",\n \"--ui-button-background-active\": \"var(--ui-button-background, var(--ui-primary, #4f46e5))\",\n \"--ui-button-border\": \"transparent\",\n // The bordered, transparent-background secondary variant's equivalents —\n // shared with confirm-dialog's Cancel button, which is the same visual\n // pattern. Defaults reproduce today's literal secondary styling exactly\n // (no background at any state, border colors matching --ui-border /\n // --ui-text-muted), so a theme only needs to override these to make\n // secondary/Cancel buttons match a primary/danger gradient theme.\n \"--ui-button-secondary-background\": \"none\",\n \"--ui-button-secondary-background-hover\": \"none\",\n \"--ui-button-secondary-background-active\": \"var(--ui-button-secondary-background, none)\",\n \"--ui-button-secondary-border\": \"var(--ui-border, #e2e8f0)\",\n \"--ui-button-secondary-border-hover\": \"var(--ui-text-muted, #64748b)\",\n // A muted-gray surface used wherever something already paints\n // --ui-surface-muted as a state indicator in flat mode — button-group's\n // unchecked-segment hover, pagination-nav's button hover, and\n // radio-cards/radio-pills' checked background — which is a genuinely\n // different default than secondary's borderless flat hover, so it can't\n // reuse --ui-button-secondary-background-hover's \"none\" default.\n \"--ui-button-secondary-surface-muted\": \"var(--ui-surface-muted, #f8fafc)\",\n // Shared by both primary/danger — a purely cosmetic gloss/legibility pair,\n // not color-specific, so one token covers both variants. `-highlight` is a\n // full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for\n // a glossy top edge, defaulting to a fully transparent (so invisible)\n // shadow rather than the keyword `none` — some usages combine it with\n // another literal shadow in a comma-separated list, where a bare `none`\n // item is invalid CSS and would zero out the *whole* declaration.\n // `-text-shadow` is a full text-shadow value for label legibility against\n // a gradient's lighter stop, always used standalone, so it keeps `none`.\n \"--ui-button-highlight\": \"0 0 0 0 transparent\",\n \"--ui-button-text-shadow\": \"none\",\n // A solid stand-in for the same accent, for spots that can't render a\n // background gradient at all — a native <input>'s accent-color only\n // accepts a plain color, and a hard-stop background gradient (e.g.\n // range-slider's filled track) can't nest another gradient inside its own\n // color-stop list. Consumers that theme the buttons into a gradient should\n // set this to the gradient's dark stop, so these non-button accents (radio\n // selection indicators, the range-slider track/thumb) stay visually\n // coordinated with it even though they can't literally paint a gradient.\n \"--ui-button-accent\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-info\": \"#0ea5e9\", // sky-500\n \"--ui-info-hover\": \"#0284c7\", // sky-600\n \"--ui-danger\": \"#dc2626\", // red-600\n \"--ui-danger-hover\": \"#b91c1c\", // red-700\n \"--ui-button-danger-background\": \"var(--ui-danger, #dc2626)\",\n \"--ui-button-danger-background-hover\": \"var(--ui-danger-hover, #b91c1c)\",\n \"--ui-button-danger-background-active\":\n \"var(--ui-button-danger-background, var(--ui-danger, #dc2626))\",\n \"--ui-button-danger-border\": \"transparent\",\n \"--ui-success\": \"#16a34a\", // green-600\n \"--ui-warning\": \"#d97706\", // amber-600\n \"--ui-warning-hover\": \"#b45309\", // amber-700\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#0f172a\", // slate-900\n \"--ui-text-muted\": \"#64748b\", // slate-500\n \"--ui-border\": \"#e2e8f0\", // slate-200\n \"--ui-surface\": \"#ffffff\", // white\n \"--ui-surface-muted\": \"#f8fafc\", // slate-50\n \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash\n \"--ui-tooltip\": \"#0f172a\", // slate-900\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\",\n \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45%\n\n // Shape / depth\n \"--ui-radius\": \"0.5rem\", // rounded-lg\n \"--ui-radius-sm\": \"0.25rem\", // rounded\n \"--ui-shadow\":\n \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md\n \"--ui-shadow-lg\":\n \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl\n \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\",\n\n // Type\n \"--ui-font\":\n 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n \"--ui-font-mono\":\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n \"--ui-font-size-lg\": \"1rem\", // text-base\n \"--ui-font-size\": \"0.875rem\", // text-sm\n \"--ui-font-size-sm\": \"0.75rem\", // text-xs\n \"--ui-font-size-xs\": \"0.6875rem\",\n\n // Font weights — the only four weights the system uses.\n \"--ui-font-weight-regular\": \"400\",\n \"--ui-font-weight-medium\": \"500\",\n \"--ui-font-weight-semibold\": \"600\",\n \"--ui-font-weight-bold\": \"700\",\n\n // Line heights — glyph (icon/marker box), tight (headings), normal (body).\n \"--ui-line-height-glyph\": \"1\",\n \"--ui-line-height-tight\": \"1.25\",\n \"--ui-line-height-normal\": \"1.5\",\n\n // Letter spacing / tracking — default and the single widened step.\n \"--ui-tracking-normal\": \"0\",\n \"--ui-tracking-wide\": \"0.04em\",\n};\n\n/**\n * Dark-mode overrides for the same `--ui-*` custom properties, applied by\n * `tokens.css` via `@media (prefers-color-scheme: dark)` and `[data-theme]`\n * (see generate-tokens-css.mjs). Same Tailwind slate scale as the light\n * palette, inverted, with primary/danger/success lightened one step (500\n * instead of 600) for sufficient contrast against dark surfaces. Shape/type\n * tokens are theme-independent and not repeated here.\n */\nexport const darkTokenValues: Record<string, string> = {\n \"--ui-primary\": \"#6366f1\", // indigo-500\n \"--ui-primary-hover\": \"#818cf8\", // indigo-400\n \"--ui-info\": \"#38bdf8\", // sky-400\n \"--ui-info-hover\": \"#7dd3fc\", // sky-300\n \"--ui-danger\": \"#ef4444\", // red-500\n \"--ui-danger-hover\": \"#f87171\", // red-400\n \"--ui-success\": \"#22c55e\", // green-500\n \"--ui-warning\": \"#f59e0b\", // amber-500\n \"--ui-warning-hover\": \"#fbbf24\", // amber-400\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#f1f5f9\", // slate-100\n \"--ui-text-muted\": \"#94a3b8\", // slate-400\n \"--ui-border\": \"#334155\", // slate-700\n \"--ui-surface\": \"#0f172a\", // slate-900\n \"--ui-surface-muted\": \"#1e293b\", // slate-800\n \"--ui-highlight\": \"#854d0e\", // amber-800 — transient \"just changed\" flash on dark\n \"--ui-tooltip\": \"#020617\", // slate-950\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.12)\",\n \"--ui-overlay\": \"rgb(2 6 23 / 0.6)\", // slate-950 / 60%\n \"--ui-focus-ring\": \"0 0 0 3px rgb(99 102 241 / 0.45)\",\n};\n\n/**\n * \"Gradient\" theme overrides, applied via `data-theme=\"gradient\"` on `<html>`\n * (see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the\n * `\"light\"` override and layers a glossy gradient look on top of the flat\n * light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/\n * `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that\n * file's doc comment). Every other token (`--ui-text`, `--ui-surface`, …)\n * is left at its light-mode default — this theme is button-only by design.\n * Each variant's gradient runs light-to-dark top-to-bottom (`180deg`)\n * across one Tailwind shade step lighter/darker than the flat token so it\n * still reads as \"the same color, glossy\" rather than a different hue;\n * `-hover` shifts the whole pair one shade lighter, `-active` reverses the\n * two stops for a pressed/\"indented\" look, and `-border` is a shade darker\n * than the gradient's dark stop for a defining edge.\n */\nexport const gradientTokenValues: Record<string, string> = {\n \"--ui-button-background\": \"linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)\", // indigo-500 -> 600\n \"--ui-button-background-hover\": \"linear-gradient(180deg, #818cf8 0%, #6366f1 100%)\", // indigo-400 -> 500\n \"--ui-button-background-active\": \"linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)\", // reversed 600 -> 500\n \"--ui-button-border\": \"#4338ca\", // indigo-700\n \"--ui-button-danger-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600\n \"--ui-button-danger-background-hover\": \"linear-gradient(180deg, #f87171 0%, #ef4444 100%)\", // red-400 -> 500\n \"--ui-button-danger-background-active\": \"linear-gradient(180deg, #dc2626 0%, #ef4444 100%)\", // reversed 600 -> 500\n \"--ui-button-danger-border\": \"#b91c1c\", // red-700\n // Secondary stays subtle (white -> slate-50) rather than a saturated hue,\n // matching its flat \"not the primary action\" role, with a slightly\n // stronger border (slate-300 instead of the flat slate-200) so its edge\n // still reads against the near-white gradient fill.\n \"--ui-button-secondary-background\": \"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)\", // white -> slate-50\n \"--ui-button-secondary-background-hover\": \"linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)\", // slate-50 -> 100\n \"--ui-button-secondary-background-active\": \"linear-gradient(180deg, #f1f5f9 0%, #ffffff 100%)\", // reversed 100 -> white\n \"--ui-button-secondary-border\": \"#cbd5e1\", // slate-300\n \"--ui-button-secondary-border-hover\": \"#94a3b8\", // slate-400\n \"--ui-button-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge\n \"--ui-button-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility on primary/danger\n \"--ui-button-accent\": \"#4338ca\", // indigo-700, matches --ui-button-border\n};\n\n/**\n * Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,\n * re-declaring every token on each component's own host element as a\n * \"materialize the inherited value, or this fallback\" trick. That pattern\n * turned out to be a genuine bug, not a working default: browsers treat\n * `--ui-x: var(--ui-x, ...)` on `:host` as a self-referencing declaration\n * that computes to the guaranteed-invalid value REGARDLESS of what an\n * ancestor (e.g. `:root`) set — the host's own `:host` rule wins the cascade\n * over the ancestor's, so this dropped whatever the app actually set and\n * silently substituted the component's own fallback everywhere. It went\n * unnoticed because every component's fallback happened to equal the\n * intended light-mode value — dark mode (a real, different value at\n * `:root`) exposed it immediately (colors rendering as if no theme were\n * applied at all). Fix: don't redeclare tokens on `:host` — plain\n * inheritance already carries `:root`'s values into every shadow root\n * correctly, and every component already has its own `var(--ui-x, fallback)`\n * at each point of use, so nothing here is needed for the \"zero external\n * CSS\" default to keep working. Kept as an empty export so the existing\n * `static override styles = [tokens, css\\`...\\`]` import in every component\n * keeps compiling.\n */\nexport const tokens = css``;\n"]}
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,SAAS;IACT,cAAc,EAAE,SAAS,EAAE,aAAa;IACxC,oBAAoB,EAAE,SAAS,EAAE,aAAa;IAC9C,4EAA4E;IAC5E,2EAA2E;IAC3E,0EAA0E;IAC1E,uEAAuE;IACvE,yEAAyE;IACzE,wEAAwE;IACxE,sEAAsE;IACtE,uEAAuE;IACvE,wEAAwE;IACxE,wEAAwE;IACxE,wBAAwB,EAAE,4BAA4B;IACtD,8BAA8B,EAAE,kCAAkC;IAClE,+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AyE;IACzE,oEAAoE;IACpE,wEAAwE;IACxE,sEAAsE;IACtE,qEAAqE;IACrE,kEAAkE;IAClE,qEAAqE;IACrE,oBAAoB;IACpB,kCAAkC,EAAE,mDAAmD,EAAE,kBAAkB;IAC3G,wCAAwC,EAAE,mDAAmD,EAAE,mBAAmB;IAClH,yCAAyC,EAAE,mDAAmD,EAAE,qBAAqB;IACrH,8BAA8B,EAAE,SAAS,EAAE,YAAY;IACvD,oCAAoC,EAAE,SAAS,EAAE,YAAY;IAC7D,uBAAuB,EAAE,uCAAuC,EAAE,kBAAkB;IACpF,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B;IACzF,oBAAoB,EAAE,SAAS,EAAE,yCAAyC;IAC1E,kEAAkE;IAClE,0EAA0E;IAC1E,0EAA0E;IAC1E,+BAA+B,EAAE,mDAAmD,EAAE,mBAAmB;IACzG,6BAA6B,EAAE,mDAAmD,EAAE,iBAAiB;IACrG,4BAA4B,EAAE,mDAAmD,EAAE,iBAAiB;IACpG,+BAA+B,EAAE,mDAAmD,EAAE,mBAAmB;IACzG,sBAAsB,EAAE,uCAAuC,EAAE,iDAAiD;IAClH,wBAAwB,EAAE,6BAA6B,EAAE,8CAA8C;CACxG,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,EAAE,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Design token values, sourced from Tailwind v4's default theme palette.\n * Each entry maps a `--ui-*` custom property name to its default value.\n * These are the same values baked in as `var(--ui-*, <fallback>)` fallbacks\n * throughout component styles, so components render correctly with zero\n * external CSS. Consumers may override any of these by setting the custom\n * property on `:root` or an ancestor element (see `tokens.css`).\n */\nexport const tokenValues: Record<string, string> = {\n // Colors\n \"--ui-primary\": \"#4f46e5\", // indigo-600\n \"--ui-primary-hover\": \"#4338ca\", // indigo-700\n // Button-specific background/border hooks: default to the flat --ui-primary\n // / --ui-danger tokens above unchanged, so those stay the single source of\n // truth for every other component. Overriding just these lets a theme opt\n // ui-button into a gradient (or any other) background without touching\n // component markup; --ui-button-border/--ui-button-danger-border default\n // to transparent (today's look) and are meant to be paired with a shade\n // darker than the gradient's dark stop when one is set. The `-active`\n // variants default to whatever `-background` already resolved to (so a\n // solid override still applies while pressed) — a gradient theme should\n // set them to the same stops in reverse, for a pressed/\"indented\" look.\n \"--ui-button-background\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-button-background-hover\": \"var(--ui-primary-hover, #4338ca)\",\n \"--ui-button-background-active\": \"var(--ui-button-background, var(--ui-primary, #4f46e5))\",\n \"--ui-button-border\": \"transparent\",\n // The bordered, transparent-background secondary variant's equivalents —\n // shared with confirm-dialog's Cancel button, which is the same visual\n // pattern. Defaults reproduce today's literal secondary styling exactly\n // (no background at any state, border colors matching --ui-border /\n // --ui-text-muted), so a theme only needs to override these to make\n // secondary/Cancel buttons match a primary/danger gradient theme.\n \"--ui-button-secondary-background\": \"none\",\n \"--ui-button-secondary-background-hover\": \"none\",\n \"--ui-button-secondary-background-active\": \"var(--ui-button-secondary-background, none)\",\n \"--ui-button-secondary-border\": \"var(--ui-border, #e2e8f0)\",\n \"--ui-button-secondary-border-hover\": \"var(--ui-text-muted, #64748b)\",\n // A muted-gray surface used wherever something already paints\n // --ui-surface-muted as a state indicator in flat mode — button-group's\n // unchecked-segment hover, pagination-nav's button hover, and\n // radio-cards/radio-pills' checked background — which is a genuinely\n // different default than secondary's borderless flat hover, so it can't\n // reuse --ui-button-secondary-background-hover's \"none\" default.\n \"--ui-button-secondary-surface-muted\": \"var(--ui-surface-muted, #f8fafc)\",\n // Shared by both primary/danger — a purely cosmetic gloss/legibility pair,\n // not color-specific, so one token covers both variants. `-highlight` is a\n // full box-shadow value (e.g. `inset 0 1px 0 rgb(255 255 255 / 0.35)`) for\n // a glossy top edge, defaulting to a fully transparent (so invisible)\n // shadow rather than the keyword `none` — some usages combine it with\n // another literal shadow in a comma-separated list, where a bare `none`\n // item is invalid CSS and would zero out the *whole* declaration.\n // `-text-shadow` is a full text-shadow value for label legibility against\n // a gradient's lighter stop, always used standalone, so it keeps `none`.\n \"--ui-button-highlight\": \"0 0 0 0 transparent\",\n \"--ui-button-text-shadow\": \"none\",\n // A solid stand-in for the same accent, for spots that can't render a\n // background gradient at all — a native <input>'s accent-color only\n // accepts a plain color, and a hard-stop background gradient (e.g.\n // range-slider's filled track) can't nest another gradient inside its own\n // color-stop list. Consumers that theme the buttons into a gradient should\n // set this to the gradient's dark stop, so these non-button accents (radio\n // selection indicators, the range-slider track/thumb) stay visually\n // coordinated with it even though they can't literally paint a gradient.\n \"--ui-button-accent\": \"var(--ui-primary, #4f46e5)\",\n \"--ui-info\": \"#0ea5e9\", // sky-500\n \"--ui-info-hover\": \"#0284c7\", // sky-600\n \"--ui-danger\": \"#dc2626\", // red-600\n \"--ui-danger-hover\": \"#b91c1c\", // red-700\n \"--ui-button-danger-background\": \"var(--ui-danger, #dc2626)\",\n \"--ui-button-danger-background-hover\": \"var(--ui-danger-hover, #b91c1c)\",\n \"--ui-button-danger-background-active\":\n \"var(--ui-button-danger-background, var(--ui-danger, #dc2626))\",\n \"--ui-button-danger-border\": \"transparent\",\n \"--ui-success\": \"#16a34a\", // green-600\n \"--ui-warning\": \"#d97706\", // amber-600\n \"--ui-warning-hover\": \"#b45309\", // amber-700\n // toast-notification's per-variant background hooks: default to the flat\n // --ui-success/--ui-danger/--ui-info/--ui-warning tokens unchanged, so\n // those stay the single source of truth for every other component —\n // the same pattern as --ui-button-background/--ui-button-danger-background\n // above. `-highlight`/`-text-shadow` are the same glossy-top-edge /\n // legibility-shadow pair as --ui-button-highlight/--ui-button-text-shadow,\n // kept as separate tokens so a theme can gloss toasts and buttons\n // independently.\n \"--ui-toast-success-background\": \"var(--ui-success, #16a34a)\",\n \"--ui-toast-error-background\": \"var(--ui-danger, #dc2626)\",\n \"--ui-toast-info-background\": \"var(--ui-info, #0ea5e9)\",\n \"--ui-toast-warning-background\": \"var(--ui-warning, #d97706)\",\n \"--ui-toast-highlight\": \"0 0 0 0 transparent\",\n \"--ui-toast-text-shadow\": \"none\",\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#0f172a\", // slate-900\n \"--ui-text-muted\": \"#64748b\", // slate-500\n \"--ui-border\": \"#e2e8f0\", // slate-200\n \"--ui-surface\": \"#ffffff\", // white\n \"--ui-surface-muted\": \"#f8fafc\", // slate-50\n \"--ui-highlight\": \"#fde68a\", // amber-200 — transient \"just changed\" flash\n \"--ui-tooltip\": \"#0f172a\", // slate-900\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.32)\",\n \"--ui-overlay\": \"rgb(15 23 42 / 0.45)\", // slate-900 / 45%\n\n // Shape / depth\n \"--ui-radius\": \"0.5rem\", // rounded-lg\n \"--ui-radius-sm\": \"0.25rem\", // rounded\n \"--ui-shadow\":\n \"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)\", // shadow-md\n \"--ui-shadow-lg\":\n \"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)\", // shadow-xl\n \"--ui-focus-ring\": \"0 0 0 3px rgb(79 70 229 / 0.35)\",\n\n // Type\n \"--ui-font\":\n 'ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n \"--ui-font-mono\":\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n \"--ui-font-size-lg\": \"1rem\", // text-base\n \"--ui-font-size\": \"0.875rem\", // text-sm\n \"--ui-font-size-sm\": \"0.75rem\", // text-xs\n \"--ui-font-size-xs\": \"0.6875rem\",\n\n // Font weights — the only four weights the system uses.\n \"--ui-font-weight-regular\": \"400\",\n \"--ui-font-weight-medium\": \"500\",\n \"--ui-font-weight-semibold\": \"600\",\n \"--ui-font-weight-bold\": \"700\",\n\n // Line heights — glyph (icon/marker box), tight (headings), normal (body).\n \"--ui-line-height-glyph\": \"1\",\n \"--ui-line-height-tight\": \"1.25\",\n \"--ui-line-height-normal\": \"1.5\",\n\n // Letter spacing / tracking — default and the single widened step.\n \"--ui-tracking-normal\": \"0\",\n \"--ui-tracking-wide\": \"0.04em\",\n};\n\n/**\n * Dark-mode overrides for the same `--ui-*` custom properties, applied by\n * `tokens.css` via `@media (prefers-color-scheme: dark)` and `[data-theme]`\n * (see generate-tokens-css.mjs). Same Tailwind slate scale as the light\n * palette, inverted, with primary/danger/success lightened one step (500\n * instead of 600) for sufficient contrast against dark surfaces. Shape/type\n * tokens are theme-independent and not repeated here.\n */\nexport const darkTokenValues: Record<string, string> = {\n \"--ui-primary\": \"#6366f1\", // indigo-500\n \"--ui-primary-hover\": \"#818cf8\", // indigo-400\n \"--ui-info\": \"#38bdf8\", // sky-400\n \"--ui-info-hover\": \"#7dd3fc\", // sky-300\n \"--ui-danger\": \"#ef4444\", // red-500\n \"--ui-danger-hover\": \"#f87171\", // red-400\n \"--ui-success\": \"#22c55e\", // green-500\n \"--ui-warning\": \"#f59e0b\", // amber-500\n \"--ui-warning-hover\": \"#fbbf24\", // amber-400\n \"--ui-on-accent\": \"#ffffff\",\n \"--ui-text\": \"#f1f5f9\", // slate-100\n \"--ui-text-muted\": \"#94a3b8\", // slate-400\n \"--ui-border\": \"#334155\", // slate-700\n \"--ui-surface\": \"#0f172a\", // slate-900\n \"--ui-surface-muted\": \"#1e293b\", // slate-800\n \"--ui-highlight\": \"#854d0e\", // amber-800 — transient \"just changed\" flash on dark\n \"--ui-tooltip\": \"#020617\", // slate-950\n \"--ui-hover-overlay\": \"rgb(255 255 255 / 0.12)\",\n \"--ui-overlay\": \"rgb(2 6 23 / 0.6)\", // slate-950 / 60%\n \"--ui-focus-ring\": \"0 0 0 3px rgb(99 102 241 / 0.45)\",\n};\n\n/**\n * \"Gradient\" theme overrides, applied via `data-theme=\"gradient\"` on `<html>`\n * (see `generate-tokens-css.mjs`) — forces `color-scheme: light` like the\n * `\"light\"` override and layers a glossy gradient look on top of the flat\n * light palette, using exactly the `--ui-button-*`/`--ui-button-danger-*`/\n * `--ui-button-secondary-*` hooks `ui-button.ts` already reads (see that\n * file's doc comment), plus the `--ui-toast-*` hooks `toast-notification.ts`\n * reads (see its doc comment). Every other token (`--ui-text`, `--ui-surface`,\n * …) is left at its light-mode default — this theme only glosses buttons and\n * toasts by design. Each variant's gradient runs light-to-dark top-to-bottom\n * (`180deg`) across one Tailwind shade step lighter/darker than the flat\n * token so it still reads as \"the same color, glossy\" rather than a\n * different hue; `-hover` shifts the whole pair one shade lighter, `-active`\n * reverses the two stops for a pressed/\"indented\" look, and `-border` is a\n * shade darker than the gradient's dark stop for a defining edge.\n */\nexport const gradientTokenValues: Record<string, string> = {\n \"--ui-button-background\": \"linear-gradient(180deg, #6366f1 0%, #4f46e5 100%)\", // indigo-500 -> 600\n \"--ui-button-background-hover\": \"linear-gradient(180deg, #818cf8 0%, #6366f1 100%)\", // indigo-400 -> 500\n \"--ui-button-background-active\": \"linear-gradient(180deg, #4f46e5 0%, #6366f1 100%)\", // reversed 600 -> 500\n \"--ui-button-border\": \"#4338ca\", // indigo-700\n \"--ui-button-danger-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600\n \"--ui-button-danger-background-hover\": \"linear-gradient(180deg, #f87171 0%, #ef4444 100%)\", // red-400 -> 500\n \"--ui-button-danger-background-active\": \"linear-gradient(180deg, #dc2626 0%, #ef4444 100%)\", // reversed 600 -> 500\n \"--ui-button-danger-border\": \"#b91c1c\", // red-700\n // Secondary stays neutral gray rather than a saturated hue, matching its\n // flat \"not the primary action\" role, but one shade darker than the\n // original white -> slate-50 pairing: at a small button size, that pair\n // read as flat white with no visible gradient at all. slate-50 -> 100\n // keeps enough contrast to actually look like a gradient while still\n // being clearly lighter/quieter than primary/danger. Border stays\n // slate-300 (a step past the flat slate-200) so its edge still reads\n // against the fill.\n \"--ui-button-secondary-background\": \"linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%)\", // slate-50 -> 100\n \"--ui-button-secondary-background-hover\": \"linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%)\", // slate-100 -> 200\n \"--ui-button-secondary-background-active\": \"linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%)\", // reversed 100 -> 50\n \"--ui-button-secondary-border\": \"#cbd5e1\", // slate-300\n \"--ui-button-secondary-border-hover\": \"#94a3b8\", // slate-400\n \"--ui-button-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge\n \"--ui-button-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility on primary/danger\n \"--ui-button-accent\": \"#4338ca\", // indigo-700, matches --ui-button-border\n // toast-notification: same light-to-dark, one-shade-step gradient\n // convention as the button variants above; the bottom stop always matches\n // the flat --ui-success/--ui-danger/--ui-info/--ui-warning value exactly.\n \"--ui-toast-success-background\": \"linear-gradient(180deg, #22c55e 0%, #16a34a 100%)\", // green-500 -> 600\n \"--ui-toast-error-background\": \"linear-gradient(180deg, #ef4444 0%, #dc2626 100%)\", // red-500 -> 600\n \"--ui-toast-info-background\": \"linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%)\", // sky-400 -> 500\n \"--ui-toast-warning-background\": \"linear-gradient(180deg, #f59e0b 0%, #d97706 100%)\", // amber-500 -> 600\n \"--ui-toast-highlight\": \"inset 0 1px 0 rgb(255 255 255 / 0.35)\", // glossy top edge, same as --ui-button-highlight\n \"--ui-toast-text-shadow\": \"0 1px 1px rgb(0 0 0 / 0.25)\", // legibility, same as --ui-button-text-shadow\n};\n\n/**\n * Historically a shared `:host { --ui-x: var(--ui-x, fallback); } ` block,\n * re-declaring every token on each component's own host element as a\n * \"materialize the inherited value, or this fallback\" trick. That pattern\n * turned out to be a genuine bug, not a working default: browsers treat\n * `--ui-x: var(--ui-x, ...)` on `:host` as a self-referencing declaration\n * that computes to the guaranteed-invalid value REGARDLESS of what an\n * ancestor (e.g. `:root`) set — the host's own `:host` rule wins the cascade\n * over the ancestor's, so this dropped whatever the app actually set and\n * silently substituted the component's own fallback everywhere. It went\n * unnoticed because every component's fallback happened to equal the\n * intended light-mode value — dark mode (a real, different value at\n * `:root`) exposed it immediately (colors rendering as if no theme were\n * applied at all). Fix: don't redeclare tokens on `:host` — plain\n * inheritance already carries `:root`'s values into every shadow root\n * correctly, and every component already has its own `var(--ui-x, fallback)`\n * at each point of use, so nothing here is needed for the \"zero external\n * CSS\" default to keep working. Kept as an empty export so the existing\n * `static override styles = [tokens, css\\`...\\`]` import in every component\n * keeps compiling.\n */\nexport const tokens = css``;\n"]}
|
package/docs/comment-composer.md
CHANGED
|
@@ -9,7 +9,11 @@ persistent value in place (see `editable-text` for that). Canceling (the
|
|
|
9
9
|
Cancel button or `Escape`) discards the draft and collapses without
|
|
10
10
|
firing `submit`. Clicking away (blur) does neither — the composer stays
|
|
11
11
|
expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`
|
|
12
|
-
submits from the textarea, matching `editable-text`'s multiline shortcut
|
|
12
|
+
submits from the textarea, matching `editable-text`'s multiline shortcut —
|
|
13
|
+
the Submit button always shows a `kbd-hint` for it, so the shortcut is
|
|
14
|
+
discoverable rather than a hidden power-user feature. Calling the standard
|
|
15
|
+
`.focus()` method expands the composer (if collapsed) and focuses its
|
|
16
|
+
field, for an ancestor that wants to drive it programmatically.
|
|
13
17
|
Purely token-styled (no bespoke colors), so it's themeable via the same
|
|
14
18
|
`--ui-*` custom properties as every other value-entry field.
|
|
15
19
|
|
|
@@ -14,6 +14,20 @@ circle, info → information circle, warning → exclamation triangle). Each toa
|
|
|
14
14
|
auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
15
15
|
button. Appears/disappears instantly — no slide/fade transitions.
|
|
16
16
|
|
|
17
|
+
Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
18
|
+
(`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
19
|
+
`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
20
|
+
so those stay the single source of truth for every other component. A
|
|
21
|
+
consumer can override just these toast-specific tokens with a
|
|
22
|
+
`linear-gradient(...)` to opt every toast into a gradient look without
|
|
23
|
+
touching component markup — `gradientTokenValues` in `tokens.ts` ships
|
|
24
|
+
exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
|
|
25
|
+
"Gradient theme" section), the same mechanism `ui-button` uses.
|
|
26
|
+
`--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
|
|
27
|
+
existing elevation shadow) and `--ui-toast-text-shadow` (legibility
|
|
28
|
+
against the gradient's lighter stop) round out the effect, mirroring
|
|
29
|
+
`ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
|
|
30
|
+
|
|
17
31
|
## Install
|
|
18
32
|
|
|
19
33
|
```js
|
|
@@ -46,6 +60,8 @@ _None._
|
|
|
46
60
|
|
|
47
61
|
| Custom property |
|
|
48
62
|
| --- |
|
|
63
|
+
| `--ui-button-highlight` |
|
|
64
|
+
| `--ui-button-text-shadow` |
|
|
49
65
|
| `--ui-danger` |
|
|
50
66
|
| `--ui-focus-ring` |
|
|
51
67
|
| `--ui-font` |
|
|
@@ -63,4 +79,11 @@ _None._
|
|
|
63
79
|
| `--ui-shadow-lg` |
|
|
64
80
|
| `--ui-success` |
|
|
65
81
|
| `--ui-text` |
|
|
82
|
+
| `--ui-toast-` |
|
|
83
|
+
| `--ui-toast-error-background` |
|
|
84
|
+
| `--ui-toast-highlight` |
|
|
85
|
+
| `--ui-toast-info-background` |
|
|
86
|
+
| `--ui-toast-success-background` |
|
|
87
|
+
| `--ui-toast-text-shadow` |
|
|
88
|
+
| `--ui-toast-warning-background` |
|
|
66
89
|
| `--ui-warning` |
|
package/llms.txt
CHANGED
|
@@ -543,7 +543,11 @@ persistent value in place (see `editable-text` for that). Canceling (the
|
|
|
543
543
|
Cancel button or `Escape`) discards the draft and collapses without
|
|
544
544
|
firing `submit`. Clicking away (blur) does neither — the composer stays
|
|
545
545
|
expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`
|
|
546
|
-
submits from the textarea, matching `editable-text`'s multiline shortcut
|
|
546
|
+
submits from the textarea, matching `editable-text`'s multiline shortcut —
|
|
547
|
+
the Submit button always shows a `kbd-hint` for it, so the shortcut is
|
|
548
|
+
discoverable rather than a hidden power-user feature. Calling the standard
|
|
549
|
+
`.focus()` method expands the composer (if collapsed) and focuses its
|
|
550
|
+
field, for an ancestor that wants to drive it programmatically.
|
|
547
551
|
Purely token-styled (no bespoke colors), so it's themeable via the same
|
|
548
552
|
`--ui-*` custom properties as every other value-entry field.
|
|
549
553
|
|
|
@@ -2127,11 +2131,25 @@ circle, info → information circle, warning → exclamation triangle). Each toa
|
|
|
2127
2131
|
auto-dismisses after `duration` ms and can also be dismissed via its ✕
|
|
2128
2132
|
button. Appears/disappears instantly — no slide/fade transitions.
|
|
2129
2133
|
|
|
2134
|
+
Each variant's background reads a dedicated `--ui-toast-*-background` hook
|
|
2135
|
+
(`success`/`error`/`info`/`warning`), which defaults to the flat
|
|
2136
|
+
`--ui-success`/`--ui-danger`/`--ui-info`/`--ui-warning` tokens unchanged —
|
|
2137
|
+
so those stay the single source of truth for every other component. A
|
|
2138
|
+
consumer can override just these toast-specific tokens with a
|
|
2139
|
+
`linear-gradient(...)` to opt every toast into a gradient look without
|
|
2140
|
+
touching component markup — `gradientTokenValues` in `tokens.ts` ships
|
|
2141
|
+
exactly this, wired up via `data-theme="gradient"` (see `tokens.css`'s
|
|
2142
|
+
"Gradient theme" section), the same mechanism `ui-button` uses.
|
|
2143
|
+
`--ui-toast-highlight` (a glossy top-edge box-shadow, layered onto the
|
|
2144
|
+
existing elevation shadow) and `--ui-toast-text-shadow` (legibility
|
|
2145
|
+
against the gradient's lighter stop) round out the effect, mirroring
|
|
2146
|
+
`ui-button`'s `--ui-button-highlight`/`--ui-button-text-shadow`.
|
|
2147
|
+
|
|
2130
2148
|
Import: `import "@f-ewald/components/toast-notification.js";`
|
|
2131
2149
|
|
|
2132
2150
|
Properties: none
|
|
2133
2151
|
Events: none
|
|
2134
|
-
CSS custom properties: `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size`, `--ui-font-size-sm`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-hover-overlay`, `--ui-info`, `--ui-line-height-glyph`, `--ui-line-height-normal`, `--ui-on-accent`, `--ui-radius`, `--ui-radius-sm`, `--ui-shadow-lg`, `--ui-success`, `--ui-text`, `--ui-warning`
|
|
2152
|
+
CSS custom properties: `--ui-button-highlight`, `--ui-button-text-shadow`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size`, `--ui-font-size-sm`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-hover-overlay`, `--ui-info`, `--ui-line-height-glyph`, `--ui-line-height-normal`, `--ui-on-accent`, `--ui-radius`, `--ui-radius-sm`, `--ui-shadow-lg`, `--ui-success`, `--ui-text`, `--ui-toast-`, `--ui-toast-error-background`, `--ui-toast-highlight`, `--ui-toast-info-background`, `--ui-toast-success-background`, `--ui-toast-text-shadow`, `--ui-toast-warning-background`, `--ui-warning`
|
|
2135
2153
|
|
|
2136
2154
|
Example:
|
|
2137
2155
|
```html
|