@f-ewald/components 1.23.1 → 1.25.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 +13 -0
- package/custom-elements.json +1882 -595
- 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 +12 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +12 -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/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 +38 -1
- package/dist/tokens.d.ts +16 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +93 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.d.ts +18 -0
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +50 -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 +6 -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 +34 -0
- package/docs/video-player.md +59 -0
- package/llms.txt +165 -23
- package/package.json +1 -1
|
@@ -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,EAA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;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` |
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# `<comment-composer>`
|
|
2
|
+
|
|
3
|
+
GitHub/Slack-style comment composer: a one-line text field that expands
|
|
4
|
+
into a multi-line textarea with a bottom-right Cancel/Submit footer
|
|
5
|
+
(`form-actions`) as soon as it's focused or clicked. Submitting fires
|
|
6
|
+
`submit` with the trimmed value, then clears the field and collapses back
|
|
7
|
+
to one line — it's meant for posting one comment at a time, not editing a
|
|
8
|
+
persistent value in place (see `editable-text` for that). Canceling (the
|
|
9
|
+
Cancel button or `Escape`) discards the draft and collapses without
|
|
10
|
+
firing `submit`. Clicking away (blur) does neither — the composer stays
|
|
11
|
+
expanded until the user explicitly submits or cancels. `Cmd`/`Ctrl`+`Enter`
|
|
12
|
+
submits from the textarea, matching `editable-text`'s multiline shortcut.
|
|
13
|
+
Purely token-styled (no bespoke colors), so it's themeable via the same
|
|
14
|
+
`--ui-*` custom properties as every other value-entry field.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import "@f-ewald/components/comment-composer.js";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<comment-composer placeholder="Add a comment…"></comment-composer>
|
|
26
|
+
<script type="module">
|
|
27
|
+
document.querySelector("comment-composer").addEventListener("submit", (e) => {
|
|
28
|
+
postComment(e.detail.value);
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Attributes / properties
|
|
34
|
+
|
|
35
|
+
| Property | Attribute | Type | Default | Description |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| `value` | `value` | `string` | `""` | Committed value shown in the collapsed one-line field. |
|
|
38
|
+
| `placeholder` | `placeholder` | `string` | `"Add a comment…"` | Placeholder text shown when empty. |
|
|
39
|
+
| `label` | `label` | `string` | `"Comment"` | Accessible name applied to the input/textarea. |
|
|
40
|
+
| `rows` | `rows` | `number` | `4` | Visible row count once expanded. |
|
|
41
|
+
| `submitLabel` | `submit-label` | `string` | `"Submit"` | Label for the primary submit button. |
|
|
42
|
+
| `cancelLabel` | `cancel-label` | `string` | `"Cancel"` | Label for the secondary cancel button. |
|
|
43
|
+
| `disabled` | `disabled` | `boolean` | `false` | Disables the field entirely. |
|
|
44
|
+
|
|
45
|
+
## Events
|
|
46
|
+
|
|
47
|
+
| Event | Description |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `cancel` | User discarded the draft via the Cancel button or `Escape`. |
|
|
50
|
+
| `submit` | User submitted a non-empty comment; detail: `{ value: string }`. |
|
|
51
|
+
|
|
52
|
+
## Slots
|
|
53
|
+
|
|
54
|
+
_None._
|
|
55
|
+
|
|
56
|
+
## CSS custom properties
|
|
57
|
+
|
|
58
|
+
| Custom property |
|
|
59
|
+
| --- |
|
|
60
|
+
| `--ui-border` |
|
|
61
|
+
| `--ui-focus-ring` |
|
|
62
|
+
| `--ui-font` |
|
|
63
|
+
| `--ui-font-size` |
|
|
64
|
+
| `--ui-line-height-normal` |
|
|
65
|
+
| `--ui-radius` |
|
|
66
|
+
| `--ui-radius-sm` |
|
|
67
|
+
| `--ui-surface` |
|
|
68
|
+
| `--ui-text` |
|
package/docs/confirm-dialog.md
CHANGED
|
@@ -4,7 +4,8 @@ Reusable confirmation dialog: overlay + centered card with a slotted body,
|
|
|
4
4
|
an optional error line, and Cancel/Confirm actions. Instant `display:none`
|
|
5
5
|
→ `display:flex` toggle (no transitions). Fires `confirm`/`cancel`
|
|
6
6
|
(bubbling, composed) instead of owning any deletion logic itself —
|
|
7
|
-
callers stay in charge of the request.
|
|
7
|
+
callers stay in charge of the request. Set `size="sm"` for compact
|
|
8
|
+
actions one step below the default, matching `ui-button`'s `sm` size.
|
|
8
9
|
|
|
9
10
|
## Install
|
|
10
11
|
|
|
@@ -30,6 +31,7 @@ import "@f-ewald/components/confirm-dialog.js";
|
|
|
30
31
|
| `danger` | `danger` | `boolean` | `true` | Danger (red) vs. primary (indigo) styling for the confirm button. |
|
|
31
32
|
| `busy` | `busy` | `boolean` | `false` | Shows a spinner and disables both buttons while a request is in flight. |
|
|
32
33
|
| `error` | `error` | `string | null` | `null` | Inline error line shown below the body, or null for none. |
|
|
34
|
+
| `size` | `size` | `"sm" | "md"` | `"md"` | Size — `sm` reduces both action buttons' height/padding/font-size one step below the default. |
|
|
33
35
|
|
|
34
36
|
## Events
|
|
35
37
|
|
|
@@ -49,12 +51,28 @@ import "@f-ewald/components/confirm-dialog.js";
|
|
|
49
51
|
| Custom property |
|
|
50
52
|
| --- |
|
|
51
53
|
| `--ui-border` |
|
|
54
|
+
| `--ui-button-background` |
|
|
55
|
+
| `--ui-button-background-active` |
|
|
56
|
+
| `--ui-button-background-hover` |
|
|
57
|
+
| `--ui-button-border` |
|
|
58
|
+
| `--ui-button-danger-background` |
|
|
59
|
+
| `--ui-button-danger-background-active` |
|
|
60
|
+
| `--ui-button-danger-background-hover` |
|
|
61
|
+
| `--ui-button-danger-border` |
|
|
62
|
+
| `--ui-button-highlight` |
|
|
63
|
+
| `--ui-button-secondary-background` |
|
|
64
|
+
| `--ui-button-secondary-background-active` |
|
|
65
|
+
| `--ui-button-secondary-background-hover` |
|
|
66
|
+
| `--ui-button-secondary-border` |
|
|
67
|
+
| `--ui-button-secondary-border-hover` |
|
|
68
|
+
| `--ui-button-text-shadow` |
|
|
52
69
|
| `--ui-danger` |
|
|
53
70
|
| `--ui-danger-hover` |
|
|
54
71
|
| `--ui-focus-ring` |
|
|
55
72
|
| `--ui-font` |
|
|
56
73
|
| `--ui-font-size` |
|
|
57
74
|
| `--ui-font-size-sm` |
|
|
75
|
+
| `--ui-font-size-xs` |
|
|
58
76
|
| `--ui-font-weight-medium` |
|
|
59
77
|
| `--ui-line-height-normal` |
|
|
60
78
|
| `--ui-line-height-tight` |
|
package/docs/dropdown-button.md
CHANGED
|
@@ -10,7 +10,8 @@ primary-filled button with a label and a rotating chevron), `text-icon`
|
|
|
10
10
|
(the same, with `icon` ahead of the label), and `icon` (a borderless,
|
|
11
11
|
square, low-emphasis icon target in the style of `icon-button` — the
|
|
12
12
|
classic "three-dot"/overflow menu, where `label` becomes the accessible
|
|
13
|
-
name rather than visible text).
|
|
13
|
+
name rather than visible text). Set `size="sm"` for a compact trigger one
|
|
14
|
+
step below the default, matching `ui-button`'s `sm` size.
|
|
14
15
|
|
|
15
16
|
## Install
|
|
16
17
|
|
|
@@ -50,6 +51,7 @@ import "@f-ewald/components/dropdown-button.js";
|
|
|
50
51
|
| `disabled` | `disabled` | `boolean` | `false` | Disables the trigger, preventing the menu from opening. |
|
|
51
52
|
| `variant` | `variant` | `DropdownButtonVariant` | `"text"` | Trigger presentation: label only, icon only, or icon + label. |
|
|
52
53
|
| `icon` | _(JS property only)_ | `TemplateResult | null` | `null` | Icon template rendered by the `icon` and `text-icon` variants. |
|
|
54
|
+
| `size` | `size` | `"sm" | "md"` | `"md"` | Size — `sm` reduces the trigger's height/padding/font-size one step below the default. |
|
|
53
55
|
|
|
54
56
|
## Events
|
|
55
57
|
|
|
@@ -66,11 +68,18 @@ _None._
|
|
|
66
68
|
| Custom property |
|
|
67
69
|
| --- |
|
|
68
70
|
| `--ui-border` |
|
|
71
|
+
| `--ui-button-background` |
|
|
72
|
+
| `--ui-button-background-active` |
|
|
73
|
+
| `--ui-button-background-hover` |
|
|
74
|
+
| `--ui-button-border` |
|
|
75
|
+
| `--ui-button-highlight` |
|
|
76
|
+
| `--ui-button-text-shadow` |
|
|
69
77
|
| `--ui-danger` |
|
|
70
78
|
| `--ui-danger-hover` |
|
|
71
79
|
| `--ui-focus-ring` |
|
|
72
80
|
| `--ui-font` |
|
|
73
81
|
| `--ui-font-size-sm` |
|
|
82
|
+
| `--ui-font-size-xs` |
|
|
74
83
|
| `--ui-font-weight-medium` |
|
|
75
84
|
| `--ui-line-height-tight` |
|
|
76
85
|
| `--ui-on-accent` |
|
package/docs/icons.md
CHANGED
|
@@ -19,6 +19,7 @@ const icon = iconPencil(16); // 16px, defaults shown below if omitted
|
|
|
19
19
|
| `iconArrowPath` | 12px | Refresh actions, or an animated busy/loading spinner. |
|
|
20
20
|
| `iconArrowRight` | 12px | "Continue" or forward-progressing actions, e.g. a compact next-step arrow. |
|
|
21
21
|
| `iconArrowRightOnRectangle` | 16px | Logout/sign-out actions. |
|
|
22
|
+
| `iconArrowsPointingIn` | 16px | "Exit fullscreen" actions; pair with iconArrowsPointingOut for entering fullscreen. |
|
|
22
23
|
| `iconArrowsPointingOut` | 16px | "Expand" or "view fullscreen" actions. |
|
|
23
24
|
| `iconArrowsRightLeft` | 16px | Swap, exchange, or compare actions between two items. |
|
|
24
25
|
| `iconArrowTopRightOnSquare` | 16px | Links that open in a new tab/window, or navigate to an external site. |
|
|
@@ -53,13 +54,18 @@ const icon = iconPencil(16); // 16px, defaults shown below if omitted
|
|
|
53
54
|
| `iconMap` | 16px | A map-view toggle, or to represent map/geographic content. |
|
|
54
55
|
| `iconMapPin` | 16px | A location, address, or map marker. |
|
|
55
56
|
| `iconMoon` | 16px | A dark-theme toggle, or to represent night/dark mode. |
|
|
57
|
+
| `iconPause` | 18px | "Pause" transport actions, e.g. audio-player/video-player's playing state. |
|
|
56
58
|
| `iconPencil` | 16px | Edit actions, e.g. an edit icon-button or inline edit toggle. |
|
|
59
|
+
| `iconPlay` | 18px | "Play" transport actions, e.g. audio-player/video-player's paused state. |
|
|
57
60
|
| `iconPlus` | 16px | "Add new" actions, e.g. creating a new item or row. |
|
|
58
61
|
| `iconPuzzlePiece` | 18px | Plugins, integrations, or extensible/add-on features. |
|
|
59
62
|
| `iconQuestionMarkCircle` | 20px | Help, tooltips, or "learn more" affordances. |
|
|
60
63
|
| `iconQueueList` | 16px | Queues, backlogs, or ordered work-item lists. |
|
|
61
64
|
| `iconShieldCheck` | 16px | Verified, secure, or trusted states. |
|
|
62
65
|
| `iconShieldExclamation` | 16px | Security warnings, or at-risk/compromised states. |
|
|
66
|
+
| `iconSparkles` | 16px | A gradient-theme toggle, or to represent a decorative/enhanced visual style. |
|
|
67
|
+
| `iconSpeakerWave` | 18px | An unmuted volume control, e.g. audio-player/video-player's mute toggle. |
|
|
68
|
+
| `iconSpeakerXMark` | 18px | A muted volume state; pair with iconSpeakerWave for the unmuted state. |
|
|
63
69
|
| `iconSquares2x2` | 18px | A grid or kanban-view toggle, or to represent card/tile layouts. |
|
|
64
70
|
| `iconSun` | 16px | A light-theme toggle, or to represent daytime/light mode. |
|
|
65
71
|
| `iconTag` | 16px | Tags, labels, or categorical metadata. |
|