@f-ewald/components 1.23.0 → 1.24.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 +7 -1
- package/custom-elements.json +1966 -643
- package/dist/address-autocomplete.d.ts.map +1 -1
- package/dist/address-autocomplete.js +7 -3
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/audio-player.d.ts +53 -0
- package/dist/audio-player.d.ts.map +1 -0
- package/dist/audio-player.js +267 -0
- package/dist/audio-player.js.map +1 -0
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +7 -3
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/button-group.d.ts +12 -1
- package/dist/button-group.d.ts.map +1 -1
- package/dist/button-group.js +35 -3
- package/dist/button-group.js.map +1 -1
- package/dist/comment-composer.d.ts +54 -0
- package/dist/comment-composer.d.ts.map +1 -0
- package/dist/comment-composer.js +244 -0
- package/dist/comment-composer.js.map +1 -0
- package/dist/confirm-dialog.d.ts +4 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +47 -9
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/dropdown-button.d.ts +4 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +29 -3
- package/dist/dropdown-button.js.map +1 -1
- package/dist/icons.d.ts +65 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +65 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +39 -0
- package/dist/mcp-server.js.map +1 -1
- package/dist/page-header.d.ts +8 -3
- package/dist/page-header.d.ts.map +1 -1
- package/dist/page-header.js +33 -12
- package/dist/page-header.js.map +1 -1
- package/dist/pagination-nav.d.ts +7 -0
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +19 -4
- package/dist/pagination-nav.js.map +1 -1
- package/dist/radio-cards.d.ts +6 -0
- package/dist/radio-cards.d.ts.map +1 -1
- package/dist/radio-cards.js +13 -3
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.d.ts +6 -0
- package/dist/radio-pills.d.ts.map +1 -1
- package/dist/radio-pills.js +13 -3
- package/dist/radio-pills.js.map +1 -1
- package/dist/range-slider.d.ts.map +1 -1
- package/dist/range-slider.js +11 -7
- package/dist/range-slider.js.map +1 -1
- package/dist/reveal-button.d.ts +5 -1
- package/dist/reveal-button.d.ts.map +1 -1
- package/dist/reveal-button.js +26 -4
- package/dist/reveal-button.js.map +1 -1
- package/dist/tokens.css +17 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +56 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.d.ts +16 -0
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +48 -7
- package/dist/ui-button.js.map +1 -1
- package/dist/utils/duration.d.ts +8 -0
- package/dist/utils/duration.d.ts.map +1 -1
- package/dist/utils/duration.js +18 -0
- package/dist/utils/duration.js.map +1 -1
- package/dist/utils/transport-controls.d.ts +11 -0
- package/dist/utils/transport-controls.d.ts.map +1 -0
- package/dist/utils/transport-controls.js +113 -0
- package/dist/utils/transport-controls.js.map +1 -0
- package/dist/video-player.d.ts +60 -0
- package/dist/video-player.d.ts.map +1 -0
- package/dist/video-player.js +324 -0
- package/dist/video-player.js.map +1 -0
- package/docs/audio-player.md +60 -0
- package/docs/button-group.md +18 -1
- package/docs/comment-composer.md +68 -0
- package/docs/confirm-dialog.md +19 -1
- package/docs/dropdown-button.md +10 -1
- package/docs/icons.md +75 -0
- package/docs/page-header.md +11 -4
- package/docs/pagination-nav.md +14 -0
- package/docs/radio-cards.md +9 -0
- package/docs/radio-pills.md +9 -0
- package/docs/range-slider.md +3 -0
- package/docs/reveal-button.md +11 -1
- package/docs/ui-button.md +32 -0
- package/docs/video-player.md +59 -0
- package/llms.txt +224 -23
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* Shared `<input type="range">` track/thumb styling for media transport
|
|
4
|
+
* controls (the seek bar and volume slider in `audio-player`/`video-player`).
|
|
5
|
+
* Reuses `range-slider.ts`'s track/fill visual language (a filled portion up
|
|
6
|
+
* to `--range-percent`) so both players get free native keyboard/pointer
|
|
7
|
+
* seeking instead of a custom-built draggable control, matching the "native
|
|
8
|
+
* semantics before custom ARIA" rule. Extracted here rather than duplicated
|
|
9
|
+
* because both components need the identical rule set.
|
|
10
|
+
*/
|
|
11
|
+
export const transportRangeStyles = css `
|
|
12
|
+
input[type="range"] {
|
|
13
|
+
-webkit-appearance: none;
|
|
14
|
+
appearance: none;
|
|
15
|
+
/* Width is intentionally left to the consumer (e.g. .seek/.volume in
|
|
16
|
+
audio-player/video-player) — this element+attribute selector has
|
|
17
|
+
higher specificity than a single class rule, so setting a width
|
|
18
|
+
here would win over a component's own narrower class and silently
|
|
19
|
+
stretch every range input (including a fixed-width volume slider)
|
|
20
|
+
to 100%. */
|
|
21
|
+
height: 1rem;
|
|
22
|
+
margin: 0;
|
|
23
|
+
background: transparent;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
input[type="range"]:disabled {
|
|
27
|
+
cursor: not-allowed;
|
|
28
|
+
opacity: 0.6;
|
|
29
|
+
}
|
|
30
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
31
|
+
height: 0.25rem;
|
|
32
|
+
border-radius: 9999px;
|
|
33
|
+
/* A hard-stop gradient two-tone fill trick — see range-slider.ts for why
|
|
34
|
+
this reads --ui-button-accent rather than --ui-button-background. */
|
|
35
|
+
background: linear-gradient(
|
|
36
|
+
to right,
|
|
37
|
+
var(--ui-button-accent, var(--ui-primary, #4f46e5)) 0%,
|
|
38
|
+
var(--ui-button-accent, var(--ui-primary, #4f46e5)) var(--range-percent, 0%),
|
|
39
|
+
var(--ui-surface-muted, #f8fafc) var(--range-percent, 0%),
|
|
40
|
+
var(--ui-surface-muted, #f8fafc) 100%
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
input[type="range"]::-moz-range-track {
|
|
44
|
+
height: 0.25rem;
|
|
45
|
+
border-radius: 9999px;
|
|
46
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
47
|
+
}
|
|
48
|
+
input[type="range"]::-moz-range-progress {
|
|
49
|
+
height: 0.25rem;
|
|
50
|
+
border-radius: 9999px;
|
|
51
|
+
background: var(--ui-button-accent, var(--ui-primary, #4f46e5));
|
|
52
|
+
}
|
|
53
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
54
|
+
-webkit-appearance: none;
|
|
55
|
+
appearance: none;
|
|
56
|
+
width: 0.75rem;
|
|
57
|
+
height: 0.75rem;
|
|
58
|
+
/* WebKit centers the thumb on the input's full 1rem box, not the
|
|
59
|
+
thinner custom track — nudge it up to align, as in range-slider.ts. */
|
|
60
|
+
transform: translateY(-0.25rem);
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
63
|
+
border: 2px solid var(--ui-surface, #ffffff);
|
|
64
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
65
|
+
}
|
|
66
|
+
input[type="range"]::-moz-range-thumb {
|
|
67
|
+
width: 0.75rem;
|
|
68
|
+
height: 0.75rem;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
background: var(--ui-button-background, var(--ui-primary, #4f46e5));
|
|
71
|
+
border: 2px solid var(--ui-surface, #ffffff);
|
|
72
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);
|
|
73
|
+
}
|
|
74
|
+
input[type="range"]:disabled::-webkit-slider-thumb {
|
|
75
|
+
background: var(--ui-text-muted, #64748b);
|
|
76
|
+
}
|
|
77
|
+
input[type="range"]:disabled::-moz-range-thumb {
|
|
78
|
+
background: var(--ui-text-muted, #64748b);
|
|
79
|
+
}
|
|
80
|
+
input[type="range"]:focus-visible {
|
|
81
|
+
outline: none;
|
|
82
|
+
}
|
|
83
|
+
input[type="range"]:focus-visible::-webkit-slider-thumb {
|
|
84
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
85
|
+
}
|
|
86
|
+
input[type="range"]:focus-visible::-moz-range-thumb {
|
|
87
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
88
|
+
}
|
|
89
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
90
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
91
|
+
transition: box-shadow 120ms ease;
|
|
92
|
+
}
|
|
93
|
+
input[type="range"]::-moz-range-thumb {
|
|
94
|
+
transition: box-shadow 120ms ease;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
@media (forced-colors: active) {
|
|
98
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
99
|
+
background: Canvas;
|
|
100
|
+
border: 1px solid CanvasText;
|
|
101
|
+
}
|
|
102
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
103
|
+
background: Highlight;
|
|
104
|
+
border-color: Canvas;
|
|
105
|
+
}
|
|
106
|
+
input[type="range"]:focus-visible::-webkit-slider-thumb {
|
|
107
|
+
outline: 2px solid CanvasText;
|
|
108
|
+
outline-offset: 2px;
|
|
109
|
+
box-shadow: none;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
//# sourceMappingURL=transport-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-controls.js","sourceRoot":"","sources":["../../src/utils/transport-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGtC,CAAC","sourcesContent":["import { css } from \"lit\";\n\n/**\n * Shared `<input type=\"range\">` track/thumb styling for media transport\n * controls (the seek bar and volume slider in `audio-player`/`video-player`).\n * Reuses `range-slider.ts`'s track/fill visual language (a filled portion up\n * to `--range-percent`) so both players get free native keyboard/pointer\n * seeking instead of a custom-built draggable control, matching the \"native\n * semantics before custom ARIA\" rule. Extracted here rather than duplicated\n * because both components need the identical rule set.\n */\nexport const transportRangeStyles = css`\n input[type=\"range\"] {\n -webkit-appearance: none;\n appearance: none;\n /* Width is intentionally left to the consumer (e.g. .seek/.volume in\n audio-player/video-player) — this element+attribute selector has\n higher specificity than a single class rule, so setting a width\n here would win over a component's own narrower class and silently\n stretch every range input (including a fixed-width volume slider)\n to 100%. */\n height: 1rem;\n margin: 0;\n background: transparent;\n cursor: pointer;\n }\n input[type=\"range\"]:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input[type=\"range\"]::-webkit-slider-runnable-track {\n height: 0.25rem;\n border-radius: 9999px;\n /* A hard-stop gradient two-tone fill trick — see range-slider.ts for why\n this reads --ui-button-accent rather than --ui-button-background. */\n background: linear-gradient(\n to right,\n var(--ui-button-accent, var(--ui-primary, #4f46e5)) 0%,\n var(--ui-button-accent, var(--ui-primary, #4f46e5)) var(--range-percent, 0%),\n var(--ui-surface-muted, #f8fafc) var(--range-percent, 0%),\n var(--ui-surface-muted, #f8fafc) 100%\n );\n }\n input[type=\"range\"]::-moz-range-track {\n height: 0.25rem;\n border-radius: 9999px;\n background: var(--ui-surface-muted, #f8fafc);\n }\n input[type=\"range\"]::-moz-range-progress {\n height: 0.25rem;\n border-radius: 9999px;\n background: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n }\n input[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0.75rem;\n height: 0.75rem;\n /* WebKit centers the thumb on the input's full 1rem box, not the\n thinner custom track — nudge it up to align, as in range-slider.ts. */\n transform: translateY(-0.25rem);\n border-radius: 50%;\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border: 2px solid var(--ui-surface, #ffffff);\n box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n input[type=\"range\"]::-moz-range-thumb {\n width: 0.75rem;\n height: 0.75rem;\n border-radius: 50%;\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border: 2px solid var(--ui-surface, #ffffff);\n box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n input[type=\"range\"]:disabled::-webkit-slider-thumb {\n background: var(--ui-text-muted, #64748b);\n }\n input[type=\"range\"]:disabled::-moz-range-thumb {\n background: var(--ui-text-muted, #64748b);\n }\n input[type=\"range\"]:focus-visible {\n outline: none;\n }\n input[type=\"range\"]:focus-visible::-webkit-slider-thumb {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n input[type=\"range\"]:focus-visible::-moz-range-thumb {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: no-preference) {\n input[type=\"range\"]::-webkit-slider-thumb {\n transition: box-shadow 120ms ease;\n }\n input[type=\"range\"]::-moz-range-thumb {\n transition: box-shadow 120ms ease;\n }\n }\n @media (forced-colors: active) {\n input[type=\"range\"]::-webkit-slider-runnable-track {\n background: Canvas;\n border: 1px solid CanvasText;\n }\n input[type=\"range\"]::-webkit-slider-thumb {\n background: Highlight;\n border-color: Canvas;\n }\n input[type=\"range\"]:focus-visible::-webkit-slider-thumb {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n`;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "./icon-button.js";
|
|
3
|
+
/**
|
|
4
|
+
* Video player wrapping a native `<video>` element (native `controls`
|
|
5
|
+
* disabled) with the same tokenized transport bar as `audio-player` — a
|
|
6
|
+
* play/pause `icon-button`, elapsed/total time, a seekable progress bar, a
|
|
7
|
+
* mute toggle + volume slider — plus a fullscreen toggle. The control bar
|
|
8
|
+
* sits in a persistent strip under the video frame rather than a
|
|
9
|
+
* hover-reveal overlay, so it stays usable for keyboard/touch input without
|
|
10
|
+
* a pointer hover state.
|
|
11
|
+
*
|
|
12
|
+
* @element video-player
|
|
13
|
+
* @fires play - The video started playing.
|
|
14
|
+
* @fires pause - The video was paused.
|
|
15
|
+
* @fires ended - Playback reached the end.
|
|
16
|
+
*/
|
|
17
|
+
export declare class VideoPlayer extends LitElement {
|
|
18
|
+
#private;
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
/** URL of the video file to play. */
|
|
21
|
+
src: string;
|
|
22
|
+
/** Poster image shown before playback starts. */
|
|
23
|
+
poster: string;
|
|
24
|
+
/** Accessible name for the player, e.g. a video title. */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Loops playback once it reaches the end. */
|
|
27
|
+
loop: boolean;
|
|
28
|
+
/** Native `<video preload>` hint. */
|
|
29
|
+
preload: "none" | "metadata" | "auto";
|
|
30
|
+
private _playing;
|
|
31
|
+
private _currentTime;
|
|
32
|
+
private _duration;
|
|
33
|
+
private _volume;
|
|
34
|
+
private _muted;
|
|
35
|
+
private _errored;
|
|
36
|
+
private _fullscreen;
|
|
37
|
+
private _video?;
|
|
38
|
+
private _frame?;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
disconnectedCallback(): void;
|
|
41
|
+
private _togglePlay;
|
|
42
|
+
private _toggleMute;
|
|
43
|
+
private _toggleFullscreen;
|
|
44
|
+
private _onSeekInput;
|
|
45
|
+
private _onVolumeInput;
|
|
46
|
+
private _onLoadedMetadata;
|
|
47
|
+
private _onTimeUpdate;
|
|
48
|
+
private _onPlay;
|
|
49
|
+
private _onPause;
|
|
50
|
+
private _onEnded;
|
|
51
|
+
private _onVolumeChange;
|
|
52
|
+
private _onError;
|
|
53
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
interface HTMLElementTagNameMap {
|
|
57
|
+
"video-player": VideoPlayer;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=video-player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-player.d.ts","sourceRoot":"","sources":["../src/video-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAa5C,OAAO,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,4BA2EpB;IAEF,qCAAqC;IACzB,GAAG,SAAM;IACrB,iDAAiD;IACrC,MAAM,SAAM;IACxB,0DAA0D;IAC9C,KAAK,SAAkB;IACnC,8CAA8C;IACjB,IAAI,UAAS;IAC1C,qCAAqC;IACzB,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAc;IAEtD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAS;IAErB,OAAO,CAAC,MAAM,CAAC,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAC,CAAiB;IAMxC,iBAAiB,IAAI,IAAI,CAGjC;IAEQ,oBAAoB,IAAI,IAAI,CAGpC;IAED,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,QAAQ;IAIP,MAAM,yCAmEd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,324 @@
|
|
|
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, query, state } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
import { transportRangeStyles } from "./utils/transport-controls.js";
|
|
11
|
+
import { formatClockDuration } from "./utils/duration.js";
|
|
12
|
+
import { iconArrowsPointingIn, iconArrowsPointingOut, iconPause, iconPlay, iconSpeakerWave, iconSpeakerXMark, } from "./icons.js";
|
|
13
|
+
import "./icon-button.js";
|
|
14
|
+
/**
|
|
15
|
+
* Video player wrapping a native `<video>` element (native `controls`
|
|
16
|
+
* disabled) with the same tokenized transport bar as `audio-player` — a
|
|
17
|
+
* play/pause `icon-button`, elapsed/total time, a seekable progress bar, a
|
|
18
|
+
* mute toggle + volume slider — plus a fullscreen toggle. The control bar
|
|
19
|
+
* sits in a persistent strip under the video frame rather than a
|
|
20
|
+
* hover-reveal overlay, so it stays usable for keyboard/touch input without
|
|
21
|
+
* a pointer hover state.
|
|
22
|
+
*
|
|
23
|
+
* @element video-player
|
|
24
|
+
* @fires play - The video started playing.
|
|
25
|
+
* @fires pause - The video was paused.
|
|
26
|
+
* @fires ended - Playback reached the end.
|
|
27
|
+
*/
|
|
28
|
+
let VideoPlayer = class VideoPlayer extends LitElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/** URL of the video file to play. */
|
|
32
|
+
this.src = "";
|
|
33
|
+
/** Poster image shown before playback starts. */
|
|
34
|
+
this.poster = "";
|
|
35
|
+
/** Accessible name for the player, e.g. a video title. */
|
|
36
|
+
this.label = "Video player";
|
|
37
|
+
/** Loops playback once it reaches the end. */
|
|
38
|
+
this.loop = false;
|
|
39
|
+
/** Native `<video preload>` hint. */
|
|
40
|
+
this.preload = "metadata";
|
|
41
|
+
this._playing = false;
|
|
42
|
+
this._currentTime = 0;
|
|
43
|
+
this._duration = NaN;
|
|
44
|
+
this._volume = 1;
|
|
45
|
+
this._muted = false;
|
|
46
|
+
this._errored = false;
|
|
47
|
+
this._fullscreen = false;
|
|
48
|
+
this.#onFullscreenChange = () => {
|
|
49
|
+
this._fullscreen = document.fullscreenElement === this._frame;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static { this.styles = [
|
|
53
|
+
tokens,
|
|
54
|
+
transportRangeStyles,
|
|
55
|
+
css `
|
|
56
|
+
:host {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
.player {
|
|
60
|
+
border: 1px solid var(--ui-border, #e2e8f0);
|
|
61
|
+
border-radius: var(--ui-radius, 0.5rem);
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
background: var(--ui-surface, #ffffff);
|
|
64
|
+
font-family: var(
|
|
65
|
+
--ui-font,
|
|
66
|
+
ui-sans-serif,
|
|
67
|
+
system-ui,
|
|
68
|
+
sans-serif,
|
|
69
|
+
"Apple Color Emoji",
|
|
70
|
+
"Segoe UI Emoji",
|
|
71
|
+
"Segoe UI Symbol",
|
|
72
|
+
"Noto Color Emoji"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
.frame {
|
|
76
|
+
display: flex;
|
|
77
|
+
/* Letterboxing behind the video's own content is a universal video
|
|
78
|
+
convention independent of the surrounding theme — same literal-color
|
|
79
|
+
exception category as this package's white map rings/avatar marks. */
|
|
80
|
+
background: #000000;
|
|
81
|
+
}
|
|
82
|
+
video {
|
|
83
|
+
display: block;
|
|
84
|
+
width: 100%;
|
|
85
|
+
max-height: 30rem;
|
|
86
|
+
object-fit: contain;
|
|
87
|
+
}
|
|
88
|
+
.controls {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: 0.5rem;
|
|
92
|
+
padding: 0.5rem 0.75rem;
|
|
93
|
+
}
|
|
94
|
+
.time {
|
|
95
|
+
flex: 0 0 auto;
|
|
96
|
+
min-width: 2.5rem;
|
|
97
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
98
|
+
color: var(--ui-text-muted, #64748b);
|
|
99
|
+
font-variant-numeric: tabular-nums;
|
|
100
|
+
text-align: center;
|
|
101
|
+
}
|
|
102
|
+
.seek {
|
|
103
|
+
/* Sets its own width (100%) and flex-basis: 0 (not auto) so it
|
|
104
|
+
fills the row's remaining space via flex-grow — an auto basis
|
|
105
|
+
would otherwise derive its hypothetical size from that same
|
|
106
|
+
width:100%, resolved against an indefinite container, and
|
|
107
|
+
collapse the track to 0. */
|
|
108
|
+
flex: 1 1 0%;
|
|
109
|
+
min-width: 0;
|
|
110
|
+
width: 100%;
|
|
111
|
+
}
|
|
112
|
+
.volume {
|
|
113
|
+
flex: 0 0 auto;
|
|
114
|
+
width: 4rem;
|
|
115
|
+
}
|
|
116
|
+
.error {
|
|
117
|
+
padding: 0.5rem 0.75rem;
|
|
118
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
119
|
+
color: var(--ui-danger, #dc2626);
|
|
120
|
+
}
|
|
121
|
+
@media (forced-colors: active) {
|
|
122
|
+
.player {
|
|
123
|
+
border-color: CanvasText;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
]; }
|
|
128
|
+
#onFullscreenChange;
|
|
129
|
+
connectedCallback() {
|
|
130
|
+
super.connectedCallback();
|
|
131
|
+
document.addEventListener("fullscreenchange", this.#onFullscreenChange);
|
|
132
|
+
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
super.disconnectedCallback();
|
|
135
|
+
document.removeEventListener("fullscreenchange", this.#onFullscreenChange);
|
|
136
|
+
}
|
|
137
|
+
_togglePlay() {
|
|
138
|
+
const video = this._video;
|
|
139
|
+
if (!video)
|
|
140
|
+
return;
|
|
141
|
+
if (video.paused)
|
|
142
|
+
video.play();
|
|
143
|
+
else
|
|
144
|
+
video.pause();
|
|
145
|
+
}
|
|
146
|
+
_toggleMute() {
|
|
147
|
+
const video = this._video;
|
|
148
|
+
if (!video)
|
|
149
|
+
return;
|
|
150
|
+
video.muted = !video.muted;
|
|
151
|
+
}
|
|
152
|
+
_toggleFullscreen() {
|
|
153
|
+
const frame = this._frame;
|
|
154
|
+
if (!frame)
|
|
155
|
+
return;
|
|
156
|
+
if (document.fullscreenElement === frame)
|
|
157
|
+
document.exitFullscreen();
|
|
158
|
+
else
|
|
159
|
+
frame.requestFullscreen();
|
|
160
|
+
}
|
|
161
|
+
_onSeekInput(e) {
|
|
162
|
+
const video = this._video;
|
|
163
|
+
if (!video)
|
|
164
|
+
return;
|
|
165
|
+
const value = Number(e.target.value);
|
|
166
|
+
video.currentTime = value;
|
|
167
|
+
this._currentTime = value;
|
|
168
|
+
}
|
|
169
|
+
_onVolumeInput(e) {
|
|
170
|
+
const video = this._video;
|
|
171
|
+
if (!video)
|
|
172
|
+
return;
|
|
173
|
+
const value = Number(e.target.value);
|
|
174
|
+
video.volume = value;
|
|
175
|
+
// Adjusting the slider while muted is treated as an implicit unmute, so
|
|
176
|
+
// dragging it back up audibly takes effect instead of appearing frozen.
|
|
177
|
+
if (video.muted && value > 0)
|
|
178
|
+
video.muted = false;
|
|
179
|
+
}
|
|
180
|
+
_onLoadedMetadata() {
|
|
181
|
+
this._duration = this._video?.duration ?? NaN;
|
|
182
|
+
this._errored = false;
|
|
183
|
+
}
|
|
184
|
+
_onTimeUpdate() {
|
|
185
|
+
this._currentTime = this._video?.currentTime ?? 0;
|
|
186
|
+
}
|
|
187
|
+
_onPlay() {
|
|
188
|
+
this._playing = true;
|
|
189
|
+
this.dispatchEvent(new CustomEvent("play", { bubbles: true, composed: true }));
|
|
190
|
+
}
|
|
191
|
+
_onPause() {
|
|
192
|
+
this._playing = false;
|
|
193
|
+
this.dispatchEvent(new CustomEvent("pause", { bubbles: true, composed: true }));
|
|
194
|
+
}
|
|
195
|
+
_onEnded() {
|
|
196
|
+
this._playing = false;
|
|
197
|
+
this.dispatchEvent(new CustomEvent("ended", { bubbles: true, composed: true }));
|
|
198
|
+
}
|
|
199
|
+
_onVolumeChange() {
|
|
200
|
+
const video = this._video;
|
|
201
|
+
if (!video)
|
|
202
|
+
return;
|
|
203
|
+
this._volume = video.volume;
|
|
204
|
+
this._muted = video.muted;
|
|
205
|
+
}
|
|
206
|
+
_onError() {
|
|
207
|
+
this._errored = true;
|
|
208
|
+
}
|
|
209
|
+
render() {
|
|
210
|
+
const duration = this._duration;
|
|
211
|
+
const seekMax = Number.isFinite(duration) && duration > 0 ? duration : 0;
|
|
212
|
+
return html `
|
|
213
|
+
<div class="player" role="group" aria-label=${this.label}>
|
|
214
|
+
<div class="frame">
|
|
215
|
+
<video
|
|
216
|
+
.src=${this.src}
|
|
217
|
+
poster=${this.poster || ""}
|
|
218
|
+
?loop=${this.loop}
|
|
219
|
+
preload=${this.preload}
|
|
220
|
+
@loadedmetadata=${this._onLoadedMetadata}
|
|
221
|
+
@timeupdate=${this._onTimeUpdate}
|
|
222
|
+
@play=${this._onPlay}
|
|
223
|
+
@pause=${this._onPause}
|
|
224
|
+
@ended=${this._onEnded}
|
|
225
|
+
@volumechange=${this._onVolumeChange}
|
|
226
|
+
@error=${this._onError}
|
|
227
|
+
@click=${this._togglePlay}
|
|
228
|
+
></video>
|
|
229
|
+
</div>
|
|
230
|
+
${this._errored
|
|
231
|
+
? html `<span class="error">Unable to load video</span>`
|
|
232
|
+
: html `
|
|
233
|
+
<div class="controls">
|
|
234
|
+
<icon-button
|
|
235
|
+
.icon=${this._playing ? iconPause(18) : iconPlay(18)}
|
|
236
|
+
label=${this._playing ? "Pause" : "Play"}
|
|
237
|
+
@click=${this._togglePlay}
|
|
238
|
+
></icon-button>
|
|
239
|
+
<span class="time">${formatClockDuration(this._currentTime)}</span>
|
|
240
|
+
<input
|
|
241
|
+
class="seek"
|
|
242
|
+
type="range"
|
|
243
|
+
min="0"
|
|
244
|
+
max=${seekMax}
|
|
245
|
+
step="0.1"
|
|
246
|
+
.value=${String(this._currentTime)}
|
|
247
|
+
aria-label="Seek"
|
|
248
|
+
aria-valuetext=${formatClockDuration(this._currentTime)}
|
|
249
|
+
@input=${this._onSeekInput}
|
|
250
|
+
/>
|
|
251
|
+
<span class="time">${formatClockDuration(duration)}</span>
|
|
252
|
+
<icon-button
|
|
253
|
+
.icon=${this._muted || this._volume === 0 ? iconSpeakerXMark(18) : iconSpeakerWave(18)}
|
|
254
|
+
label=${this._muted ? "Unmute" : "Mute"}
|
|
255
|
+
@click=${this._toggleMute}
|
|
256
|
+
></icon-button>
|
|
257
|
+
<input
|
|
258
|
+
class="volume"
|
|
259
|
+
type="range"
|
|
260
|
+
min="0"
|
|
261
|
+
max="1"
|
|
262
|
+
step="0.05"
|
|
263
|
+
.value=${String(this._muted ? 0 : this._volume)}
|
|
264
|
+
aria-label="Volume"
|
|
265
|
+
@input=${this._onVolumeInput}
|
|
266
|
+
/>
|
|
267
|
+
<icon-button
|
|
268
|
+
.icon=${this._fullscreen ? iconArrowsPointingIn(18) : iconArrowsPointingOut(18)}
|
|
269
|
+
label=${this._fullscreen ? "Exit fullscreen" : "Enter fullscreen"}
|
|
270
|
+
@click=${this._toggleFullscreen}
|
|
271
|
+
></icon-button>
|
|
272
|
+
</div>
|
|
273
|
+
`}
|
|
274
|
+
</div>
|
|
275
|
+
`;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
__decorate([
|
|
279
|
+
property()
|
|
280
|
+
], VideoPlayer.prototype, "src", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
property()
|
|
283
|
+
], VideoPlayer.prototype, "poster", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
property()
|
|
286
|
+
], VideoPlayer.prototype, "label", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
property({ type: Boolean })
|
|
289
|
+
], VideoPlayer.prototype, "loop", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
property()
|
|
292
|
+
], VideoPlayer.prototype, "preload", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
state()
|
|
295
|
+
], VideoPlayer.prototype, "_playing", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
state()
|
|
298
|
+
], VideoPlayer.prototype, "_currentTime", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
state()
|
|
301
|
+
], VideoPlayer.prototype, "_duration", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
state()
|
|
304
|
+
], VideoPlayer.prototype, "_volume", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
state()
|
|
307
|
+
], VideoPlayer.prototype, "_muted", void 0);
|
|
308
|
+
__decorate([
|
|
309
|
+
state()
|
|
310
|
+
], VideoPlayer.prototype, "_errored", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
state()
|
|
313
|
+
], VideoPlayer.prototype, "_fullscreen", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
query("video")
|
|
316
|
+
], VideoPlayer.prototype, "_video", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
query(".frame")
|
|
319
|
+
], VideoPlayer.prototype, "_frame", void 0);
|
|
320
|
+
VideoPlayer = __decorate([
|
|
321
|
+
customElement("video-player")
|
|
322
|
+
], VideoPlayer);
|
|
323
|
+
export { VideoPlayer };
|
|
324
|
+
//# sourceMappingURL=video-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-player.js","sourceRoot":"","sources":["../src/video-player.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QA8EL,qCAAqC;QACzB,QAAG,GAAG,EAAE,CAAC;QACrB,iDAAiD;QACrC,WAAM,GAAG,EAAE,CAAC;QACxB,0DAA0D;QAC9C,UAAK,GAAG,cAAc,CAAC;QACnC,8CAA8C;QACjB,SAAI,GAAG,KAAK,CAAC;QAC1C,qCAAqC;QACzB,YAAO,GAAiC,UAAU,CAAC;QAE9C,aAAQ,GAAG,KAAK,CAAC;QACjB,iBAAY,GAAG,CAAC,CAAC;QACjB,cAAS,GAAG,GAAG,CAAC;QAChB,YAAO,GAAG,CAAC,CAAC;Q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AAA;AAhLa;IAAX,QAAQ,EAAE;wCAAU;AAET;IAAX,QAAQ,EAAE;2CAAa;AAEZ;IAAX,QAAQ,EAAE;0CAAwB;AAEN;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAE9B;IAAX,QAAQ,EAAE;4CAAoD;AAE9C;IAAhB,KAAK,EAAE;6CAA0B;AACjB;IAAhB,KAAK,EAAE;iDAA0B;AACjB;IAAhB,KAAK,EAAE;8CAAyB;AAChB;IAAhB,KAAK,EAAE;4CAAqB;AACZ;IAAhB,KAAK,EAAE;2CAAwB;AACf;IAAhB,KAAK,EAAE;6CAA0B;AACjB;IAAhB,KAAK,EAAE;gDAA6B;AAEb;IAAvB,KAAK,CAAC,OAAO,CAAC;2CAAmC;AACzB;IAAxB,KAAK,CAAC,QAAQ,CAAC;2CAAiC;AAlGtC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA+PvB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport { transportRangeStyles } from \"./utils/transport-controls.js\";\nimport { formatClockDuration } from \"./utils/duration.js\";\nimport {\n iconArrowsPointingIn,\n iconArrowsPointingOut,\n iconPause,\n iconPlay,\n iconSpeakerWave,\n iconSpeakerXMark,\n} from \"./icons.js\";\nimport \"./icon-button.js\";\n\n/**\n * Video player wrapping a native `<video>` element (native `controls`\n * disabled) with the same tokenized transport bar as `audio-player` — a\n * play/pause `icon-button`, elapsed/total time, a seekable progress bar, a\n * mute toggle + volume slider — plus a fullscreen toggle. The control bar\n * sits in a persistent strip under the video frame rather than a\n * hover-reveal overlay, so it stays usable for keyboard/touch input without\n * a pointer hover state.\n *\n * @element video-player\n * @fires play - The video started playing.\n * @fires pause - The video was paused.\n * @fires ended - Playback reached the end.\n */\n@customElement(\"video-player\")\nexport class VideoPlayer extends LitElement {\n static override styles = [\n tokens,\n transportRangeStyles,\n css`\n :host {\n display: block;\n }\n .player {\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius, 0.5rem);\n overflow: hidden;\n background: var(--ui-surface, #ffffff);\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 }\n .frame {\n display: flex;\n /* Letterboxing behind the video's own content is a universal video\n convention independent of the surrounding theme — same literal-color\n exception category as this package's white map rings/avatar marks. */\n background: #000000;\n }\n video {\n display: block;\n width: 100%;\n max-height: 30rem;\n object-fit: contain;\n }\n .controls {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n }\n .time {\n flex: 0 0 auto;\n min-width: 2.5rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n color: var(--ui-text-muted, #64748b);\n font-variant-numeric: tabular-nums;\n text-align: center;\n }\n .seek {\n /* Sets its own width (100%) and flex-basis: 0 (not auto) so it\n fills the row's remaining space via flex-grow — an auto basis\n would otherwise derive its hypothetical size from that same\n width:100%, resolved against an indefinite container, and\n collapse the track to 0. */\n flex: 1 1 0%;\n min-width: 0;\n width: 100%;\n }\n .volume {\n flex: 0 0 auto;\n width: 4rem;\n }\n .error {\n padding: 0.5rem 0.75rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n color: var(--ui-danger, #dc2626);\n }\n @media (forced-colors: active) {\n .player {\n border-color: CanvasText;\n }\n }\n `,\n ];\n\n /** URL of the video file to play. */\n @property() src = \"\";\n /** Poster image shown before playback starts. */\n @property() poster = \"\";\n /** Accessible name for the player, e.g. a video title. */\n @property() label = \"Video player\";\n /** Loops playback once it reaches the end. */\n @property({ type: Boolean }) loop = false;\n /** Native `<video preload>` hint. */\n @property() preload: \"none\" | \"metadata\" | \"auto\" = \"metadata\";\n\n @state() private _playing = false;\n @state() private _currentTime = 0;\n @state() private _duration = NaN;\n @state() private _volume = 1;\n @state() private _muted = false;\n @state() private _errored = false;\n @state() private _fullscreen = false;\n\n @query(\"video\") private _video?: HTMLVideoElement;\n @query(\".frame\") private _frame?: HTMLDivElement;\n\n #onFullscreenChange = (): void => {\n this._fullscreen = document.fullscreenElement === this._frame;\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener(\"fullscreenchange\", this.#onFullscreenChange);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"fullscreenchange\", this.#onFullscreenChange);\n }\n\n private _togglePlay(): void {\n const video = this._video;\n if (!video) return;\n if (video.paused) video.play();\n else video.pause();\n }\n\n private _toggleMute(): void {\n const video = this._video;\n if (!video) return;\n video.muted = !video.muted;\n }\n\n private _toggleFullscreen(): void {\n const frame = this._frame;\n if (!frame) return;\n if (document.fullscreenElement === frame) document.exitFullscreen();\n else frame.requestFullscreen();\n }\n\n private _onSeekInput(e: Event): void {\n const video = this._video;\n if (!video) return;\n const value = Number((e.target as HTMLInputElement).value);\n video.currentTime = value;\n this._currentTime = value;\n }\n\n private _onVolumeInput(e: Event): void {\n const video = this._video;\n if (!video) return;\n const value = Number((e.target as HTMLInputElement).value);\n video.volume = value;\n // Adjusting the slider while muted is treated as an implicit unmute, so\n // dragging it back up audibly takes effect instead of appearing frozen.\n if (video.muted && value > 0) video.muted = false;\n }\n\n private _onLoadedMetadata(): void {\n this._duration = this._video?.duration ?? NaN;\n this._errored = false;\n }\n\n private _onTimeUpdate(): void {\n this._currentTime = this._video?.currentTime ?? 0;\n }\n\n private _onPlay(): void {\n this._playing = true;\n this.dispatchEvent(new CustomEvent(\"play\", { bubbles: true, composed: true }));\n }\n\n private _onPause(): void {\n this._playing = false;\n this.dispatchEvent(new CustomEvent(\"pause\", { bubbles: true, composed: true }));\n }\n\n private _onEnded(): void {\n this._playing = false;\n this.dispatchEvent(new CustomEvent(\"ended\", { bubbles: true, composed: true }));\n }\n\n private _onVolumeChange(): void {\n const video = this._video;\n if (!video) return;\n this._volume = video.volume;\n this._muted = video.muted;\n }\n\n private _onError(): void {\n this._errored = true;\n }\n\n override render() {\n const duration = this._duration;\n const seekMax = Number.isFinite(duration) && duration > 0 ? duration : 0;\n return html`\n <div class=\"player\" role=\"group\" aria-label=${this.label}>\n <div class=\"frame\">\n <video\n .src=${this.src}\n poster=${this.poster || \"\"}\n ?loop=${this.loop}\n preload=${this.preload}\n @loadedmetadata=${this._onLoadedMetadata}\n @timeupdate=${this._onTimeUpdate}\n @play=${this._onPlay}\n @pause=${this._onPause}\n @ended=${this._onEnded}\n @volumechange=${this._onVolumeChange}\n @error=${this._onError}\n @click=${this._togglePlay}\n ></video>\n </div>\n ${this._errored\n ? html`<span class=\"error\">Unable to load video</span>`\n : html`\n <div class=\"controls\">\n <icon-button\n .icon=${this._playing ? iconPause(18) : iconPlay(18)}\n label=${this._playing ? \"Pause\" : \"Play\"}\n @click=${this._togglePlay}\n ></icon-button>\n <span class=\"time\">${formatClockDuration(this._currentTime)}</span>\n <input\n class=\"seek\"\n type=\"range\"\n min=\"0\"\n max=${seekMax}\n step=\"0.1\"\n .value=${String(this._currentTime)}\n aria-label=\"Seek\"\n aria-valuetext=${formatClockDuration(this._currentTime)}\n @input=${this._onSeekInput}\n />\n <span class=\"time\">${formatClockDuration(duration)}</span>\n <icon-button\n .icon=${this._muted || this._volume === 0 ? iconSpeakerXMark(18) : iconSpeakerWave(18)}\n label=${this._muted ? \"Unmute\" : \"Mute\"}\n @click=${this._toggleMute}\n ></icon-button>\n <input\n class=\"volume\"\n type=\"range\"\n min=\"0\"\n max=\"1\"\n step=\"0.05\"\n .value=${String(this._muted ? 0 : this._volume)}\n aria-label=\"Volume\"\n @input=${this._onVolumeInput}\n />\n <icon-button\n .icon=${this._fullscreen ? iconArrowsPointingIn(18) : iconArrowsPointingOut(18)}\n label=${this._fullscreen ? \"Exit fullscreen\" : \"Enter fullscreen\"}\n @click=${this._toggleFullscreen}\n ></icon-button>\n </div>\n `}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"video-player\": VideoPlayer;\n }\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# `<audio-player>`
|
|
2
|
+
|
|
3
|
+
Compact audio player wrapping a native `<audio>` element (kept off-screen
|
|
4
|
+
for its decoding/playback engine and free `timeupdate`/`loadedmetadata`
|
|
5
|
+
events) behind a tokenized transport bar: a play/pause `icon-button`,
|
|
6
|
+
elapsed/total time, a seekable progress bar, and a mute toggle + volume
|
|
7
|
+
slider. The seek/volume sliders are native `<input type="range">`
|
|
8
|
+
elements (see `utils/transport-controls.ts`) for free keyboard and
|
|
9
|
+
pointer support, per this package's "native semantics before custom ARIA"
|
|
10
|
+
rule.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import "@f-ewald/components/audio-player.js";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<audio-player src="/episode-12.mp3" label="Episode 12"></audio-player>
|
|
22
|
+
<script type="module">
|
|
23
|
+
document.querySelector("audio-player").addEventListener("ended", () => {
|
|
24
|
+
console.log("playback finished");
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Attributes / properties
|
|
30
|
+
|
|
31
|
+
| Property | Attribute | Type | Default | Description |
|
|
32
|
+
| --- | --- | --- | --- | --- |
|
|
33
|
+
| `src` | `src` | `string` | `""` | URL of the audio file to play. |
|
|
34
|
+
| `label` | `label` | `string` | `"Audio player"` | Accessible name for the player, e.g. a track/episode title. |
|
|
35
|
+
| `loop` | `loop` | `boolean` | `false` | Loops playback once it reaches the end. |
|
|
36
|
+
| `preload` | `preload` | `"none" | "metadata" | "auto"` | `"metadata"` | Native `<audio preload>` hint. |
|
|
37
|
+
|
|
38
|
+
## Events
|
|
39
|
+
|
|
40
|
+
| Event | Description |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `play` | The audio started playing. |
|
|
43
|
+
| `pause` | The audio was paused. |
|
|
44
|
+
| `ended` | Playback reached the end. |
|
|
45
|
+
|
|
46
|
+
## Slots
|
|
47
|
+
|
|
48
|
+
_None._
|
|
49
|
+
|
|
50
|
+
## CSS custom properties
|
|
51
|
+
|
|
52
|
+
| Custom property |
|
|
53
|
+
| --- |
|
|
54
|
+
| `--ui-border` |
|
|
55
|
+
| `--ui-danger` |
|
|
56
|
+
| `--ui-font` |
|
|
57
|
+
| `--ui-font-size-sm` |
|
|
58
|
+
| `--ui-radius` |
|
|
59
|
+
| `--ui-surface` |
|
|
60
|
+
| `--ui-text-muted` |
|
package/docs/button-group.md
CHANGED
|
@@ -6,7 +6,16 @@ choices (a view switcher, a theme picker) where the *currently selected*
|
|
|
6
6
|
option should read as visually "pressed," not just checked. For many
|
|
7
7
|
short, individually pill-shaped choices, use `radio-pills` instead. Wraps
|
|
8
8
|
native radio inputs for keyboard/a11y and fires `change` rather than
|
|
9
|
-
relying on form submission.
|
|
9
|
+
relying on form submission. Set `size="sm"` for a compact strip one step
|
|
10
|
+
below the default, matching `ui-button`'s `sm` size.
|
|
11
|
+
|
|
12
|
+
The checked segment reads `--ui-button-background`/`-hover`/`-active`,
|
|
13
|
+
same as `ui-button`'s `primary` variant. Unchecked segments are treated as
|
|
14
|
+
`ui-button`'s `secondary` variant: they read the shared
|
|
15
|
+
`--ui-button-secondary-background`/`-active` (rest/pressed) so a gradient
|
|
16
|
+
theme applies consistently, but use the shared `--ui-button-secondary-surface-muted`
|
|
17
|
+
(also used by `pagination-nav`) for hover, since — unlike `secondary` — an
|
|
18
|
+
unchecked segment already paints `--ui-surface-muted` on hover by default.
|
|
10
19
|
|
|
11
20
|
## Install
|
|
12
21
|
|
|
@@ -37,6 +46,7 @@ import "@f-ewald/components/button-group.js";
|
|
|
37
46
|
| `value` | `value` | `string` | `""` | Currently selected value. |
|
|
38
47
|
| `disabled` | `disabled` | `boolean` | `false` | Disables every native radio in the group. |
|
|
39
48
|
| `iconOnly` | `icon-only` | `boolean` | `false` | Hides labels visually (icons only) while keeping them as the accessible name. |
|
|
49
|
+
| `size` | `size` | `"sm" | "md"` | `"md"` | Size — `sm` reduces segment height/padding/font-size one step below the default. |
|
|
40
50
|
|
|
41
51
|
## Events
|
|
42
52
|
|
|
@@ -53,9 +63,16 @@ _None._
|
|
|
53
63
|
| Custom property |
|
|
54
64
|
| --- |
|
|
55
65
|
| `--ui-border` |
|
|
66
|
+
| `--ui-button-background` |
|
|
67
|
+
| `--ui-button-highlight` |
|
|
68
|
+
| `--ui-button-secondary-background` |
|
|
69
|
+
| `--ui-button-secondary-background-active` |
|
|
70
|
+
| `--ui-button-secondary-surface-muted` |
|
|
71
|
+
| `--ui-button-text-shadow` |
|
|
56
72
|
| `--ui-focus-ring` |
|
|
57
73
|
| `--ui-font` |
|
|
58
74
|
| `--ui-font-size-sm` |
|
|
75
|
+
| `--ui-font-size-xs` |
|
|
59
76
|
| `--ui-font-weight-medium` |
|
|
60
77
|
| `--ui-line-height-tight` |
|
|
61
78
|
| `--ui-on-accent` |
|