@f-ewald/components 1.28.0 → 1.30.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 -0
- package/custom-elements.json +1817 -84
- package/dist/countdown-timer.d.ts +31 -0
- package/dist/countdown-timer.d.ts.map +1 -0
- package/dist/countdown-timer.js +74 -0
- package/dist/countdown-timer.js.map +1 -0
- package/dist/cron-schedule.d.ts +55 -0
- package/dist/cron-schedule.d.ts.map +1 -0
- package/dist/cron-schedule.js +768 -0
- package/dist/cron-schedule.js.map +1 -0
- package/dist/fullscreen-button.d.ts +43 -0
- package/dist/fullscreen-button.d.ts.map +1 -0
- package/dist/fullscreen-button.js +172 -0
- package/dist/fullscreen-button.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/scroll-dots.d.ts +54 -0
- package/dist/scroll-dots.d.ts.map +1 -0
- package/dist/scroll-dots.js +178 -0
- package/dist/scroll-dots.js.map +1 -0
- package/dist/timeline-container.d.ts +21 -5
- package/dist/timeline-container.d.ts.map +1 -1
- package/dist/timeline-container.js +35 -7
- package/dist/timeline-container.js.map +1 -1
- package/dist/timeline-entry.d.ts +32 -0
- package/dist/timeline-entry.d.ts.map +1 -1
- package/dist/timeline-entry.js +130 -3
- package/dist/timeline-entry.js.map +1 -1
- package/dist/utils/cron.d.ts +83 -0
- package/dist/utils/cron.d.ts.map +1 -0
- package/dist/utils/cron.js +409 -0
- package/dist/utils/cron.js.map +1 -0
- package/docs/countdown-timer.md +40 -0
- package/docs/cron-schedule.md +82 -0
- package/docs/fullscreen-button.md +70 -0
- package/docs/scroll-dots.md +65 -0
- package/docs/timeline-container.md +30 -6
- package/docs/timeline-entry.md +18 -0
- package/llms.txt +171 -8
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
/**
|
|
11
|
+
* Vertical section navigator for a long scrolled page or a slide deck: one dot
|
|
12
|
+
* per section, the active one drawn as an elongated rounded bar rather than a
|
|
13
|
+
* dot, which is the only cue needed to read position at a glance.
|
|
14
|
+
*
|
|
15
|
+
* Controlled, like `pagination-nav`: it owns no scroll behavior and never
|
|
16
|
+
* reads the scroll position. The consumer sets `active` and moves the page in
|
|
17
|
+
* response to `dot-select` — what counts as the active section differs too much
|
|
18
|
+
* between a snapped deck and an ordinary long page to bake in.
|
|
19
|
+
*
|
|
20
|
+
* Positioning is also the consumer's, since a rail is normally fixed into a
|
|
21
|
+
* reserved gutter that only the page knows the width of.
|
|
22
|
+
*
|
|
23
|
+
* The dots use the same lighter-on-top gradient as `map-circle`/`map-pin`,
|
|
24
|
+
* derived from a single base `color` — a rail beside a map reads as the same
|
|
25
|
+
* family of marks as the pins on it.
|
|
26
|
+
*
|
|
27
|
+
* @element scroll-dots
|
|
28
|
+
* @fires dot-select - The user picked a dot (`detail: { index }`).
|
|
29
|
+
*/
|
|
30
|
+
let ScrollDots = class ScrollDots extends LitElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
/** Dots to render, in document order. A bare string is shorthand for `{ label }`. */
|
|
34
|
+
this.items = [];
|
|
35
|
+
/** 0-based index of the active dot. Out-of-range values simply match no dot. */
|
|
36
|
+
this.active = 0;
|
|
37
|
+
/** Base color the dot gradient is derived from. Empty uses `--ui-primary`. */
|
|
38
|
+
this.color = "";
|
|
39
|
+
/** Accessible name for the rail, e.g. "Journey stops". */
|
|
40
|
+
this.label = "";
|
|
41
|
+
}
|
|
42
|
+
static { this.styles = [
|
|
43
|
+
tokens,
|
|
44
|
+
css `
|
|
45
|
+
/*
|
|
46
|
+
* will-change promotes the rail to its own compositor layer. A rail is
|
|
47
|
+
* typically fixed over the page's main content — for a map deck, over a
|
|
48
|
+
* WebGL canvas — and without it the browser repaints the dots on the main
|
|
49
|
+
* thread, which flickers and squares off their rounded edges whenever a
|
|
50
|
+
* scroll and an animation are competing for that thread.
|
|
51
|
+
*/
|
|
52
|
+
:host {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
will-change: transform;
|
|
55
|
+
backface-visibility: hidden;
|
|
56
|
+
}
|
|
57
|
+
nav {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
align-items: center;
|
|
61
|
+
gap: 0.75rem;
|
|
62
|
+
}
|
|
63
|
+
button {
|
|
64
|
+
width: 0.625rem;
|
|
65
|
+
height: 0.625rem;
|
|
66
|
+
padding: 0;
|
|
67
|
+
border: none;
|
|
68
|
+
border-radius: 9999px;
|
|
69
|
+
/* Same lighter-on-top token gradient as map-circle/timeline-entry's
|
|
70
|
+
dot; the base color is swapped via the private --_dot var. */
|
|
71
|
+
background: linear-gradient(
|
|
72
|
+
to bottom,
|
|
73
|
+
color-mix(in srgb, var(--_dot, var(--ui-text-muted, #64748b)) 70%, #ffffff) 0%,
|
|
74
|
+
color-mix(in srgb, var(--_dot, var(--ui-text-muted, #64748b)) 70%, #000000) 100%
|
|
75
|
+
);
|
|
76
|
+
opacity: 0.45;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
/*
|
|
79
|
+
* Size is deliberately absent: height is a layout property, so
|
|
80
|
+
* transitioning it animates on the main thread, where a concurrent
|
|
81
|
+
* animation elsewhere on the page can starve it down to a couple of
|
|
82
|
+
* frames and render the bar with squared-off edges. The size change
|
|
83
|
+
* snaps; only the compositable properties ease.
|
|
84
|
+
*/
|
|
85
|
+
transition: opacity 0.25s ease;
|
|
86
|
+
}
|
|
87
|
+
button.muted {
|
|
88
|
+
width: 0.4rem;
|
|
89
|
+
height: 0.4rem;
|
|
90
|
+
}
|
|
91
|
+
button:hover {
|
|
92
|
+
opacity: 0.8;
|
|
93
|
+
}
|
|
94
|
+
button:focus-visible {
|
|
95
|
+
outline: none;
|
|
96
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
97
|
+
}
|
|
98
|
+
button.active {
|
|
99
|
+
height: 2.25rem;
|
|
100
|
+
--_dot: var(--_color, var(--ui-primary, #4f46e5));
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
@media (forced-colors: active) {
|
|
104
|
+
button {
|
|
105
|
+
background: GrayText;
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
|
108
|
+
button.active {
|
|
109
|
+
background: Highlight;
|
|
110
|
+
}
|
|
111
|
+
button:focus-visible {
|
|
112
|
+
outline: 2px solid CanvasText;
|
|
113
|
+
outline-offset: 2px;
|
|
114
|
+
box-shadow: none;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
118
|
+
button {
|
|
119
|
+
transition: none;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
]; }
|
|
124
|
+
render() {
|
|
125
|
+
const dots = this.items.map((item, index) => this._renderDot(normalize(item), index));
|
|
126
|
+
return html `
|
|
127
|
+
<nav
|
|
128
|
+
aria-label=${this.label}
|
|
129
|
+
style=${this.color === "" ? "" : `--_color: ${this.color}`}
|
|
130
|
+
>
|
|
131
|
+
${dots}
|
|
132
|
+
</nav>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
_renderDot(item, index) {
|
|
136
|
+
const isActive = index === this.active;
|
|
137
|
+
const classes = [item.muted ? "muted" : "", isActive ? "active" : ""]
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.join(" ");
|
|
140
|
+
return html `
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
class=${classes}
|
|
144
|
+
aria-label=${item.label}
|
|
145
|
+
title=${item.label}
|
|
146
|
+
aria-current=${String(isActive)}
|
|
147
|
+
@click=${() => this._select(index)}
|
|
148
|
+
></button>
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
_select(index) {
|
|
152
|
+
this.dispatchEvent(new CustomEvent("dot-select", {
|
|
153
|
+
detail: { index },
|
|
154
|
+
bubbles: true,
|
|
155
|
+
composed: true,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ attribute: false })
|
|
161
|
+
], ScrollDots.prototype, "items", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property({ type: Number })
|
|
164
|
+
], ScrollDots.prototype, "active", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property()
|
|
167
|
+
], ScrollDots.prototype, "color", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property()
|
|
170
|
+
], ScrollDots.prototype, "label", void 0);
|
|
171
|
+
ScrollDots = __decorate([
|
|
172
|
+
customElement("scroll-dots")
|
|
173
|
+
], ScrollDots);
|
|
174
|
+
export { ScrollDots };
|
|
175
|
+
function normalize(item) {
|
|
176
|
+
return typeof item === "string" ? { label: item } : item;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=scroll-dots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-dots.js","sourceRoot":"","sources":["../src/scroll-dots.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;AAkBrC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QACL,qFAAqF;QACrD,UAAK,GAAqB,EAAE,CAAC;QAE7D,gFAAgF;QACpD,WAAM,GAAG,CAAC,CAAC;QAEvC,8EAA8E;QAClE,UAAK,GAAG,EAAE,CAAC;QAEvB,0DAA0D;QAC9C,UAAK,GAAG,EAAE,CAAC;IA2HzB,CAAC;aAzHiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8EF;KACF,AAjFqB,CAiFpB;IAEO,MAAM;QACb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QACtF,OAAO,IAAI,CAAA;;qBAEM,IAAI,CAAC,KAAK;gBACf,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,KAAK,EAAE;;UAExD,IAAI;;KAET,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,IAAmB,EAAE,KAAa;QACnD,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC;QACvC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAA;;;gBAGC,OAAO;qBACF,IAAI,CAAC,KAAK;gBACf,IAAI,CAAC,KAAK;uBACH,MAAM,CAAC,QAAQ,CAAC;iBACtB,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;;KAErC,CAAC;IACJ,CAAC;IAEO,OAAO,CAAC,KAAa;QAC3B,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAkB,YAAY,EAAE;YAC7C,MAAM,EAAE,EAAE,KAAK,EAAE;YACjB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AApIiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCAA8B;AAGjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAY;AAG3B;IAAX,QAAQ,EAAE;yCAAY;AAGX;IAAX,QAAQ,EAAE;yCAAY;AAXZ,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAsItB;;AAED,SAAS,SAAS,CAAC,IAAoB;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** One dot on a `scroll-dots` rail. */\nexport interface ScrollDotItem {\n /** Accessible name for the dot's button — the section or slide title. */\n label: string;\n /** Renders the dot smaller and quieter, for a section subordinate to its neighbours. */\n muted?: boolean;\n}\n\n/** A dot, or a bare string as shorthand for `{ label }`. */\nexport type ScrollDotsItem = string | ScrollDotItem;\n\n/** Fired when the user picks a dot. `detail.index` is the 0-based target. */\nexport interface DotSelectDetail {\n index: number;\n}\n\n/**\n * Vertical section navigator for a long scrolled page or a slide deck: one dot\n * per section, the active one drawn as an elongated rounded bar rather than a\n * dot, which is the only cue needed to read position at a glance.\n *\n * Controlled, like `pagination-nav`: it owns no scroll behavior and never\n * reads the scroll position. The consumer sets `active` and moves the page in\n * response to `dot-select` — what counts as the active section differs too much\n * between a snapped deck and an ordinary long page to bake in.\n *\n * Positioning is also the consumer's, since a rail is normally fixed into a\n * reserved gutter that only the page knows the width of.\n *\n * The dots use the same lighter-on-top gradient as `map-circle`/`map-pin`,\n * derived from a single base `color` — a rail beside a map reads as the same\n * family of marks as the pins on it.\n *\n * @element scroll-dots\n * @fires dot-select - The user picked a dot (`detail: { index }`).\n */\n@customElement(\"scroll-dots\")\nexport class ScrollDots extends LitElement {\n /** Dots to render, in document order. A bare string is shorthand for `{ label }`. */\n @property({ attribute: false }) items: ScrollDotsItem[] = [];\n\n /** 0-based index of the active dot. Out-of-range values simply match no dot. */\n @property({ type: Number }) active = 0;\n\n /** Base color the dot gradient is derived from. Empty uses `--ui-primary`. */\n @property() color = \"\";\n\n /** Accessible name for the rail, e.g. \"Journey stops\". */\n @property() label = \"\";\n\n static override styles = [\n tokens,\n css`\n /*\n * will-change promotes the rail to its own compositor layer. A rail is\n * typically fixed over the page's main content — for a map deck, over a\n * WebGL canvas — and without it the browser repaints the dots on the main\n * thread, which flickers and squares off their rounded edges whenever a\n * scroll and an animation are competing for that thread.\n */\n :host {\n display: inline-flex;\n will-change: transform;\n backface-visibility: hidden;\n }\n nav {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 0.75rem;\n }\n button {\n width: 0.625rem;\n height: 0.625rem;\n padding: 0;\n border: none;\n border-radius: 9999px;\n /* Same lighter-on-top token gradient as map-circle/timeline-entry's\n dot; the base color is swapped via the private --_dot var. */\n background: linear-gradient(\n to bottom,\n color-mix(in srgb, var(--_dot, var(--ui-text-muted, #64748b)) 70%, #ffffff) 0%,\n color-mix(in srgb, var(--_dot, var(--ui-text-muted, #64748b)) 70%, #000000) 100%\n );\n opacity: 0.45;\n cursor: pointer;\n /*\n * Size is deliberately absent: height is a layout property, so\n * transitioning it animates on the main thread, where a concurrent\n * animation elsewhere on the page can starve it down to a couple of\n * frames and render the bar with squared-off edges. The size change\n * snaps; only the compositable properties ease.\n */\n transition: opacity 0.25s ease;\n }\n button.muted {\n width: 0.4rem;\n height: 0.4rem;\n }\n button:hover {\n opacity: 0.8;\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 button.active {\n height: 2.25rem;\n --_dot: var(--_color, var(--ui-primary, #4f46e5));\n opacity: 1;\n }\n @media (forced-colors: active) {\n button {\n background: GrayText;\n opacity: 1;\n }\n button.active {\n background: Highlight;\n }\n button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n button {\n transition: none;\n }\n }\n `,\n ];\n\n override render() {\n const dots = this.items.map((item, index) => this._renderDot(normalize(item), index));\n return html`\n <nav\n aria-label=${this.label}\n style=${this.color === \"\" ? \"\" : `--_color: ${this.color}`}\n >\n ${dots}\n </nav>\n `;\n }\n\n private _renderDot(item: ScrollDotItem, index: number) {\n const isActive = index === this.active;\n const classes = [item.muted ? \"muted\" : \"\", isActive ? \"active\" : \"\"]\n .filter(Boolean)\n .join(\" \");\n return html`\n <button\n type=\"button\"\n class=${classes}\n aria-label=${item.label}\n title=${item.label}\n aria-current=${String(isActive)}\n @click=${() => this._select(index)}\n ></button>\n `;\n }\n\n private _select(index: number): void {\n this.dispatchEvent(\n new CustomEvent<DotSelectDetail>(\"dot-select\", {\n detail: { index },\n bubbles: true,\n composed: true,\n }),\n );\n }\n}\n\nfunction normalize(item: ScrollDotsItem): ScrollDotItem {\n return typeof item === \"string\" ? { label: item } : item;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"scroll-dots\": ScrollDots;\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
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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;
|
|
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
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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;
|
|
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"]}
|
package/dist/timeline-entry.d.ts
CHANGED
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,uEAAuE;IAC3D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3C,iFAAiF;IACrE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAExC;;;OAGG;IACyC,WAAW,UAAS;IAEhE;;;OAGG;IACS,KAAK,EAAE,eAAe,CAAa;IAE/C;;;OAGG;IACyC,OAAO,UAAS;IAE5D;;;;OAIG;IACyC,OAAO,UAAS;IAE5D,gEAAgE;IACvD,OAAO,CAAC,YAAY,CAAS;IAEtC,6DAA6D;IACpD,OAAO,CAAC,SAAS,CAAS;IAEnC,OAAgB,MAAM,4BAiQpB;IAEO,iBAAiB,IAAI,IAAI,CAGjC;IAED;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAgBnB,+EAA+E;IAC/E,OAAO,CAAC,kBAAkB;IAI1B,6EAA6E;IAC7E,OAAO,CAAC,qBAAqB;IAIpB,MAAM,yCA6Bd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
package/dist/timeline-entry.js
CHANGED
|
@@ -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.
|
|
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);
|