@f-ewald/components 1.38.0 → 1.40.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 +48 -0
- package/custom-elements.json +1052 -131
- package/dist/address-autocomplete.js +2 -2
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/app-shell.js +4 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/app-sidebar.js +2 -2
- package/dist/app-sidebar.js.map +1 -1
- package/dist/audio-player.js +1 -1
- package/dist/audio-player.js.map +1 -1
- package/dist/autocomplete-input.js +2 -2
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/breadcrumb-nav.d.ts +69 -0
- package/dist/breadcrumb-nav.d.ts.map +1 -0
- package/dist/breadcrumb-nav.js +235 -0
- package/dist/breadcrumb-nav.js.map +1 -0
- package/dist/button-group.js +2 -2
- package/dist/button-group.js.map +1 -1
- package/dist/calendar-day.js +3 -3
- package/dist/calendar-day.js.map +1 -1
- package/dist/calendar-month.d.ts.map +1 -1
- package/dist/calendar-month.js +4 -1
- package/dist/calendar-month.js.map +1 -1
- package/dist/calendar-week.js +4 -4
- package/dist/calendar-week.js.map +1 -1
- package/dist/chat-message.js +1 -1
- package/dist/chat-message.js.map +1 -1
- package/dist/comment-composer.js +1 -1
- package/dist/comment-composer.js.map +1 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +5 -2
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/content-divider.js +1 -1
- package/dist/content-divider.js.map +1 -1
- package/dist/cron-schedule.d.ts.map +1 -1
- package/dist/cron-schedule.js +6 -5
- package/dist/cron-schedule.js.map +1 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +3 -2
- package/dist/data-table.js.map +1 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +4 -2
- package/dist/dropdown-button.js.map +1 -1
- package/dist/editable-text.js +1 -1
- package/dist/editable-text.js.map +1 -1
- package/dist/empty-state.d.ts +42 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +172 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/form-field.js +1 -1
- package/dist/form-field.js.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/form-select.js.map +1 -1
- package/dist/frame-box.js +1 -1
- package/dist/frame-box.js.map +1 -1
- package/dist/fullscreen-button.js +1 -1
- package/dist/fullscreen-button.js.map +1 -1
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/kanban-card.js +1 -1
- package/dist/kanban-card.js.map +1 -1
- package/dist/kanban-column.js +3 -3
- package/dist/kanban-column.js.map +1 -1
- package/dist/kbd-hint.d.ts.map +1 -1
- package/dist/kbd-hint.js +2 -1
- package/dist/kbd-hint.js.map +1 -1
- package/dist/link-card.js +1 -1
- package/dist/link-card.js.map +1 -1
- package/dist/markdown-view.js +3 -3
- package/dist/markdown-view.js.map +1 -1
- package/dist/modal-dialog.js +1 -1
- package/dist/modal-dialog.js.map +1 -1
- package/dist/multi-select.js +5 -5
- package/dist/multi-select.js.map +1 -1
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +5 -1
- package/dist/pagination-nav.js.map +1 -1
- package/dist/photo-gallery.js +1 -1
- package/dist/photo-gallery.js.map +1 -1
- package/dist/popover-panel.d.ts.map +1 -1
- package/dist/popover-panel.js +4 -2
- package/dist/popover-panel.js.map +1 -1
- package/dist/progress-bar.d.ts.map +1 -1
- package/dist/progress-bar.js +1 -0
- package/dist/progress-bar.js.map +1 -1
- package/dist/radio-cards.js +1 -1
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.js +1 -1
- package/dist/radio-pills.js.map +1 -1
- package/dist/reveal-button.js +1 -1
- package/dist/reveal-button.js.map +1 -1
- package/dist/scroll-to-bottom.js +1 -1
- package/dist/scroll-to-bottom.js.map +1 -1
- package/dist/scroll-to-top.js +1 -1
- package/dist/scroll-to-top.js.map +1 -1
- package/dist/skip-link.d.ts +30 -0
- package/dist/skip-link.d.ts.map +1 -0
- package/dist/skip-link.js +136 -0
- package/dist/skip-link.js.map +1 -0
- package/dist/slide-panel.js +1 -1
- package/dist/slide-panel.js.map +1 -1
- package/dist/spec-list.d.ts +49 -0
- package/dist/spec-list.d.ts.map +1 -0
- package/dist/spec-list.js +168 -0
- package/dist/spec-list.js.map +1 -0
- package/dist/stat-meter.d.ts.map +1 -1
- package/dist/stat-meter.js +1 -0
- package/dist/stat-meter.js.map +1 -1
- package/dist/tab-bar.js +1 -1
- package/dist/tab-bar.js.map +1 -1
- package/dist/text-area.js +1 -1
- package/dist/text-area.js.map +1 -1
- package/dist/tile-grid.js +1 -1
- package/dist/tile-grid.js.map +1 -1
- package/dist/tokens.css +42 -1
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +132 -0
- package/dist/tokens.js.map +1 -1
- package/dist/tree-view.js +2 -2
- package/dist/tree-view.js.map +1 -1
- package/dist/ui-admonition.js +1 -1
- package/dist/ui-admonition.js.map +1 -1
- package/dist/ui-button.js +1 -1
- package/dist/ui-button.js.map +1 -1
- package/dist/ui-checkbox.d.ts +10 -1
- package/dist/ui-checkbox.d.ts.map +1 -1
- package/dist/ui-checkbox.js +11 -2
- package/dist/ui-checkbox.js.map +1 -1
- package/dist/video-player.js +1 -1
- package/dist/video-player.js.map +1 -1
- package/dist/vote-control.d.ts +40 -0
- package/dist/vote-control.d.ts.map +1 -0
- package/dist/vote-control.js +311 -0
- package/dist/vote-control.js.map +1 -0
- package/docs/address-autocomplete.md +1 -0
- package/docs/app-shell.md +1 -0
- package/docs/app-sidebar.md +1 -0
- package/docs/audio-player.md +1 -0
- package/docs/autocomplete-input.md +1 -0
- package/docs/breadcrumb-nav.md +70 -0
- package/docs/button-group.md +1 -0
- package/docs/calendar-day.md +1 -0
- package/docs/calendar-month.md +1 -0
- package/docs/calendar-week.md +1 -0
- package/docs/chat-message.md +1 -0
- package/docs/comment-composer.md +1 -0
- package/docs/confirm-dialog.md +1 -0
- package/docs/content-divider.md +1 -0
- package/docs/cron-schedule.md +2 -0
- package/docs/data-table.md +2 -0
- package/docs/design-language.md +57 -5
- package/docs/dropdown-button.md +1 -0
- package/docs/editable-text.md +1 -0
- package/docs/empty-state.md +55 -0
- package/docs/form-field.md +1 -0
- package/docs/form-select.md +1 -0
- package/docs/frame-box.md +1 -0
- package/docs/fullscreen-button.md +1 -0
- package/docs/icons.md +1 -0
- package/docs/kanban-card.md +1 -0
- package/docs/kanban-column.md +1 -0
- package/docs/kbd-hint.md +1 -0
- package/docs/link-card.md +1 -0
- package/docs/markdown-view.md +1 -0
- package/docs/modal-dialog.md +1 -0
- package/docs/multi-select.md +1 -0
- package/docs/pagination-nav.md +2 -0
- package/docs/photo-gallery.md +1 -0
- package/docs/popover-panel.md +1 -0
- package/docs/progress-bar.md +1 -0
- package/docs/radio-cards.md +1 -0
- package/docs/radio-pills.md +1 -0
- package/docs/reveal-button.md +1 -0
- package/docs/scroll-to-bottom.md +1 -0
- package/docs/scroll-to-top.md +1 -0
- package/docs/skip-link.md +54 -0
- package/docs/slide-panel.md +1 -0
- package/docs/spec-list.md +71 -0
- package/docs/stat-meter.md +1 -0
- package/docs/tab-bar.md +1 -0
- package/docs/text-area.md +1 -0
- package/docs/tile-grid.md +1 -0
- package/docs/tree-view.md +1 -0
- package/docs/ui-admonition.md +1 -0
- package/docs/ui-button.md +1 -0
- package/docs/ui-checkbox.md +13 -2
- package/docs/video-player.md +1 -0
- package/docs/vote-control.md +73 -0
- package/llms.txt +210 -49
- package/package.json +1 -1
package/dist/video-player.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-player.js","sourceRoot":"","sources":["../src/video-player.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B;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"]}
|
|
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;A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xB,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: var(--ui-border-width, 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,40 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { PropertyValues } from "lit";
|
|
3
|
+
/**
|
|
4
|
+
* An up/down vote widget with a live score readout — the "vote an entry up or
|
|
5
|
+
* down toward a promotion threshold" pattern from a public register site,
|
|
6
|
+
* where one member casts a single vote that can be changed or withdrawn at any
|
|
7
|
+
* time. Two native `<button>`s flank a score; the button matching the user's
|
|
8
|
+
* own cast `vote` reads as pressed (`aria-pressed`), and clicking it again
|
|
9
|
+
* withdraws the vote. Set an optional `target` to render a thin progress meter
|
|
10
|
+
* toward the promotion threshold beneath (vertical) or beside (horizontal) the
|
|
11
|
+
* buttons.
|
|
12
|
+
*
|
|
13
|
+
* @element vote-control
|
|
14
|
+
* @fires vote-change - The user cast, switched, or withdrew their vote;
|
|
15
|
+
* detail: { vote: "up" | "down" | null, value: number }.
|
|
16
|
+
*/
|
|
17
|
+
export declare class VoteControl extends LitElement {
|
|
18
|
+
#private;
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
/** The current net score shown between the buttons. */
|
|
21
|
+
value: number;
|
|
22
|
+
/** This user's own cast vote, or `null` if they have not voted. Reflected so CSS can style the pressed button. */
|
|
23
|
+
vote: "up" | "down" | null;
|
|
24
|
+
/** Disables both buttons and dims the control. */
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
/** Layout — `vertical` is the compact stacked box (default); `horizontal` is the wide inline variant. */
|
|
27
|
+
orientation: "vertical" | "horizontal";
|
|
28
|
+
/** Promotion threshold. When > 0, a thin progress meter toward it renders; when 0 (default) no meter renders and no space is reserved for it. */
|
|
29
|
+
target: number;
|
|
30
|
+
/** Accessible label naming the vote group. */
|
|
31
|
+
label: string;
|
|
32
|
+
updated(changed: PropertyValues<this>): void;
|
|
33
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface HTMLElementTagNameMap {
|
|
37
|
+
"vote-control": VoteControl;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=vote-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vote-control.d.ts","sourceRoot":"","sources":["../src/vote-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK1C;;;;;;;;;;;;;GAaG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,4BA0KpB;IAEF,uDAAuD;IACZ,KAAK,SAAK;IAErD,kHAAkH;IACrF,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAQ;IAE/D,kDAAkD;IACN,QAAQ,UAAS;IAE7D,yGAAyG;IAC5E,WAAW,EAAE,UAAU,GAAG,YAAY,CAAc;IAEjF,iJAAiJ;IACrH,MAAM,SAAK;IAEvC,8CAA8C;IAClC,KAAK,SAAU;IAElB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,QAI7C;IA4BQ,MAAM,yCA8Cd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,311 @@
|
|
|
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, nothing } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { iconChevronDown, iconChevronUp } from "./icons.js";
|
|
10
|
+
import { tokens } from "./tokens.js";
|
|
11
|
+
/**
|
|
12
|
+
* An up/down vote widget with a live score readout — the "vote an entry up or
|
|
13
|
+
* down toward a promotion threshold" pattern from a public register site,
|
|
14
|
+
* where one member casts a single vote that can be changed or withdrawn at any
|
|
15
|
+
* time. Two native `<button>`s flank a score; the button matching the user's
|
|
16
|
+
* own cast `vote` reads as pressed (`aria-pressed`), and clicking it again
|
|
17
|
+
* withdraws the vote. Set an optional `target` to render a thin progress meter
|
|
18
|
+
* toward the promotion threshold beneath (vertical) or beside (horizontal) the
|
|
19
|
+
* buttons.
|
|
20
|
+
*
|
|
21
|
+
* @element vote-control
|
|
22
|
+
* @fires vote-change - The user cast, switched, or withdrew their vote;
|
|
23
|
+
* detail: { vote: "up" | "down" | null, value: number }.
|
|
24
|
+
*/
|
|
25
|
+
let VoteControl = class VoteControl extends LitElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
/** The current net score shown between the buttons. */
|
|
29
|
+
this.value = 0;
|
|
30
|
+
/** This user's own cast vote, or `null` if they have not voted. Reflected so CSS can style the pressed button. */
|
|
31
|
+
this.vote = null;
|
|
32
|
+
/** Disables both buttons and dims the control. */
|
|
33
|
+
this.disabled = false;
|
|
34
|
+
/** Layout — `vertical` is the compact stacked box (default); `horizontal` is the wide inline variant. */
|
|
35
|
+
this.orientation = "vertical";
|
|
36
|
+
/** Promotion threshold. When > 0, a thin progress meter toward it renders; when 0 (default) no meter renders and no space is reserved for it. */
|
|
37
|
+
this.target = 0;
|
|
38
|
+
/** Accessible label naming the vote group. */
|
|
39
|
+
this.label = "Vote";
|
|
40
|
+
}
|
|
41
|
+
static { this.styles = [
|
|
42
|
+
tokens,
|
|
43
|
+
css `
|
|
44
|
+
:host {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
font-family: var(
|
|
47
|
+
--ui-font,
|
|
48
|
+
ui-sans-serif,
|
|
49
|
+
system-ui,
|
|
50
|
+
sans-serif,
|
|
51
|
+
"Apple Color Emoji",
|
|
52
|
+
"Segoe UI Emoji",
|
|
53
|
+
"Segoe UI Symbol",
|
|
54
|
+
"Noto Color Emoji"
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
.control {
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
61
|
+
border-radius: var(--ui-radius, 0.5rem);
|
|
62
|
+
background: var(--ui-surface, #ffffff);
|
|
63
|
+
}
|
|
64
|
+
/* Vertical (default): stacked box — up, score, down, optional meter. */
|
|
65
|
+
:host([orientation="vertical"]) .control {
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: stretch;
|
|
68
|
+
padding: 0.25rem;
|
|
69
|
+
gap: 0.25rem;
|
|
70
|
+
}
|
|
71
|
+
/* Horizontal: wide inline row — up, score, down, optional meter beside. */
|
|
72
|
+
:host([orientation="horizontal"]) .control {
|
|
73
|
+
flex-direction: row;
|
|
74
|
+
align-items: center;
|
|
75
|
+
padding: 0.25rem 0.5rem;
|
|
76
|
+
gap: 0.5rem;
|
|
77
|
+
}
|
|
78
|
+
.buttons {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
gap: 0.25rem;
|
|
83
|
+
}
|
|
84
|
+
:host([orientation="vertical"]) .buttons {
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
}
|
|
87
|
+
:host([orientation="horizontal"]) .buttons {
|
|
88
|
+
flex-direction: row;
|
|
89
|
+
}
|
|
90
|
+
.vote-btn {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
width: 2rem;
|
|
95
|
+
height: 2rem;
|
|
96
|
+
padding: 0;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
border: none;
|
|
99
|
+
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
100
|
+
background: none;
|
|
101
|
+
color: var(--ui-text-muted, #64748b);
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
}
|
|
104
|
+
.vote-btn:hover:not(:disabled) {
|
|
105
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
106
|
+
color: var(--ui-text, #0f172a);
|
|
107
|
+
}
|
|
108
|
+
.vote-btn.up[aria-pressed="true"] {
|
|
109
|
+
color: var(--ui-success, #16a34a);
|
|
110
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
111
|
+
}
|
|
112
|
+
.vote-btn.down[aria-pressed="true"] {
|
|
113
|
+
color: var(--ui-danger, #dc2626);
|
|
114
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
115
|
+
}
|
|
116
|
+
.vote-btn:disabled {
|
|
117
|
+
cursor: not-allowed;
|
|
118
|
+
opacity: 0.5;
|
|
119
|
+
}
|
|
120
|
+
.vote-btn:focus-visible {
|
|
121
|
+
outline: none;
|
|
122
|
+
box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
|
|
123
|
+
}
|
|
124
|
+
.score {
|
|
125
|
+
min-width: 2rem;
|
|
126
|
+
text-align: center;
|
|
127
|
+
font-size: var(--ui-font-size-lg, 1rem);
|
|
128
|
+
font-weight: var(--ui-font-weight-semibold, 600);
|
|
129
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
130
|
+
color: var(--ui-text, #0f172a);
|
|
131
|
+
font-variant-numeric: var(--ui-numeric, normal);
|
|
132
|
+
}
|
|
133
|
+
.meter {
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
gap: 0.25rem;
|
|
137
|
+
}
|
|
138
|
+
:host([orientation="horizontal"]) .meter {
|
|
139
|
+
min-width: 4rem;
|
|
140
|
+
}
|
|
141
|
+
.track {
|
|
142
|
+
display: block;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 0.25rem;
|
|
145
|
+
border-radius: var(--ui-radius-pill, 9999px);
|
|
146
|
+
background: var(--ui-surface-muted, #f8fafc);
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
}
|
|
149
|
+
.fill {
|
|
150
|
+
display: block;
|
|
151
|
+
height: 100%;
|
|
152
|
+
background: var(--ui-button-accent, var(--ui-primary, #4f46e5));
|
|
153
|
+
transition: width 200ms ease;
|
|
154
|
+
}
|
|
155
|
+
.caption {
|
|
156
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
157
|
+
font-weight: var(--ui-font-weight-medium, 500);
|
|
158
|
+
letter-spacing: var(--ui-tracking-wide, 0.04em);
|
|
159
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
160
|
+
text-transform: var(--ui-label-transform, none);
|
|
161
|
+
color: var(--ui-text-muted, #64748b);
|
|
162
|
+
font-variant-numeric: var(--ui-numeric, normal);
|
|
163
|
+
text-align: center;
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
}
|
|
166
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
167
|
+
.score.bump {
|
|
168
|
+
animation: vote-bump 220ms ease;
|
|
169
|
+
}
|
|
170
|
+
@keyframes vote-bump {
|
|
171
|
+
0% {
|
|
172
|
+
transform: scale(1);
|
|
173
|
+
}
|
|
174
|
+
40% {
|
|
175
|
+
transform: scale(1.25);
|
|
176
|
+
}
|
|
177
|
+
100% {
|
|
178
|
+
transform: scale(1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
@media (prefers-reduced-motion: reduce) {
|
|
183
|
+
.fill {
|
|
184
|
+
transition: none;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
@media (forced-colors: active) {
|
|
188
|
+
.control {
|
|
189
|
+
border: 1px solid CanvasText;
|
|
190
|
+
}
|
|
191
|
+
.vote-btn:focus-visible {
|
|
192
|
+
outline: 2px solid CanvasText;
|
|
193
|
+
outline-offset: 2px;
|
|
194
|
+
box-shadow: none;
|
|
195
|
+
}
|
|
196
|
+
.vote-btn[aria-pressed="true"] {
|
|
197
|
+
outline: 2px solid Highlight;
|
|
198
|
+
}
|
|
199
|
+
.vote-btn:disabled {
|
|
200
|
+
color: GrayText;
|
|
201
|
+
opacity: 1;
|
|
202
|
+
}
|
|
203
|
+
.track {
|
|
204
|
+
border: 1px solid CanvasText;
|
|
205
|
+
}
|
|
206
|
+
.fill {
|
|
207
|
+
background: Highlight;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
`,
|
|
211
|
+
]; }
|
|
212
|
+
updated(changed) {
|
|
213
|
+
if (changed.has("value") && changed.get("value") !== undefined) {
|
|
214
|
+
this.#restartBump();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
#restartBump() {
|
|
218
|
+
const score = this.renderRoot?.querySelector(".score");
|
|
219
|
+
if (!score)
|
|
220
|
+
return;
|
|
221
|
+
score.classList.remove("bump");
|
|
222
|
+
// Force a reflow so removing/re-adding the class restarts the animation.
|
|
223
|
+
void score.offsetWidth;
|
|
224
|
+
score.classList.add("bump");
|
|
225
|
+
}
|
|
226
|
+
#cast(dir) {
|
|
227
|
+
if (this.disabled)
|
|
228
|
+
return;
|
|
229
|
+
const previous = this.vote;
|
|
230
|
+
const nextVote = previous === dir ? null : dir;
|
|
231
|
+
const contribution = (v) => (v === "up" ? 1 : v === "down" ? -1 : 0);
|
|
232
|
+
const delta = contribution(nextVote) - contribution(previous);
|
|
233
|
+
this.vote = nextVote;
|
|
234
|
+
this.value += delta;
|
|
235
|
+
this.dispatchEvent(new CustomEvent("vote-change", {
|
|
236
|
+
detail: { vote: this.vote, value: this.value },
|
|
237
|
+
bubbles: true,
|
|
238
|
+
composed: true,
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
render() {
|
|
242
|
+
const showMeter = this.target > 0;
|
|
243
|
+
const progress = showMeter ? Math.min(100, Math.max(0, (this.value / this.target) * 100)) : 0;
|
|
244
|
+
return html `
|
|
245
|
+
<div class="control" role="group" aria-label=${this.label}>
|
|
246
|
+
<div class="buttons">
|
|
247
|
+
<button
|
|
248
|
+
type="button"
|
|
249
|
+
class="vote-btn up"
|
|
250
|
+
aria-label="Vote up"
|
|
251
|
+
aria-pressed=${this.vote === "up" ? "true" : "false"}
|
|
252
|
+
?disabled=${this.disabled}
|
|
253
|
+
@click=${() => this.#cast("up")}
|
|
254
|
+
>
|
|
255
|
+
${iconChevronUp(18)}
|
|
256
|
+
</button>
|
|
257
|
+
<span class="score" aria-live="polite" aria-atomic="true">${this.value}</span>
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
class="vote-btn down"
|
|
261
|
+
aria-label="Vote down"
|
|
262
|
+
aria-pressed=${this.vote === "down" ? "true" : "false"}
|
|
263
|
+
?disabled=${this.disabled}
|
|
264
|
+
@click=${() => this.#cast("down")}
|
|
265
|
+
>
|
|
266
|
+
${iconChevronDown(18)}
|
|
267
|
+
</button>
|
|
268
|
+
</div>
|
|
269
|
+
${showMeter
|
|
270
|
+
? html `
|
|
271
|
+
<div class="meter">
|
|
272
|
+
<span
|
|
273
|
+
class="track"
|
|
274
|
+
role="progressbar"
|
|
275
|
+
aria-valuenow=${this.value}
|
|
276
|
+
aria-valuemin="0"
|
|
277
|
+
aria-valuemax=${this.target}
|
|
278
|
+
>
|
|
279
|
+
<span class="fill" style=${`width: ${progress}%`}></span>
|
|
280
|
+
</span>
|
|
281
|
+
<span class="caption">${this.value} / ${this.target}</span>
|
|
282
|
+
</div>
|
|
283
|
+
`
|
|
284
|
+
: nothing}
|
|
285
|
+
</div>
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
__decorate([
|
|
290
|
+
property({ type: Number, reflect: true })
|
|
291
|
+
], VoteControl.prototype, "value", void 0);
|
|
292
|
+
__decorate([
|
|
293
|
+
property({ reflect: true })
|
|
294
|
+
], VoteControl.prototype, "vote", void 0);
|
|
295
|
+
__decorate([
|
|
296
|
+
property({ type: Boolean, reflect: true })
|
|
297
|
+
], VoteControl.prototype, "disabled", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
property({ reflect: true })
|
|
300
|
+
], VoteControl.prototype, "orientation", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
property({ type: Number })
|
|
303
|
+
], VoteControl.prototype, "target", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
property()
|
|
306
|
+
], VoteControl.prototype, "label", void 0);
|
|
307
|
+
VoteControl = __decorate([
|
|
308
|
+
customElement("vote-control")
|
|
309
|
+
], VoteControl);
|
|
310
|
+
export { VoteControl };
|
|
311
|
+
//# sourceMappingURL=vote-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vote-control.js","sourceRoot":"","sources":["../src/vote-control.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;GAaG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QA6KL,uDAAuD;QACZ,UAAK,GAAG,CAAC,CAAC;QAErD,kHAAkH;QACrF,SAAI,GAAyB,IAAI,CAAC;QAE/D,kDAAkD;QACN,aAAQ,GAAG,KAAK,CAAC;QAE7D,yGAAyG;QAC5E,gBAAW,GAA8B,UAAU,CAAC;QAEjF,iJAAiJ;QACrH,WAAM,GAAG,CAAC,CAAC;QAEvC,8CAA8C;QAClC,UAAK,GAAG,MAAM,CAAC;IAiF7B,CAAC;aA7QiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuKF;KACF,AA1KqB,CA0KpB;IAoBO,OAAO,CAAC,OAA6B;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;YAC/D,IAAI,CAAC,YAA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AAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAkB;AAGhC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAqD;AAGrD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAY;AAG3B;IAAX,QAAQ,EAAE;0CAAgB;AA7LhB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8QvB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport type { PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconChevronDown, iconChevronUp } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * An up/down vote widget with a live score readout — the \"vote an entry up or\n * down toward a promotion threshold\" pattern from a public register site,\n * where one member casts a single vote that can be changed or withdrawn at any\n * time. Two native `<button>`s flank a score; the button matching the user's\n * own cast `vote` reads as pressed (`aria-pressed`), and clicking it again\n * withdraws the vote. Set an optional `target` to render a thin progress meter\n * toward the promotion threshold beneath (vertical) or beside (horizontal) the\n * buttons.\n *\n * @element vote-control\n * @fires vote-change - The user cast, switched, or withdrew their vote;\n * detail: { vote: \"up\" | \"down\" | null, value: number }.\n */\n@customElement(\"vote-control\")\nexport class VoteControl extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\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 .control {\n display: inline-flex;\n box-sizing: border-box;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface, #ffffff);\n }\n /* Vertical (default): stacked box — up, score, down, optional meter. */\n :host([orientation=\"vertical\"]) .control {\n flex-direction: column;\n align-items: stretch;\n padding: 0.25rem;\n gap: 0.25rem;\n }\n /* Horizontal: wide inline row — up, score, down, optional meter beside. */\n :host([orientation=\"horizontal\"]) .control {\n flex-direction: row;\n align-items: center;\n padding: 0.25rem 0.5rem;\n gap: 0.5rem;\n }\n .buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n }\n :host([orientation=\"vertical\"]) .buttons {\n flex-direction: column;\n }\n :host([orientation=\"horizontal\"]) .buttons {\n flex-direction: row;\n }\n .vote-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n box-sizing: border-box;\n border: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: none;\n color: var(--ui-text-muted, #64748b);\n cursor: pointer;\n }\n .vote-btn:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n color: var(--ui-text, #0f172a);\n }\n .vote-btn.up[aria-pressed=\"true\"] {\n color: var(--ui-success, #16a34a);\n background: var(--ui-surface-muted, #f8fafc);\n }\n .vote-btn.down[aria-pressed=\"true\"] {\n color: var(--ui-danger, #dc2626);\n background: var(--ui-surface-muted, #f8fafc);\n }\n .vote-btn:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n .vote-btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .score {\n min-width: 2rem;\n text-align: center;\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n font-variant-numeric: var(--ui-numeric, normal);\n }\n .meter {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n :host([orientation=\"horizontal\"]) .meter {\n min-width: 4rem;\n }\n .track {\n display: block;\n width: 100%;\n height: 0.25rem;\n border-radius: var(--ui-radius-pill, 9999px);\n background: var(--ui-surface-muted, #f8fafc);\n overflow: hidden;\n }\n .fill {\n display: block;\n height: 100%;\n background: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n transition: width 200ms ease;\n }\n .caption {\n font-size: var(--ui-font-size-xs, 0.6875rem);\n font-weight: var(--ui-font-weight-medium, 500);\n letter-spacing: var(--ui-tracking-wide, 0.04em);\n line-height: var(--ui-line-height-tight, 1.25);\n text-transform: var(--ui-label-transform, none);\n color: var(--ui-text-muted, #64748b);\n font-variant-numeric: var(--ui-numeric, normal);\n text-align: center;\n white-space: nowrap;\n }\n @media (prefers-reduced-motion: no-preference) {\n .score.bump {\n animation: vote-bump 220ms ease;\n }\n @keyframes vote-bump {\n 0% {\n transform: scale(1);\n }\n 40% {\n transform: scale(1.25);\n }\n 100% {\n transform: scale(1);\n }\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .control {\n border: 1px solid CanvasText;\n }\n .vote-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .vote-btn[aria-pressed=\"true\"] {\n outline: 2px solid Highlight;\n }\n .vote-btn:disabled {\n color: GrayText;\n opacity: 1;\n }\n .track {\n border: 1px solid CanvasText;\n }\n .fill {\n background: Highlight;\n }\n }\n `,\n ];\n\n /** The current net score shown between the buttons. */\n @property({ type: Number, reflect: true }) value = 0;\n\n /** This user's own cast vote, or `null` if they have not voted. Reflected so CSS can style the pressed button. */\n @property({ reflect: true }) vote: \"up\" | \"down\" | null = null;\n\n /** Disables both buttons and dims the control. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Layout — `vertical` is the compact stacked box (default); `horizontal` is the wide inline variant. */\n @property({ reflect: true }) orientation: \"vertical\" | \"horizontal\" = \"vertical\";\n\n /** Promotion threshold. When > 0, a thin progress meter toward it renders; when 0 (default) no meter renders and no space is reserved for it. */\n @property({ type: Number }) target = 0;\n\n /** Accessible label naming the vote group. */\n @property() label = \"Vote\";\n\n override updated(changed: PropertyValues<this>) {\n if (changed.has(\"value\") && changed.get(\"value\") !== undefined) {\n this.#restartBump();\n }\n }\n\n #restartBump() {\n const score = this.renderRoot?.querySelector<HTMLElement>(\".score\");\n if (!score) return;\n score.classList.remove(\"bump\");\n // Force a reflow so removing/re-adding the class restarts the animation.\n void score.offsetWidth;\n score.classList.add(\"bump\");\n }\n\n #cast(dir: \"up\" | \"down\") {\n if (this.disabled) return;\n const previous = this.vote;\n const nextVote = previous === dir ? null : dir;\n const contribution = (v: \"up\" | \"down\" | null) => (v === \"up\" ? 1 : v === \"down\" ? -1 : 0);\n const delta = contribution(nextVote) - contribution(previous);\n this.vote = nextVote;\n this.value += delta;\n this.dispatchEvent(\n new CustomEvent(\"vote-change\", {\n detail: { vote: this.vote, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n override render() {\n const showMeter = this.target > 0;\n const progress = showMeter ? Math.min(100, Math.max(0, (this.value / this.target) * 100)) : 0;\n return html`\n <div class=\"control\" role=\"group\" aria-label=${this.label}>\n <div class=\"buttons\">\n <button\n type=\"button\"\n class=\"vote-btn up\"\n aria-label=\"Vote up\"\n aria-pressed=${this.vote === \"up\" ? \"true\" : \"false\"}\n ?disabled=${this.disabled}\n @click=${() => this.#cast(\"up\")}\n >\n ${iconChevronUp(18)}\n </button>\n <span class=\"score\" aria-live=\"polite\" aria-atomic=\"true\">${this.value}</span>\n <button\n type=\"button\"\n class=\"vote-btn down\"\n aria-label=\"Vote down\"\n aria-pressed=${this.vote === \"down\" ? \"true\" : \"false\"}\n ?disabled=${this.disabled}\n @click=${() => this.#cast(\"down\")}\n >\n ${iconChevronDown(18)}\n </button>\n </div>\n ${showMeter\n ? html`\n <div class=\"meter\">\n <span\n class=\"track\"\n role=\"progressbar\"\n aria-valuenow=${this.value}\n aria-valuemin=\"0\"\n aria-valuemax=${this.target}\n >\n <span class=\"fill\" style=${`width: ${progress}%`}></span>\n </span>\n <span class=\"caption\">${this.value} / ${this.target}</span>\n </div>\n `\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vote-control\": VoteControl;\n }\n}\n"]}
|
package/docs/app-shell.md
CHANGED
package/docs/app-sidebar.md
CHANGED
package/docs/audio-player.md
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# `<breadcrumb-nav>`
|
|
2
|
+
|
|
3
|
+
A breadcrumb trail: a `<nav aria-label="Breadcrumb">` wrapping an ordered
|
|
4
|
+
list, with chevron separators and the current page rendered as plain,
|
|
5
|
+
non-interactive text. Designed to drop into `page-header`'s `breadcrumb`
|
|
6
|
+
slot, but usable on its own anywhere a trail is needed.
|
|
7
|
+
|
|
8
|
+
The last `items` entry is always treated as the current page: it renders as
|
|
9
|
+
text with `aria-current="page"` even if it carries an `href`. Middle entries
|
|
10
|
+
without an `href` render as plain text too; only middle entries with an
|
|
11
|
+
`href` are real anchors.
|
|
12
|
+
|
|
13
|
+
When `max-visible` is greater than zero and the trail is longer than that,
|
|
14
|
+
the middle collapses behind an overflow button that always keeps the first
|
|
15
|
+
and current crumbs visible; activating it toggles `expanded` to reveal the
|
|
16
|
+
hidden crumbs in place.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import "@f-ewald/components/breadcrumb-nav.js";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<breadcrumb-nav></breadcrumb-nav>
|
|
28
|
+
<script type="module">
|
|
29
|
+
const trail = document.querySelector("breadcrumb-nav");
|
|
30
|
+
trail.items = [
|
|
31
|
+
{ label: "Home", href: "/" },
|
|
32
|
+
{ label: "Settings", href: "/settings" },
|
|
33
|
+
{ label: "Members" },
|
|
34
|
+
];
|
|
35
|
+
trail.addEventListener("breadcrumb-navigate", (e) => console.log(e.detail.item.label, e.detail.index));
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Attributes / properties
|
|
40
|
+
|
|
41
|
+
| Property | Attribute | Type | Default | Description |
|
|
42
|
+
| --- | --- | --- | --- | --- |
|
|
43
|
+
| `items` | `items` | `BreadcrumbItem[]` | `[]` | The crumbs, root first. The last entry is the current page and is rendered as non-interactive text with `aria-current="page"`. |
|
|
44
|
+
| `maxVisible` | `max-visible` | `number` | `0` | When greater than zero and the trail has more items than this, collapse the middle of the trail behind an overflow button (the first and current crumbs always stay visible). `0` (the default) never collapses. |
|
|
45
|
+
| `expanded` | `expanded` | `boolean` | `false` | Whether a collapsed trail is currently expanded to show its hidden crumbs. |
|
|
46
|
+
|
|
47
|
+
## Events
|
|
48
|
+
|
|
49
|
+
| Event | Description |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `breadcrumb-navigate` | A crumb link was activated; `detail` is `{ item: BreadcrumbItem; index: number }`. This is an additional notification hook only — the anchor's native navigation is never prevented, so crumbs stay real, middle-clickable, right-clickable links. |
|
|
52
|
+
|
|
53
|
+
## Slots
|
|
54
|
+
|
|
55
|
+
_None._
|
|
56
|
+
|
|
57
|
+
## CSS custom properties
|
|
58
|
+
|
|
59
|
+
| Custom property |
|
|
60
|
+
| --- |
|
|
61
|
+
| `--ui-focus-ring` |
|
|
62
|
+
| `--ui-font` |
|
|
63
|
+
| `--ui-font-size-sm` |
|
|
64
|
+
| `--ui-font-weight-medium` |
|
|
65
|
+
| `--ui-font-weight-regular` |
|
|
66
|
+
| `--ui-line-height-glyph` |
|
|
67
|
+
| `--ui-line-height-tight` |
|
|
68
|
+
| `--ui-radius-sm` |
|
|
69
|
+
| `--ui-text` |
|
|
70
|
+
| `--ui-text-muted` |
|
package/docs/button-group.md
CHANGED
package/docs/calendar-day.md
CHANGED
package/docs/calendar-month.md
CHANGED
package/docs/calendar-week.md
CHANGED
package/docs/chat-message.md
CHANGED
package/docs/comment-composer.md
CHANGED
package/docs/confirm-dialog.md
CHANGED