@f-ewald/components 1.27.3 → 1.29.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.
Files changed (64) hide show
  1. package/README.md +2 -0
  2. package/custom-elements.json +460 -9
  3. package/dist/fullscreen-button.d.ts +43 -0
  4. package/dist/fullscreen-button.d.ts.map +1 -0
  5. package/dist/fullscreen-button.js +172 -0
  6. package/dist/fullscreen-button.js.map +1 -0
  7. package/dist/icons.d.ts +1 -1
  8. package/dist/icons.d.ts.map +1 -1
  9. package/dist/icons.js +1 -1
  10. package/dist/icons.js.map +1 -1
  11. package/dist/index.d.ts +3 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/percent-bar-chart.d.ts.map +1 -1
  16. package/dist/percent-bar-chart.js +9 -2
  17. package/dist/percent-bar-chart.js.map +1 -1
  18. package/dist/radio-cards.d.ts +5 -1
  19. package/dist/radio-cards.d.ts.map +1 -1
  20. package/dist/radio-cards.js +19 -2
  21. package/dist/radio-cards.js.map +1 -1
  22. package/dist/scroll-dots.d.ts +54 -0
  23. package/dist/scroll-dots.d.ts.map +1 -0
  24. package/dist/scroll-dots.js +178 -0
  25. package/dist/scroll-dots.js.map +1 -0
  26. package/dist/scroll-to-bottom.d.ts +6 -0
  27. package/dist/scroll-to-bottom.d.ts.map +1 -1
  28. package/dist/scroll-to-bottom.js +31 -7
  29. package/dist/scroll-to-bottom.js.map +1 -1
  30. package/dist/scroll-to-top.d.ts +6 -0
  31. package/dist/scroll-to-top.d.ts.map +1 -1
  32. package/dist/scroll-to-top.js +31 -7
  33. package/dist/scroll-to-top.js.map +1 -1
  34. package/dist/timeline-container.d.ts +21 -5
  35. package/dist/timeline-container.d.ts.map +1 -1
  36. package/dist/timeline-container.js +35 -7
  37. package/dist/timeline-container.js.map +1 -1
  38. package/dist/timeline-entry.d.ts +32 -0
  39. package/dist/timeline-entry.d.ts.map +1 -1
  40. package/dist/timeline-entry.js +130 -3
  41. package/dist/timeline-entry.js.map +1 -1
  42. package/dist/tokens.css +4 -0
  43. package/dist/tokens.d.ts.map +1 -1
  44. package/dist/tokens.js +11 -0
  45. package/dist/tokens.js.map +1 -1
  46. package/dist/ui-button.d.ts +24 -0
  47. package/dist/ui-button.d.ts.map +1 -1
  48. package/dist/ui-button.js +122 -1
  49. package/dist/ui-button.js.map +1 -1
  50. package/dist/weight-bar-chart.js +2 -2
  51. package/dist/weight-bar-chart.js.map +1 -1
  52. package/docs/design-language.md +19 -0
  53. package/docs/fullscreen-button.md +70 -0
  54. package/docs/icons.md +1 -1
  55. package/docs/radio-cards.md +6 -1
  56. package/docs/scroll-dots.md +65 -0
  57. package/docs/scroll-to-bottom.md +15 -0
  58. package/docs/scroll-to-top.md +15 -0
  59. package/docs/timeline-container.md +30 -6
  60. package/docs/timeline-entry.md +18 -0
  61. package/docs/ui-button.md +28 -0
  62. package/docs/weight-bar-chart.md +1 -0
  63. package/llms.txt +159 -16
  64. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-bottom.js","sourceRoot":"","sources":["../src/scroll-to-bottom.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAgFL,0EAA0E;QAC1C,WAAM,GAAuB,IAAI,CAAC;QAClE,sEAAsE;QAC1C,cAAS,GAAG,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esContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronDown } from \"./icons.js\";\nimport { distanceFromBottom, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the bottom edge, and\n * scrolls back to the bottom on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * @element scroll-to-bottom\n * @fires scroll-to-bottom-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-bottom\")\nexport class ScrollToBottom extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0 0.75rem;\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: 999px;\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n cursor: pointer;\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-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n }\n button:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the bottom before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to bottom\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromBottom(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-bottom-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"bottom\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronDown(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-bottom\": ScrollToBottom;\n }\n}\n"]}
1
+ {"version":3,"file":"scroll-to-bottom.js","sourceRoot":"","sources":["../src/scroll-to-bottom.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAkGL,0EAA0E;QAC1C,WAAM,GAAuB,IAAI,CAAC;QAClE,sEAAsE;QAC1C,cAAS,GAAG,GAAG,CAAC;QAC5C,oDAAoD;QACxC,UAAK,GAAG,kBAAkB,CAAC;QAEtB,aAAQ,GAAG,KAAK,CAAC;QAElC,gBAAW,GAAgC,IAAI,CAAC;QAwChD,cAAS,GAAG,GAAS,EAAE;YACrB,IAAI,CAAC,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;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AC/E,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,YAAY;QACV,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,SAAS,CAEP;IAEF,QAAQ;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QACrC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACrG,CAAC;QACF,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;qCACsB,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;UAChD,eAAe,CAAC,EAAE,CAAC;gBACb,IAAI,CAAC,KAAK;;KAErB,CAAC;IACJ,CAAC;CACF,CAAA;AApEiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8CAAmC;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAiB;AAEhC;IAAX,QAAQ,EAAE;6CAA4B;AAEtB;IAAhB,KAAK,EAAE;gDAA0B;AAzGvB,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAuK1B","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronDown } from \"./icons.js\";\nimport { distanceFromBottom, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the bottom edge, and\n * scrolls back to the bottom on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * The control is styled as a standard secondary button (ui-button's\n * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the\n * `--ui-button-secondary-*` background/border tokens, so a gradient theme\n * carries over) rather than a pill, layered over an opaque `--ui-surface`\n * base and an elevation shadow, since it floats above scrolled content.\n *\n * @element scroll-to-bottom\n * @fires scroll-to-bottom-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-bottom\")\nexport class ScrollToBottom extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n color: var(--ui-text, #0f172a);\n /* ui-button's secondary variant, over an opaque --ui-surface base: a\n floating control can't let scrolled content show through the way a\n secondary button's transparent flat background does. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow:\n var(--ui-button-highlight, 0 0 0 0 transparent),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n cursor: pointer;\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-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n }\n button:hover {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface-muted, #f8fafc);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n button:active {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface-muted, #f8fafc);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n button:focus-visible {\n outline: none;\n box-shadow:\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the bottom before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to bottom\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromBottom(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-bottom-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"bottom\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronDown(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-bottom\": ScrollToBottom;\n }\n}\n"]}
@@ -13,6 +13,12 @@ import { LitElement, type PropertyValues } from "lit";
13
13
  * own visible corner as its content scrolls, rather than floating over the
14
14
  * whole page.
15
15
  *
16
+ * The control is styled as a standard secondary button (ui-button's
17
+ * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the
18
+ * `--ui-button-secondary-*` background/border tokens, so a gradient theme
19
+ * carries over) rather than a pill, layered over an opaque `--ui-surface`
20
+ * base and an elevation shadow, since it floats above scrolled content.
21
+ *
16
22
  * @element scroll-to-top
17
23
  * @fires scroll-to-top-triggered - The button was clicked, just before
18
24
  * scrolling; detail: `{ target }`.
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-top.d.ts","sourceR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,OAAO,EAAE,cAAc,GAAG,IAAI,CAExD;IA0BQ,MAAM,yCAOd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF"}
@@ -23,6 +23,12 @@ import { tokens } from "./tokens.js";
23
23
  * own visible corner as its content scrolls, rather than floating over the
24
24
  * whole page.
25
25
  *
26
+ * The control is styled as a standard secondary button (ui-button's
27
+ * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the
28
+ * `--ui-button-secondary-*` background/border tokens, so a gradient theme
29
+ * carries over) rather than a pill, layered over an opaque `--ui-surface`
30
+ * base and an elevation shadow, since it floats above scrolled content.
31
+ *
26
32
  * @element scroll-to-top
27
33
  * @fires scroll-to-top-triggered - The button was clicked, just before
28
34
  * scrolling; detail: `{ target }`.
@@ -74,12 +80,19 @@ let ScrollToTop = class ScrollToTop extends LitElement {
74
80
  gap: 0.25rem;
75
81
  height: 2rem;
76
82
  box-sizing: border-box;
77
- padding: 0 0.75rem;
83
+ padding: 0.5rem 1rem;
78
84
  color: var(--ui-text, #0f172a);
79
- background: var(--ui-surface, #ffffff);
80
- border: 1px solid var(--ui-border, #e2e8f0);
81
- border-radius: 999px;
82
- box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
85
+ /* ui-button's secondary variant, over an opaque --ui-surface base: a
86
+ floating control can't let scrolled content show through the way a
87
+ secondary button's transparent flat background does. */
88
+ background:
89
+ var(--ui-button-secondary-background, none),
90
+ var(--ui-surface, #ffffff);
91
+ border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
92
+ border-radius: var(--ui-radius-sm, 0.25rem);
93
+ box-shadow:
94
+ var(--ui-button-highlight, 0 0 0 0 transparent),
95
+ var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
83
96
  cursor: pointer;
84
97
  font-family: var(
85
98
  --ui-font,
@@ -97,11 +110,22 @@ let ScrollToTop = class ScrollToTop extends LitElement {
97
110
  white-space: nowrap;
98
111
  }
99
112
  button:hover {
100
- background: var(--ui-surface-muted, #f8fafc);
113
+ background:
114
+ var(--ui-button-secondary-background-hover, none),
115
+ var(--ui-surface-muted, #f8fafc);
116
+ border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
117
+ }
118
+ button:active {
119
+ background:
120
+ var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),
121
+ var(--ui-surface-muted, #f8fafc);
122
+ box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
101
123
  }
102
124
  button:focus-visible {
103
125
  outline: none;
104
- box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
126
+ box-shadow:
127
+ var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)),
128
+ var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
105
129
  }
106
130
  @media (prefers-reduced-motion: reduce) {
107
131
  :host {
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-top.js","sourceRoot":"","sources":["../src/scroll-to-top.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAA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AAK,EAAE;6CAA0B;AAvFvB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAqJvB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronUp } from \"./icons.js\";\nimport { distanceFromTop, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the top edge, and\n * scrolls back to the top on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * @element scroll-to-top\n * @fires scroll-to-top-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-top\")\nexport class ScrollToTop extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0 0.75rem;\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: 999px;\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n cursor: pointer;\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-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n }\n button:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the top before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to top\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromTop(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-top-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"top\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronUp(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-top\": ScrollToTop;\n }\n}\n"]}
1
+ {"version":3,"file":"scroll-to-top.js","sourceRoot":"","sources":["../src/scroll-to-top.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAkGL,0EAA0E;QAC1C,WAAM,GAAuB,IAAI,CAAC;QAClE,mEAAmE;QACvC,cAAS,GAAG,GAAG,CAAC;QAC5C,oDAAoD;QACxC,UAAK,GAAG,eAAe,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QAElC,gBAAW,GAAgC,IAAI,CAAC;QAwChD,cAAS,GAAG,GAAS,EAAE;YACrB,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,IA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E,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/E,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,YAAY;QACV,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,SAAS,CAEP;IAEF,QAAQ;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QACrC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAClG,CAAC;QACF,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;qCACsB,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;UAChD,aAAa,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK;;KAErB,CAAC;IACJ,CAAC;CACF,CAAA;AApEiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAmC;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAiB;AAEhC;IAAX,QAAQ,EAAE;0CAAyB;AAEnB;IAAhB,KAAK,EAAE;6CAA0B;AAzGvB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAuKvB","sourcesContent":["import { LitElement, css, html, type PropertyValues } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronUp } from \"./icons.js\";\nimport { distanceFromTop, scrollToEdge } from \"./utils/scroll.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Overlay button that appears once the page (or a given `target` container)\n * has scrolled more than `threshold` pixels away from the top edge, and\n * scrolls back to the top on click.\n *\n * With no `target` (default), the button is `position: fixed` to the\n * viewport. When `target` is set, the button switches to `position:\n * absolute` and expects to be placed as a descendant of a `position:\n * relative` (or otherwise positioned) ancestor that establishes the visual\n * bounds to float within — typically `target` itself, given `overflow-y:\n * auto; position: relative`, so the button stays pinned to that container's\n * own visible corner as its content scrolls, rather than floating over the\n * whole page.\n *\n * The control is styled as a standard secondary button (ui-button's\n * `secondary` variant: 2rem tall, `--ui-radius-sm` corners, the\n * `--ui-button-secondary-*` background/border tokens, so a gradient theme\n * carries over) rather than a pill, layered over an opaque `--ui-surface`\n * base and an elevation shadow, since it floats above scrolled content.\n *\n * @element scroll-to-top\n * @fires scroll-to-top-triggered - The button was clicked, just before\n * scrolling; detail: `{ target }`.\n */\n@customElement(\"scroll-to-top\")\nexport class ScrollToTop extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n position: fixed;\n bottom: 0.75rem;\n right: 0.75rem;\n z-index: 40;\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n transition:\n opacity 150ms ease,\n visibility 0s linear 150ms;\n }\n :host([contained]) {\n position: absolute;\n }\n :host([visible]) {\n opacity: 1;\n visibility: visible;\n transition:\n opacity 150ms ease,\n visibility 0s linear 0s;\n }\n button {\n pointer-events: auto;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 1rem;\n color: var(--ui-text, #0f172a);\n /* ui-button's secondary variant, over an opaque --ui-surface base: a\n floating control can't let scrolled content show through the way a\n secondary button's transparent flat background does. */\n background:\n var(--ui-button-secondary-background, none),\n var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow:\n var(--ui-button-highlight, 0 0 0 0 transparent),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n cursor: pointer;\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-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n }\n button:hover {\n background:\n var(--ui-button-secondary-background-hover, none),\n var(--ui-surface-muted, #f8fafc);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n button:active {\n background:\n var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none)),\n var(--ui-surface-muted, #f8fafc);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n button:focus-visible {\n outline: none;\n box-shadow:\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)),\n var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n transition: none;\n }\n :host([visible]) {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Scrollable container to control; `null` (default) scrolls `window`. */\n @property({ attribute: false }) target: HTMLElement | null = null;\n /** Pixels scrolled away from the top before the button appears. */\n @property({ type: Number }) threshold = 200;\n /** Visible button text, and its accessible name. */\n @property() label = \"Scroll to top\";\n\n @state() private _visible = false;\n\n #listenedTo: HTMLElement | Window | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has(\"target\")) {\n this.toggleAttribute(\"contained\", this.target !== null);\n // Resubscribing here (not in `updated()`) lets `#onScroll()`'s\n // `_visible` write fold into the update already in progress instead of\n // scheduling a new one. Guarded against the initial update, where\n // `target` is always in `changed` too, but `connectedCallback` already\n // subscribed to it.\n if (this.#listenedTo !== (this.target ?? window)) this.#subscribe();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"_visible\")) this.toggleAttribute(\"visible\", this._visible);\n }\n\n #subscribe(): void {\n this.#unsubscribe();\n this.#listenedTo = this.target ?? window;\n this.#listenedTo.addEventListener(\"scroll\", this.#onScroll, { passive: true });\n this.#onScroll();\n }\n\n #unsubscribe(): void {\n this.#listenedTo?.removeEventListener(\"scroll\", this.#onScroll);\n this.#listenedTo = null;\n }\n\n #onScroll = (): void => {\n this._visible = distanceFromTop(this.target ?? window) > this.threshold;\n };\n\n #onClick(): void {\n const target = this.target ?? window;\n this.dispatchEvent(\n new CustomEvent(\"scroll-to-top-triggered\", { detail: { target }, bubbles: true, composed: true }),\n );\n scrollToEdge(target, \"top\");\n }\n\n override render() {\n return html`\n <button type=\"button\" @click=${() => this.#onClick()}>\n ${iconChevronUp(14)}\n <span>${this.label}</span>\n </button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-to-top\": ScrollToTop;\n }\n}\n"]}
@@ -1,17 +1,33 @@
1
1
  import { LitElement } from "lit";
2
+ /** How a `timeline-container` arranges its entries. */
3
+ export type TimelineLayout = "left" | "alternating";
2
4
  /**
3
- * Vertical timeline: a single connecting line runs down the left edge and each
4
- * slotted `timeline-entry` places a dot on it. This is a thin layout and
5
- * semantics wrapper — the entries draw the line segments and dots themselves,
6
- * so the container adds no gap between them (a gap would break the line).
7
- * Exposed to assistive technology as a list of events.
5
+ * Vertical timeline: a connecting line runs down the entries and each slotted
6
+ * `timeline-entry` places a dot on it. This is a thin layout and semantics
7
+ * wrapper — the entries draw the line segments and dots themselves, so the
8
+ * container adds no gap between them (a gap would break the line). Exposed to
9
+ * assistive technology as a list of events.
10
+ *
11
+ * `layout` chooses where the line runs. `left` (the default) puts it down the
12
+ * left edge with each entry's label inline beside its headline. `alternating`
13
+ * centers it and gives each entry three columns — label, line, body — with the
14
+ * two sides swapping on every second entry, for a presentation timeline rather
15
+ * than an event log.
16
+ *
17
+ * The layout is pushed onto each entry rather than read from here, because a
18
+ * shadow-DOM child cannot style itself against an ancestor portably —
19
+ * `:host-context()` is Chromium-only.
8
20
  *
9
21
  * @element timeline-container
10
22
  * @slot - `timeline-entry` elements, in chronological order.
11
23
  */
12
24
  export declare class TimelineContainer extends LitElement {
25
+ #private;
26
+ /** Arrangement of the entries: a left-edge line, or a centered alternating one. */
27
+ layout: TimelineLayout;
13
28
  static styles: import("lit").CSSResult[];
14
29
  connectedCallback(): void;
30
+ protected updated(): void;
15
31
  render(): import("lit-html").TemplateResult<1>;
16
32
  }
17
33
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-container.d.ts","sourceRoot":"","sources":["../src/timeline-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C;;;;;;;;;GASG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IAC/C,OAAgB,MAAM,4BAOpB;IAEO,iBAAiB,IAAI,IAAI,CAGjC;IAEQ,MAAM,yCAEd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,iBAAiB,CAAC;KACzC;CACF"}
1
+ {"version":3,"file":"timeline-container.d.ts","sourceRoot":"","sources":["../src/timeline-container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,iBAAkB,SAAQ,UAAU;;IAC/C,mFAAmF;IACtD,MAAM,EAAE,cAAc,CAAU;IAE7D,OAAgB,MAAM,4BAOpB;IAEO,iBAAiB,IAAI,IAAI,CAGjC;IAED,UAAmB,OAAO,IAAI,IAAI,CAEjC;IAUQ,MAAM,yCAEd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,iBAAiB,CAAC;KACzC;CACF"}
@@ -5,19 +5,34 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { LitElement, css, html } from "lit";
8
- import { customElement } from "lit/decorators.js";
8
+ import { customElement, property } from "lit/decorators.js";
9
9
  import { tokens } from "./tokens.js";
10
10
  /**
11
- * Vertical timeline: a single connecting line runs down the left edge and each
12
- * slotted `timeline-entry` places a dot on it. This is a thin layout and
13
- * semantics wrapper — the entries draw the line segments and dots themselves,
14
- * so the container adds no gap between them (a gap would break the line).
15
- * Exposed to assistive technology as a list of events.
11
+ * Vertical timeline: a connecting line runs down the entries and each slotted
12
+ * `timeline-entry` places a dot on it. This is a thin layout and semantics
13
+ * wrapper — the entries draw the line segments and dots themselves, so the
14
+ * container adds no gap between them (a gap would break the line). Exposed to
15
+ * assistive technology as a list of events.
16
+ *
17
+ * `layout` chooses where the line runs. `left` (the default) puts it down the
18
+ * left edge with each entry's label inline beside its headline. `alternating`
19
+ * centers it and gives each entry three columns — label, line, body — with the
20
+ * two sides swapping on every second entry, for a presentation timeline rather
21
+ * than an event log.
22
+ *
23
+ * The layout is pushed onto each entry rather than read from here, because a
24
+ * shadow-DOM child cannot style itself against an ancestor portably —
25
+ * `:host-context()` is Chromium-only.
16
26
  *
17
27
  * @element timeline-container
18
28
  * @slot - `timeline-entry` elements, in chronological order.
19
29
  */
20
30
  let TimelineContainer = class TimelineContainer extends LitElement {
31
+ constructor() {
32
+ super(...arguments);
33
+ /** Arrangement of the entries: a left-edge line, or a centered alternating one. */
34
+ this.layout = "left";
35
+ }
21
36
  static { this.styles = [
22
37
  tokens,
23
38
  css `
@@ -31,10 +46,23 @@ let TimelineContainer = class TimelineContainer extends LitElement {
31
46
  if (!this.hasAttribute("role"))
32
47
  this.setAttribute("role", "list");
33
48
  }
49
+ updated() {
50
+ this.#applyLayout();
51
+ }
52
+ /** Mirrors `layout` onto every slotted entry so each can style itself. */
53
+ #applyLayout() {
54
+ const alternating = this.layout === "alternating";
55
+ for (const entry of this.querySelectorAll("timeline-entry")) {
56
+ entry.alternating = alternating;
57
+ }
58
+ }
34
59
  render() {
35
- return html `<slot></slot>`;
60
+ return html `<slot @slotchange=${this.#applyLayout}></slot>`;
36
61
  }
37
62
  };
63
+ __decorate([
64
+ property({ reflect: true })
65
+ ], TimelineContainer.prototype, "layout", void 0);
38
66
  TimelineContainer = __decorate([
39
67
  customElement("timeline-container")
40
68
  ], TimelineContainer);
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-container.js","sourceRoot":"","sources":["../src/timeline-container.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;GASG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;aAC/B,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;KAIF;KACF,AAPqB,CAOpB;IAEO,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;CACF,CAAA;AAlBY,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CAkB7B","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Vertical timeline: a single connecting line runs down the left edge and each\n * slotted `timeline-entry` places a dot on it. This is a thin layout and\n * semantics wrapper — the entries draw the line segments and dots themselves,\n * so the container adds no gap between them (a gap would break the line).\n * Exposed to assistive technology as a list of events.\n *\n * @element timeline-container\n * @slot - `timeline-entry` elements, in chronological order.\n */\n@customElement(\"timeline-container\")\nexport class TimelineContainer extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n `,\n ];\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"role\")) this.setAttribute(\"role\", \"list\");\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"timeline-container\": TimelineContainer;\n }\n}\n"]}
1
+ {"version":3,"file":"timeline-container.js","sourceRoot":"","sources":["../src/timeline-container.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QACL,mFAAmF;QACtD,WAAM,GAAmB,MAAM,CAAC;IA+B/D,CAAC;aA7BiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;KAIF;KACF,AAPqB,CAOpB;IAEO,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IAEkB,OAAO;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,0EAA0E;IAC1E,YAAY;QACV,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC;QAClD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAgB,gBAAgB,CAAC,EAAE,CAAC;YAC3E,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QAClC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,qBAAqB,IAAI,CAAC,YAAY,UAAU,CAAC;IAC9D,CAAC;CACF,CAAA;AA/B8B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAiC;AAFlD,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CAiC7B","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport type { TimelineEntry } from \"./timeline-entry.js\";\n\n/** How a `timeline-container` arranges its entries. */\nexport type TimelineLayout = \"left\" | \"alternating\";\n\n/**\n * Vertical timeline: a connecting line runs down the entries and each slotted\n * `timeline-entry` places a dot on it. This is a thin layout and semantics\n * wrapper — the entries draw the line segments and dots themselves, so the\n * container adds no gap between them (a gap would break the line). Exposed to\n * assistive technology as a list of events.\n *\n * `layout` chooses where the line runs. `left` (the default) puts it down the\n * left edge with each entry's label inline beside its headline. `alternating`\n * centers it and gives each entry three columns — label, line, body — with the\n * two sides swapping on every second entry, for a presentation timeline rather\n * than an event log.\n *\n * The layout is pushed onto each entry rather than read from here, because a\n * shadow-DOM child cannot style itself against an ancestor portably —\n * `:host-context()` is Chromium-only.\n *\n * @element timeline-container\n * @slot - `timeline-entry` elements, in chronological order.\n */\n@customElement(\"timeline-container\")\nexport class TimelineContainer extends LitElement {\n /** Arrangement of the entries: a left-edge line, or a centered alternating one. */\n @property({ reflect: true }) layout: TimelineLayout = \"left\";\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n `,\n ];\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"role\")) this.setAttribute(\"role\", \"list\");\n }\n\n protected override updated(): void {\n this.#applyLayout();\n }\n\n /** Mirrors `layout` onto every slotted entry so each can style itself. */\n #applyLayout(): void {\n const alternating = this.layout === \"alternating\";\n for (const entry of this.querySelectorAll<TimelineEntry>(\"timeline-entry\")) {\n entry.alternating = alternating;\n }\n }\n\n override render() {\n return html`<slot @slotchange=${this.#applyLayout}></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"timeline-container\": TimelineContainer;\n }\n}\n"]}
@@ -13,6 +13,19 @@ import type { StatusPillColor } from "./status-pill.js";
13
13
  * timestamp prop (e.g. `chat-message`'s `timestamp`) should leave it unset —
14
14
  * setting both renders the same time twice.
15
15
  *
16
+ * `label` is a free-text alternative for a timeline whose axis is not a wall
17
+ * clock — a year, an era, a phase. It wins over `datetime` when both are set.
18
+ * Slot `label` instead when it needs its own styling, since a property is
19
+ * rendered inside this component's shadow DOM and cannot be reached from
20
+ * outside.
21
+ *
22
+ * `alternating` is set by `timeline-container` and should not be set by hand:
23
+ * it switches the entry to three columns — label, line, body — with the sides
24
+ * swapping on every second entry. The entry fills whatever height it is given,
25
+ * so the line spans it rather than only its content — do not override the
26
+ * host's `display` from outside, since a light-DOM rule beats the `:host`
27
+ * declaration this relies on.
28
+ *
16
29
  * The dot's `color` types the entry using the shared status-pill palette —
17
30
  * `primary` by default, plus `neutral`, `info`, `success`, `warning`, and
18
31
  * `danger`.
@@ -26,11 +39,20 @@ import type { StatusPillColor } from "./status-pill.js";
26
39
  *
27
40
  * @element timeline-entry
28
41
  * @slot headline - Optional headline/title for the event.
42
+ * @slot label - Optional replacement for the `label` property, for a label that
43
+ * needs its own styling.
29
44
  * @slot - The event content; nest any elements here.
30
45
  */
31
46
  export declare class TimelineEntry extends LitElement {
32
47
  /** ISO 8601 or SQLite datetime string, rendered as a relative time. */
33
48
  datetime: string | null;
49
+ /** Free-text label shown in place of the relative time; wins over `datetime`. */
50
+ label: string | null;
51
+ /**
52
+ * Three-column alternating presentation. Set by `timeline-container` from its
53
+ * own `layout`; setting it directly is not supported.
54
+ */
55
+ alternating: boolean;
34
56
  /**
35
57
  * Visual type of the entry's dot, from the shared status-pill palette:
36
58
  * `primary` (default), `neutral`, `info`, `success`, `warning`, or `danger`.
@@ -49,8 +71,18 @@ export declare class TimelineEntry extends LitElement {
49
71
  running: boolean;
50
72
  /** Whether the headline slot currently has assigned content. */
51
73
  private _hasHeadline;
74
+ /** Whether the label slot currently has assigned content. */
75
+ private _hasLabel;
52
76
  static styles: import("lit").CSSResult[];
53
77
  connectedCallback(): void;
78
+ /**
79
+ * The entry's one time/label element: a slotted label, else the `label`
80
+ * property, else a relative time. Placed inline beside the headline in the
81
+ * default layout and in its own column when alternating.
82
+ */
83
+ private _renderMeta;
84
+ /** Tracks whether the label slot has content, so an empty one can collapse. */
85
+ private _onLabelSlotChange;
54
86
  /** Collapses the headline when nothing is slotted so the time sits alone. */
55
87
  private _onHeadlineSlotChange;
56
88
  render(): import("lit-html").TemplateResult<1>;
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-entry.d.ts","sourceRoot":"","sources":["../src/timeline-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAErD,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,uEAAuE;IAC3D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3C;;;OAGG;IACS,KAAK,EAAE,eAAe,CAAa;IAE/C;;;OAGG;IACyC,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AU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -20,6 +20,19 @@ import { tokens } from "./tokens.js";
20
20
  * timestamp prop (e.g. `chat-message`'s `timestamp`) should leave it unset —
21
21
  * setting both renders the same time twice.
22
22
  *
23
+ * `label` is a free-text alternative for a timeline whose axis is not a wall
24
+ * clock — a year, an era, a phase. It wins over `datetime` when both are set.
25
+ * Slot `label` instead when it needs its own styling, since a property is
26
+ * rendered inside this component's shadow DOM and cannot be reached from
27
+ * outside.
28
+ *
29
+ * `alternating` is set by `timeline-container` and should not be set by hand:
30
+ * it switches the entry to three columns — label, line, body — with the sides
31
+ * swapping on every second entry. The entry fills whatever height it is given,
32
+ * so the line spans it rather than only its content — do not override the
33
+ * host's `display` from outside, since a light-DOM rule beats the `:host`
34
+ * declaration this relies on.
35
+ *
23
36
  * The dot's `color` types the entry using the shared status-pill palette —
24
37
  * `primary` by default, plus `neutral`, `info`, `success`, `warning`, and
25
38
  * `danger`.
@@ -33,6 +46,8 @@ import { tokens } from "./tokens.js";
33
46
  *
34
47
  * @element timeline-entry
35
48
  * @slot headline - Optional headline/title for the event.
49
+ * @slot label - Optional replacement for the `label` property, for a label that
50
+ * needs its own styling.
36
51
  * @slot - The event content; nest any elements here.
37
52
  */
38
53
  let TimelineEntry = class TimelineEntry extends LitElement {
@@ -40,6 +55,13 @@ let TimelineEntry = class TimelineEntry extends LitElement {
40
55
  super(...arguments);
41
56
  /** ISO 8601 or SQLite datetime string, rendered as a relative time. */
42
57
  this.datetime = null;
58
+ /** Free-text label shown in place of the relative time; wins over `datetime`. */
59
+ this.label = null;
60
+ /**
61
+ * Three-column alternating presentation. Set by `timeline-container` from its
62
+ * own `layout`; setting it directly is not supported.
63
+ */
64
+ this.alternating = false;
43
65
  /**
44
66
  * Visual type of the entry's dot, from the shared status-pill palette:
45
67
  * `primary` (default), `neutral`, `info`, `success`, `warning`, or `danger`.
@@ -58,6 +80,8 @@ let TimelineEntry = class TimelineEntry extends LitElement {
58
80
  this.running = false;
59
81
  /** Whether the headline slot currently has assigned content. */
60
82
  this._hasHeadline = false;
83
+ /** Whether the label slot currently has assigned content. */
84
+ this._hasLabel = false;
61
85
  }
62
86
  static { this.styles = [
63
87
  tokens,
@@ -243,6 +267,78 @@ let TimelineEntry = class TimelineEntry extends LitElement {
243
267
  font-size: var(--ui-font-size-sm, 0.75rem);
244
268
  color: var(--ui-text-muted, #64748b);
245
269
  }
270
+ .time.empty {
271
+ display: none;
272
+ }
273
+
274
+ /*
275
+ * Alternating layout. minmax(0, 1fr) rather than a bare 1fr: an
276
+ * auto-sized track grows to its content's minimum width, which would
277
+ * push the middle column - and with it the line and dot - off center.
278
+ */
279
+ /* A grid host so its single auto row stretches to whatever height the
280
+ consumer gives the entry. The line is drawn inside that row, so
281
+ without this it spans only the content and leaves gaps between
282
+ consecutive entries. Flex does not do this: with a content-sized
283
+ height there is no free space for flex-grow to distribute. */
284
+ :host([alternating]) {
285
+ display: grid;
286
+ }
287
+ :host([alternating]) .entry {
288
+ display: grid;
289
+ grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
290
+ align-items: center;
291
+ column-gap: 1.5rem;
292
+ }
293
+ :host([alternating]) .meta,
294
+ :host([alternating]) .rail,
295
+ :host([alternating]) .body {
296
+ grid-row: 1;
297
+ }
298
+ :host([alternating]) .meta {
299
+ grid-column: 1;
300
+ justify-self: end;
301
+ text-align: right;
302
+ }
303
+ :host([alternating]) .rail {
304
+ grid-column: 2;
305
+ align-self: stretch;
306
+ }
307
+ :host([alternating]) .body {
308
+ grid-column: 3;
309
+ padding: 1.5rem 0;
310
+ }
311
+ :host([alternating]:nth-child(even)) .meta {
312
+ grid-column: 3;
313
+ justify-self: start;
314
+ text-align: left;
315
+ }
316
+ :host([alternating]:nth-child(even)) .body {
317
+ grid-column: 1;
318
+ }
319
+ /* The dot marks the middle of the entry rather than its headline, and
320
+ the line runs the entry's full height so consecutive entries join. */
321
+ :host([alternating]) .dot {
322
+ top: 50%;
323
+ transform: translate(-50%, -50%);
324
+ }
325
+ :host([alternating]) .spinner {
326
+ top: 50%;
327
+ transform: translateY(-50%);
328
+ }
329
+ :host([alternating]) .line-top {
330
+ top: 0;
331
+ height: 50%;
332
+ }
333
+ :host([alternating]) .line-bottom {
334
+ top: 50%;
335
+ bottom: 0;
336
+ }
337
+ :host([alternating]) .time {
338
+ font-size: var(--ui-font-size-lg, 1rem);
339
+ font-weight: var(--ui-font-weight-medium, 500);
340
+ letter-spacing: var(--ui-tracking-wide, 0.04em);
341
+ }
246
342
  `,
247
343
  ]; }
248
344
  connectedCallback() {
@@ -250,6 +346,29 @@ let TimelineEntry = class TimelineEntry extends LitElement {
250
346
  if (!this.hasAttribute("role"))
251
347
  this.setAttribute("role", "listitem");
252
348
  }
349
+ /**
350
+ * The entry's one time/label element: a slotted label, else the `label`
351
+ * property, else a relative time. Placed inline beside the headline in the
352
+ * default layout and in its own column when alternating.
353
+ */
354
+ _renderMeta() {
355
+ const fallback = this.label !== null && this.label !== ""
356
+ ? html `${this.label}`
357
+ : this.datetime
358
+ ? html `<relative-time datetime=${this.datetime}></relative-time>`
359
+ : nothing;
360
+ // Collapsed rather than omitted when there is nothing to show: the slot has
361
+ // to stay in the tree for its slotchange to report late-assigned content,
362
+ // but an empty span would otherwise still claim the head row's gap.
363
+ const empty = fallback === nothing && !this._hasLabel;
364
+ return html `<span class="time ${empty ? "empty" : ""}">
365
+ <slot name="label" @slotchange=${this._onLabelSlotChange}>${fallback}</slot>
366
+ </span>`;
367
+ }
368
+ /** Tracks whether the label slot has content, so an empty one can collapse. */
369
+ _onLabelSlotChange(event) {
370
+ this._hasLabel = event.target.assignedNodes({ flatten: true }).length > 0;
371
+ }
253
372
  /** Collapses the headline when nothing is slotted so the time sits alone. */
254
373
  _onHeadlineSlotChange(event) {
255
374
  this._hasHeadline = event.target.assignedNodes({ flatten: true }).length > 0;
@@ -257,6 +376,7 @@ let TimelineEntry = class TimelineEntry extends LitElement {
257
376
  render() {
258
377
  return html `
259
378
  <div class="entry">
379
+ ${this.alternating ? html `<div class="meta">${this._renderMeta()}</div>` : nothing}
260
380
  <div class="rail" aria-hidden="true">
261
381
  <span class="line line-top"></span>
262
382
  <span class="line line-bottom"></span>
@@ -276,9 +396,7 @@ let TimelineEntry = class TimelineEntry extends LitElement {
276
396
  <span class="headline ${this._hasHeadline ? "" : "empty"}">
277
397
  <slot name="headline" @slotchange=${this._onHeadlineSlotChange}></slot>
278
398
  </span>
279
- ${this.datetime
280
- ? html `<relative-time class="time" datetime=${this.datetime}></relative-time>`
281
- : nothing}
399
+ ${this.alternating ? nothing : this._renderMeta()}
282
400
  </div>
283
401
  <div class="content"><slot></slot></div>
284
402
  </div>
@@ -289,6 +407,12 @@ let TimelineEntry = class TimelineEntry extends LitElement {
289
407
  __decorate([
290
408
  property()
291
409
  ], TimelineEntry.prototype, "datetime", void 0);
410
+ __decorate([
411
+ property()
412
+ ], TimelineEntry.prototype, "label", void 0);
413
+ __decorate([
414
+ property({ type: Boolean, reflect: true })
415
+ ], TimelineEntry.prototype, "alternating", void 0);
292
416
  __decorate([
293
417
  property()
294
418
  ], TimelineEntry.prototype, "color", void 0);
@@ -301,6 +425,9 @@ __decorate([
301
425
  __decorate([
302
426
  state()
303
427
  ], TimelineEntry.prototype, "_hasHeadline", void 0);
428
+ __decorate([
429
+ state()
430
+ ], TimelineEntry.prototype, "_hasLabel", void 0);
304
431
  TimelineEntry = __decorate([
305
432
  customElement("timeline-entry")
306
433
  ], TimelineEntry);