@gjsify/example-gtk-adwaita-storybook 0.54.0 → 0.55.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/dist/browser-main.js +8089 -3038
- package/dist/gjs.js +14 -9
- package/dist/gjs.node.mjs +10 -5
- package/package.json +5 -5
- package/src/browser/buttons/color-dialog-button.web.ts +42 -0
- package/src/browser/buttons/font-dialog-button.web.ts +42 -0
- package/src/browser/buttons/link-button.web.ts +37 -0
- package/src/browser/buttons/scale-button.web.ts +36 -0
- package/src/browser/buttons/toggle-button.web.ts +35 -0
- package/src/browser/controls/check-button.web.ts +38 -0
- package/src/browser/controls/gtk-spinner.web.ts +39 -0
- package/src/browser/controls/level-bar.web.ts +43 -0
- package/src/browser/controls/password-entry.web.ts +36 -0
- package/src/browser/controls/progress-bar.web.ts +39 -0
- package/src/browser/controls/scale.web.ts +44 -0
- package/src/browser/controls/search-entry.web.ts +49 -0
- package/src/browser/controls/spin-button.web.ts +40 -0
- package/src/browser/controls/switch.web.ts +38 -0
- package/src/browser/drawing/drag-icon.web.ts +112 -0
- package/src/browser/drawing/drawing-area.web.ts +66 -0
- package/src/browser/drawing/gl-area.web.ts +162 -0
- package/src/browser/drawing/graphics-offload.web.ts +74 -0
- package/src/browser/feedback/dialog.web.ts +76 -0
- package/src/browser/feedback/emoji-chooser.web.ts +93 -0
- package/src/browser/feedback/gtk-about-dialog.web.ts +105 -0
- package/src/browser/feedback/page-setup-unix-dialog.web.ts +93 -0
- package/src/browser/feedback/print-unix-dialog.web.ts +111 -0
- package/src/browser/feedback/shortcuts-dialog.web.ts +90 -0
- package/src/browser/layout/application-window.web.ts +94 -0
- package/src/browser/layout/aspect-frame.web.ts +49 -0
- package/src/browser/layout/bin.web.ts +41 -0
- package/src/browser/layout/breakpoint-bin.web.ts +61 -0
- package/src/browser/layout/center-box.web.ts +45 -0
- package/src/browser/layout/clamp-scrollable.web.ts +47 -0
- package/src/browser/layout/expander.web.ts +52 -0
- package/src/browser/layout/fixed.web.ts +51 -0
- package/src/browser/layout/frame.web.ts +40 -0
- package/src/browser/layout/grid.web.ts +46 -0
- package/src/browser/layout/layout-slot.web.ts +60 -0
- package/src/browser/layout/multi-layout-view.web.ts +94 -0
- package/src/browser/layout/overlay.web.ts +57 -0
- package/src/browser/layout/paned.web.ts +69 -0
- package/src/browser/layout/popover-bin.web.ts +54 -0
- package/src/browser/layout/popover-menu.web.ts +48 -0
- package/src/browser/layout/popover.web.ts +61 -0
- package/src/browser/layout/revealer.web.ts +53 -0
- package/src/browser/layout/scrollbar.web.ts +54 -0
- package/src/browser/layout/scrolled-window.web.ts +52 -0
- package/src/browser/layout/separator.web.ts +47 -0
- package/src/browser/layout/viewport.web.ts +51 -0
- package/src/browser/layout/window.web.ts +60 -0
- package/src/browser/media/image.web.ts +39 -0
- package/src/browser/media/inscription.web.ts +52 -0
- package/src/browser/media/media-controls.web.ts +65 -0
- package/src/browser/media/picture.web.ts +56 -0
- package/src/browser/media/video.web.ts +56 -0
- package/src/browser/navigation/popover-menu-bar.web.ts +40 -0
- package/src/browser/presentation/calendar.web.ts +49 -0
- package/src/browser/presentation/column-view.web.ts +45 -0
- package/src/browser/presentation/flow-box.web.ts +52 -0
- package/src/browser/presentation/grid-view.web.ts +37 -0
- package/src/browser/presentation/list-box.web.ts +48 -0
- package/src/browser/presentation/list-view.web.ts +36 -0
- package/src/browser/presentation/tree-expander.web.ts +68 -0
- package/src/browser/presentation/window-handle.web.ts +42 -0
- package/src/browser/rows/preferences-row.web.ts +43 -0
- package/src/browser/stories.ts +158 -0
- package/src/browser/text/editable-label.web.ts +45 -0
- package/src/browser/text/search-bar.web.ts +45 -0
- package/src/browser/text/text-view.web.ts +54 -0
- package/src/browser/text/text.web.ts +48 -0
- package/src/browser/view-switching/notebook.web.ts +67 -0
- package/src/browser/view-switching/stack-sidebar.web.ts +68 -0
- package/src/browser/view-switching/stack-switcher.web.ts +70 -0
- package/src/browser/view-switching/stack.web.ts +72 -0
- package/src/browser/view-switching/tab-bar.web.ts +105 -0
- package/src/browser/view-switching/tab-button.web.ts +52 -0
- package/src/browser/view-switching/tab-overview.web.ts +87 -0
- package/src/browser/view-switching/view-switcher-sidebar.web.ts +77 -0
- package/src/browser/windows/action-bar.web.ts +66 -0
- package/src/browser/windows/gtk-application-window.web.ts +67 -0
- package/src/browser/windows/gtk-header-bar.web.ts +61 -0
- package/src/browser/windows/gtk-window.web.ts +58 -0
- package/src/browser/windows/window-controls.web.ts +54 -0
- package/src/buttons/color-dialog-button.meta.ts +16 -0
- package/src/buttons/color-dialog-button.story.ts +49 -0
- package/src/buttons/font-dialog-button.meta.ts +29 -0
- package/src/buttons/font-dialog-button.story.ts +52 -0
- package/src/buttons/link-button.meta.ts +18 -0
- package/src/buttons/link-button.story.ts +48 -0
- package/src/buttons/scale-button.meta.ts +34 -0
- package/src/buttons/scale-button.story.ts +50 -0
- package/src/buttons/toggle-button.meta.ts +17 -0
- package/src/buttons/toggle-button.story.ts +46 -0
- package/src/controls/check-button.meta.ts +19 -0
- package/src/controls/check-button.story.ts +56 -0
- package/src/controls/gtk-spinner.meta.ts +24 -0
- package/src/controls/gtk-spinner.story.ts +53 -0
- package/src/controls/level-bar.meta.ts +39 -0
- package/src/controls/level-bar.story.ts +58 -0
- package/src/controls/password-entry.meta.ts +18 -0
- package/src/controls/password-entry.story.ts +54 -0
- package/src/controls/progress-bar.meta.ts +20 -0
- package/src/controls/progress-bar.story.ts +53 -0
- package/src/controls/scale.meta.ts +47 -0
- package/src/controls/scale.story.ts +66 -0
- package/src/controls/search-entry.meta.ts +18 -0
- package/src/controls/search-entry.story.ts +57 -0
- package/src/controls/spin-button.meta.ts +40 -0
- package/src/controls/spin-button.story.ts +55 -0
- package/src/controls/switch.meta.ts +18 -0
- package/src/controls/switch.story.ts +50 -0
- package/src/drawing/drag-icon.meta.ts +39 -0
- package/src/drawing/drag-icon.story.ts +117 -0
- package/src/drawing/drawing-area.meta.ts +45 -0
- package/src/drawing/drawing-area.story.ts +78 -0
- package/src/drawing/gl-area.meta.ts +30 -0
- package/src/drawing/gl-area.story.ts +113 -0
- package/src/drawing/graphics-offload.meta.ts +39 -0
- package/src/drawing/graphics-offload.story.ts +73 -0
- package/src/feedback/dialog.meta.ts +25 -0
- package/src/feedback/dialog.story.ts +78 -0
- package/src/feedback/emoji-chooser.meta.ts +10 -0
- package/src/feedback/emoji-chooser.story.ts +98 -0
- package/src/feedback/gtk-about-dialog.meta.ts +29 -0
- package/src/feedback/gtk-about-dialog.story.ts +90 -0
- package/src/feedback/page-setup-unix-dialog.meta.ts +37 -0
- package/src/feedback/page-setup-unix-dialog.story.ts +70 -0
- package/src/feedback/print-unix-dialog.meta.ts +30 -0
- package/src/feedback/print-unix-dialog.story.ts +93 -0
- package/src/feedback/shortcuts-dialog.meta.ts +12 -0
- package/src/feedback/shortcuts-dialog.story.ts +79 -0
- package/src/layout/application-window.meta.ts +16 -0
- package/src/layout/application-window.story.ts +97 -0
- package/src/layout/aspect-frame.meta.ts +19 -0
- package/src/layout/aspect-frame.story.ts +62 -0
- package/src/layout/bin.meta.ts +15 -0
- package/src/layout/bin.story.ts +56 -0
- package/src/layout/breakpoint-bin.meta.ts +38 -0
- package/src/layout/breakpoint-bin.story.ts +62 -0
- package/src/layout/center-box.meta.ts +26 -0
- package/src/layout/center-box.story.ts +54 -0
- package/src/layout/clamp-scrollable.meta.ts +30 -0
- package/src/layout/clamp-scrollable.story.ts +51 -0
- package/src/layout/expander.meta.ts +30 -0
- package/src/layout/expander.story.ts +62 -0
- package/src/layout/fixed.meta.ts +16 -0
- package/src/layout/fixed.story.ts +54 -0
- package/src/layout/frame.meta.ts +24 -0
- package/src/layout/frame.story.ts +51 -0
- package/src/layout/grid.meta.ts +45 -0
- package/src/layout/grid.story.ts +80 -0
- package/src/layout/layout-slot.meta.ts +22 -0
- package/src/layout/layout-slot.story.ts +68 -0
- package/src/layout/multi-layout-view.meta.ts +31 -0
- package/src/layout/multi-layout-view.story.ts +101 -0
- package/src/layout/overlay.meta.ts +42 -0
- package/src/layout/overlay.story.ts +72 -0
- package/src/layout/paned.meta.ts +45 -0
- package/src/layout/paned.story.ts +70 -0
- package/src/layout/popover-bin.meta.ts +29 -0
- package/src/layout/popover-bin.story.ts +66 -0
- package/src/layout/popover-menu.meta.ts +54 -0
- package/src/layout/popover-menu.story.ts +119 -0
- package/src/layout/popover.meta.ts +38 -0
- package/src/layout/popover.story.ts +66 -0
- package/src/layout/revealer.meta.ts +44 -0
- package/src/layout/revealer.story.ts +79 -0
- package/src/layout/scrollbar.meta.ts +33 -0
- package/src/layout/scrollbar.story.ts +61 -0
- package/src/layout/scrolled-window.meta.ts +57 -0
- package/src/layout/scrolled-window.story.ts +74 -0
- package/src/layout/separator.meta.ts +25 -0
- package/src/layout/separator.story.ts +53 -0
- package/src/layout/viewport.meta.ts +19 -0
- package/src/layout/viewport.story.ts +53 -0
- package/src/layout/window.meta.ts +13 -0
- package/src/layout/window.story.ts +66 -0
- package/src/media/image.meta.ts +24 -0
- package/src/media/image.story.ts +48 -0
- package/src/media/inscription.meta.ts +45 -0
- package/src/media/inscription.story.ts +64 -0
- package/src/media/media-controls.meta.ts +30 -0
- package/src/media/media-controls.story.ts +58 -0
- package/src/media/picture.meta.ts +42 -0
- package/src/media/picture.story.ts +81 -0
- package/src/media/video.meta.ts +32 -0
- package/src/media/video.story.ts +57 -0
- package/src/metas.ts +79 -0
- package/src/navigation/popover-menu-bar.meta.ts +51 -0
- package/src/navigation/popover-menu-bar.story.ts +72 -0
- package/src/presentation/calendar.meta.ts +28 -0
- package/src/presentation/calendar.story.ts +64 -0
- package/src/presentation/column-view.meta.ts +30 -0
- package/src/presentation/column-view.story.ts +73 -0
- package/src/presentation/flow-box.meta.ts +51 -0
- package/src/presentation/flow-box.story.ts +72 -0
- package/src/presentation/grid-view.meta.ts +28 -0
- package/src/presentation/grid-view.story.ts +64 -0
- package/src/presentation/list-box.meta.ts +55 -0
- package/src/presentation/list-box.story.ts +68 -0
- package/src/presentation/list-view.meta.ts +38 -0
- package/src/presentation/list-view.story.ts +73 -0
- package/src/presentation/tree-expander.meta.ts +24 -0
- package/src/presentation/tree-expander.story.ts +105 -0
- package/src/presentation/window-handle.meta.ts +27 -0
- package/src/presentation/window-handle.story.ts +53 -0
- package/src/rows/preferences-row.meta.ts +15 -0
- package/src/rows/preferences-row.story.ts +50 -0
- package/src/text/editable-label.meta.ts +17 -0
- package/src/text/editable-label.story.ts +47 -0
- package/src/text/search-bar.meta.ts +17 -0
- package/src/text/search-bar.story.ts +48 -0
- package/src/text/text-view.meta.ts +49 -0
- package/src/text/text-view.story.ts +69 -0
- package/src/text/text.meta.ts +21 -0
- package/src/text/text.story.ts +50 -0
- package/src/view-switching/notebook.meta.ts +44 -0
- package/src/view-switching/notebook.story.ts +77 -0
- package/src/view-switching/stack-sidebar.meta.ts +50 -0
- package/src/view-switching/stack-sidebar.story.ts +85 -0
- package/src/view-switching/stack-switcher.meta.ts +53 -0
- package/src/view-switching/stack-switcher.story.ts +95 -0
- package/src/view-switching/stack.meta.ts +53 -0
- package/src/view-switching/stack.story.ts +95 -0
- package/src/view-switching/tab-bar.meta.ts +22 -0
- package/src/view-switching/tab-bar.story.ts +85 -0
- package/src/view-switching/tab-button.meta.ts +14 -0
- package/src/view-switching/tab-button.story.ts +52 -0
- package/src/view-switching/tab-overview.meta.ts +21 -0
- package/src/view-switching/tab-overview.story.ts +86 -0
- package/src/view-switching/view-switcher-sidebar.meta.ts +42 -0
- package/src/view-switching/view-switcher-sidebar.story.ts +73 -0
- package/src/windows/action-bar.meta.ts +27 -0
- package/src/windows/action-bar.story.ts +65 -0
- package/src/windows/gtk-application-window.meta.ts +27 -0
- package/src/windows/gtk-application-window.story.ts +89 -0
- package/src/windows/gtk-header-bar.meta.ts +39 -0
- package/src/windows/gtk-header-bar.story.ts +76 -0
- package/src/windows/gtk-window.meta.ts +30 -0
- package/src/windows/gtk-window.story.ts +64 -0
- package/src/windows/window-controls.meta.ts +42 -0
- package/src/windows/window-controls.story.ts +61 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Browser port of the Popover story. Shares metadata with popover.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { popoverMeta } from '../../layout/popover.meta.js';
|
|
5
|
+
|
|
6
|
+
/** The two members the story drives that are properties rather than attributes. */
|
|
7
|
+
interface PopoverSurface extends HTMLElement {
|
|
8
|
+
open: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class PopoverWebStory extends StoryElement {
|
|
12
|
+
private _anchor!: HTMLButtonElement;
|
|
13
|
+
private _popover!: PopoverSurface;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super(PopoverWebStory.getMetadata(), 'Default');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getMetadata(): StoryMeta {
|
|
20
|
+
return popoverMeta;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
initialize(): void {
|
|
24
|
+
this._anchor = document.createElement('button');
|
|
25
|
+
this._anchor.textContent = 'Show popover';
|
|
26
|
+
|
|
27
|
+
this._popover = document.createElement('gtk-popover') as unknown as PopoverSurface;
|
|
28
|
+
// A plain content popover, NOT the `.menu` variant: `popover > contents` pads 8px,
|
|
29
|
+
// where a menu popover re-declares 0 and moves the inset to the item box
|
|
30
|
+
// (`popover.menu > contents`, _menus.scss:58-66).
|
|
31
|
+
const box = document.createElement('div');
|
|
32
|
+
box.style.cssText = 'display:flex;flex-direction:column;gap:6px;';
|
|
33
|
+
for (const label of ['Anything you like', 'in here']) {
|
|
34
|
+
const line = document.createElement('span');
|
|
35
|
+
line.textContent = label;
|
|
36
|
+
box.appendChild(line);
|
|
37
|
+
}
|
|
38
|
+
this._popover.appendChild(box);
|
|
39
|
+
|
|
40
|
+
this._anchor.appendChild(this._popover);
|
|
41
|
+
this._anchor.addEventListener('click', () => {
|
|
42
|
+
this._popover.open = !this._popover.open;
|
|
43
|
+
});
|
|
44
|
+
this._apply();
|
|
45
|
+
this.addContent(this._anchor);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
updateArgs(_args: StoryArgs): void {
|
|
49
|
+
this._apply();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private _apply(): void {
|
|
53
|
+
if (!this._popover) return;
|
|
54
|
+
this._popover.setAttribute('position', this.args.position as string);
|
|
55
|
+
this._popover.setAttribute('align', this.args.align as string);
|
|
56
|
+
// Default-TRUE, so the attribute has to be able to say BOTH values here.
|
|
57
|
+
this._popover.setAttribute('autohide', String(this.args.autohide as boolean));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const PopoverWebStories: WebStoryModule = { stories: [PopoverWebStory] };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Browser port of the Revealer story. Shares metadata with revealer.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { revealerMeta } from '../../layout/revealer.meta.js';
|
|
5
|
+
|
|
6
|
+
export class RevealerWebStory extends StoryElement {
|
|
7
|
+
private _revealer: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(RevealerWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return revealerMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
this._revealer = document.createElement('gtk-revealer');
|
|
19
|
+
|
|
20
|
+
const content = document.createElement('gtk-box');
|
|
21
|
+
content.setAttribute('orientation', 'vertical');
|
|
22
|
+
content.setAttribute('spacing', '6');
|
|
23
|
+
content.style.padding = '12px';
|
|
24
|
+
|
|
25
|
+
const title = document.createElement('gtk-label');
|
|
26
|
+
title.setAttribute('label', 'The revealed child');
|
|
27
|
+
content.appendChild(title);
|
|
28
|
+
|
|
29
|
+
const hint = document.createElement('gtk-label');
|
|
30
|
+
hint.setAttribute('label', 'Use the controls to change the transition');
|
|
31
|
+
hint.classList.add('dimmed');
|
|
32
|
+
content.appendChild(hint);
|
|
33
|
+
|
|
34
|
+
this._revealer.appendChild(content);
|
|
35
|
+
this._apply();
|
|
36
|
+
this.addContent(this._revealer);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
updateArgs(_args: StoryArgs): void {
|
|
40
|
+
this._apply();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private _apply(): void {
|
|
44
|
+
if (!this._revealer) return;
|
|
45
|
+
// The nicks ARE the attribute values, which is the whole reason the control's options
|
|
46
|
+
// spell them the way the GIR does.
|
|
47
|
+
this._revealer.setAttribute('transition-type', String(this.args.transitionType));
|
|
48
|
+
this._revealer.setAttribute('transition-duration', String(this.args.transitionDuration));
|
|
49
|
+
this._revealer.toggleAttribute('reveal-child', this.args.revealChild as boolean);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const RevealerWebStories: WebStoryModule = { stories: [RevealerWebStory] };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Browser port of the Scrollbar story. Shares metadata with scrollbar.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { scrollbarMeta } from '../../layout/scrollbar.meta.js';
|
|
5
|
+
|
|
6
|
+
/** The scrollbar the web element IS: the adjustment plus the orientation. */
|
|
7
|
+
interface WebScrollbar extends HTMLElement {
|
|
8
|
+
adjustment: Record<string, number>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ScrollbarWebStory extends StoryElement {
|
|
12
|
+
private _scrollbar: WebScrollbar | null = null;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super(ScrollbarWebStory.getMetadata(), 'Default');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static getMetadata(): StoryMeta {
|
|
19
|
+
return scrollbarMeta;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initialize(): void {
|
|
23
|
+
const scrollbar = document.createElement('gtk-scrollbar') as WebScrollbar;
|
|
24
|
+
// The element is a bar with no thickness of its own in a column, so the allocation is
|
|
25
|
+
// the one GTK would give it inside a scrolled window.
|
|
26
|
+
scrollbar.style.height = '240px';
|
|
27
|
+
scrollbar.style.width = '24px';
|
|
28
|
+
scrollbar.setAttribute('valign', 'center');
|
|
29
|
+
this._scrollbar = scrollbar;
|
|
30
|
+
this._apply();
|
|
31
|
+
this.addContent(scrollbar);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
updateArgs(_args: StoryArgs): void {
|
|
35
|
+
this._apply();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private _apply(): void {
|
|
39
|
+
const scrollbar = this._scrollbar;
|
|
40
|
+
if (!scrollbar) return;
|
|
41
|
+
scrollbar.setAttribute('orientation', this.args.orientation as string);
|
|
42
|
+
// One write for the whole adjustment, the way `gtk_adjustment_configure` takes it.
|
|
43
|
+
scrollbar.adjustment = {
|
|
44
|
+
value: Number(this.args.value),
|
|
45
|
+
lower: 0,
|
|
46
|
+
upper: Number(this.args.upper),
|
|
47
|
+
stepIncrement: 10,
|
|
48
|
+
pageIncrement: 80,
|
|
49
|
+
pageSize: Number(this.args.pageSize),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const ScrollbarWebStories: WebStoryModule = { stories: [ScrollbarWebStory] };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Browser port of the Scrolled Window story. Shares metadata with scrolled-window.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { scrolledWindowMeta } from '../../layout/scrolled-window.meta.js';
|
|
5
|
+
|
|
6
|
+
export class ScrolledWindowWebStory extends StoryElement {
|
|
7
|
+
private _window: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(ScrolledWindowWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return scrolledWindowMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
const window = document.createElement('gtk-scrolled-window');
|
|
19
|
+
// An ALLOCATION, which is what GTK hands this widget and what makes it scroll rather
|
|
20
|
+
// than grow: an auto-height box grows with its content and has nothing to scroll.
|
|
21
|
+
window.style.height = '240px';
|
|
22
|
+
window.style.width = '260px';
|
|
23
|
+
const box = document.createElement('gtk-box');
|
|
24
|
+
box.setAttribute('orientation', 'vertical');
|
|
25
|
+
box.setAttribute('spacing', '8');
|
|
26
|
+
for (let i = 1; i <= 16; i++) {
|
|
27
|
+
const label = document.createElement('gtk-label');
|
|
28
|
+
label.setAttribute('label', `Row ${i}`);
|
|
29
|
+
box.appendChild(label);
|
|
30
|
+
}
|
|
31
|
+
window.appendChild(box);
|
|
32
|
+
this._window = window;
|
|
33
|
+
this._apply();
|
|
34
|
+
this.addContent(window);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
updateArgs(_args: StoryArgs): void {
|
|
38
|
+
this._apply();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private _apply(): void {
|
|
42
|
+
const window = this._window;
|
|
43
|
+
if (!window) return;
|
|
44
|
+
window.setAttribute('hscrollbar-policy', this.args.hPolicy as string);
|
|
45
|
+
window.setAttribute('vscrollbar-policy', this.args.vPolicy as string);
|
|
46
|
+
window.setAttribute('window-placement', this.args.placement as string);
|
|
47
|
+
window.toggleAttribute('has-frame', this.args.frame as boolean);
|
|
48
|
+
window.toggleAttribute('overlay-scrolling', this.args.overlayScrolling as boolean);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const ScrolledWindowWebStories: WebStoryModule = { stories: [ScrolledWindowWebStory] };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Browser port of the Separator story. Shares metadata with separator.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { separatorMeta } from '../../layout/separator.meta.js';
|
|
5
|
+
|
|
6
|
+
export class SeparatorWebStory extends StoryElement {
|
|
7
|
+
private _box: HTMLElement | null = null;
|
|
8
|
+
private _separator: HTMLElement | null = null;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super(SeparatorWebStory.getMetadata(), 'Default');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static getMetadata(): StoryMeta {
|
|
15
|
+
return separatorMeta;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
initialize(): void {
|
|
19
|
+
this._separator = document.createElement('gtk-separator');
|
|
20
|
+
this._box = document.createElement('gtk-box');
|
|
21
|
+
this._box.setAttribute('spacing', '12');
|
|
22
|
+
for (const label of ['Above', 'Below']) {
|
|
23
|
+
const text = document.createElement('gtk-label');
|
|
24
|
+
text.setAttribute('label', label);
|
|
25
|
+
// The separator sits BETWEEN the two labels.
|
|
26
|
+
if (label === 'Below') this._box.appendChild(this._separator);
|
|
27
|
+
this._box.appendChild(text);
|
|
28
|
+
}
|
|
29
|
+
this._apply();
|
|
30
|
+
this.addContent(this._box);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateArgs(_args: StoryArgs): void {
|
|
34
|
+
this._apply();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _apply(): void {
|
|
38
|
+
if (!this._box || !this._separator) return;
|
|
39
|
+
const vertical = this.args.orientation === 'vertical';
|
|
40
|
+
this._separator.setAttribute('orientation', vertical ? 'vertical' : 'horizontal');
|
|
41
|
+
// A rule runs ACROSS its box, so the box runs the other way.
|
|
42
|
+
this._box.setAttribute('orientation', vertical ? 'horizontal' : 'vertical');
|
|
43
|
+
this._separator.classList.toggle('spacer', this.args.spacer as boolean);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const SeparatorWebStories: WebStoryModule = { stories: [SeparatorWebStory] };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Browser port of the Viewport story. Shares metadata with viewport.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { viewportMeta } from '../../layout/viewport.meta.js';
|
|
5
|
+
|
|
6
|
+
export class ViewportWebStory extends StoryElement {
|
|
7
|
+
private _viewport: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(ViewportWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return viewportMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
const viewport = document.createElement('gtk-viewport');
|
|
19
|
+
// An allocation, which is what GTK hands a viewport; without one it grows with its
|
|
20
|
+
// content and has nothing to scroll.
|
|
21
|
+
viewport.style.height = '240px';
|
|
22
|
+
viewport.style.width = '260px';
|
|
23
|
+
const box = document.createElement('gtk-box');
|
|
24
|
+
box.setAttribute('orientation', 'vertical');
|
|
25
|
+
box.setAttribute('spacing', '8');
|
|
26
|
+
for (let i = 1; i <= 16; i++) {
|
|
27
|
+
const label = document.createElement('gtk-label');
|
|
28
|
+
label.setAttribute('label', `Row ${i}`);
|
|
29
|
+
box.appendChild(label);
|
|
30
|
+
}
|
|
31
|
+
const button = document.createElement('gtk-button');
|
|
32
|
+
button.setAttribute('label', 'Focus me');
|
|
33
|
+
box.appendChild(button);
|
|
34
|
+
viewport.appendChild(box);
|
|
35
|
+
this._viewport = viewport;
|
|
36
|
+
this._apply();
|
|
37
|
+
this.addContent(viewport);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
updateArgs(_args: StoryArgs): void {
|
|
41
|
+
this._apply();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private _apply(): void {
|
|
45
|
+
const viewport = this._viewport;
|
|
46
|
+
if (!viewport) return;
|
|
47
|
+
viewport.setAttribute('scroll-to-focus', String(this.args.scrollToFocus as boolean));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const ViewportWebStories: WebStoryModule = { stories: [ViewportWebStory] };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Browser port of the Window story. Shares metadata with window.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { windowMeta } from '../../layout/window.meta.js';
|
|
5
|
+
|
|
6
|
+
export class WindowWebStory extends StoryElement {
|
|
7
|
+
private _title: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(WindowWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return windowMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
this._title = document.createElement('adw-window-title');
|
|
19
|
+
this._title.setAttribute('slot', 'center');
|
|
20
|
+
|
|
21
|
+
const backButton = document.createElement('gtk-button');
|
|
22
|
+
backButton.setAttribute('slot', 'start');
|
|
23
|
+
backButton.setAttribute('icon', 'go-previous');
|
|
24
|
+
backButton.setAttribute('flat', '');
|
|
25
|
+
|
|
26
|
+
const menuButton = document.createElement('gtk-button');
|
|
27
|
+
menuButton.setAttribute('slot', 'end');
|
|
28
|
+
menuButton.setAttribute('icon', 'open-menu');
|
|
29
|
+
menuButton.setAttribute('flat', '');
|
|
30
|
+
|
|
31
|
+
const headerBar = document.createElement('adw-header-bar');
|
|
32
|
+
headerBar.style.width = '460px';
|
|
33
|
+
headerBar.append(backButton, this._title, menuButton);
|
|
34
|
+
|
|
35
|
+
const statusPage = document.createElement('adw-status-page');
|
|
36
|
+
statusPage.setAttribute('title', 'Your Library');
|
|
37
|
+
statusPage.setAttribute('description', 'Content sits between the toolbars and scrolls independently of them.');
|
|
38
|
+
|
|
39
|
+
const toolbarView = document.createElement('adw-toolbar-view');
|
|
40
|
+
toolbarView.append(headerBar, statusPage);
|
|
41
|
+
|
|
42
|
+
const win = document.createElement('adw-window');
|
|
43
|
+
win.append(toolbarView);
|
|
44
|
+
|
|
45
|
+
this._sync();
|
|
46
|
+
this.addContent(win);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
updateArgs(_args: StoryArgs): void {
|
|
50
|
+
this._sync();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private _sync(): void {
|
|
54
|
+
if (!this._title) return;
|
|
55
|
+
this._title.setAttribute('title', this.args.title as string);
|
|
56
|
+
this._title.setAttribute('subtitle', this.args.subtitle as string);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const WindowWebStories: WebStoryModule = { stories: [WindowWebStory] };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Browser port of the Image story. Shares metadata with image.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { imageMeta } from '../../media/image.meta.js';
|
|
5
|
+
|
|
6
|
+
export class ImageWebStory extends StoryElement {
|
|
7
|
+
private _image: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(ImageWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return imageMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
this._image = document.createElement('gtk-image');
|
|
19
|
+
this._apply();
|
|
20
|
+
this.addContent(this._image);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
updateArgs(_args: StoryArgs): void {
|
|
24
|
+
this._apply();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private _apply(): void {
|
|
28
|
+
if (!this._image) return;
|
|
29
|
+
// The GTK story casts the pixel count to a `Gtk.IconSize` enum, which does not exist on
|
|
30
|
+
// this renderer — the web's icon box is sized in PIXELS by the same `size` attribute
|
|
31
|
+
// `gtk-image.ts` documents, and the two agree at 16/32/48 because those are the enum's
|
|
32
|
+
// own members in points.
|
|
33
|
+
this._image.setAttribute('size', String(this.args.size as number));
|
|
34
|
+
this._image.setAttribute('icon-name', this.args.iconName as string);
|
|
35
|
+
this._image.toggleAttribute('disabled', this.args.disabled as boolean);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const ImageWebStories: WebStoryModule = { stories: [ImageWebStory] };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Browser port of the Inscription story. Shares metadata with inscription.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { inscriptionMeta } from '../../media/inscription.meta.js';
|
|
5
|
+
|
|
6
|
+
export class InscriptionWebStory extends StoryElement {
|
|
7
|
+
private _inscription: HTMLElement | null = null;
|
|
8
|
+
private _frame: HTMLElement | null = null;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super(InscriptionWebStory.getMetadata(), 'Default');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static getMetadata(): StoryMeta {
|
|
15
|
+
return inscriptionMeta;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
initialize(): void {
|
|
19
|
+
// The frame is the fixed box the counts are shown against, as in the GTK story — an
|
|
20
|
+
// inscription in an unconstrained column shrinks to its minimum and the `nat` counts
|
|
21
|
+
// visibly do nothing.
|
|
22
|
+
this._frame = document.createElement('div');
|
|
23
|
+
this._frame.style.cssText =
|
|
24
|
+
'width:320px;height:160px;border:1px solid var(--separator-color);display:flex;align-items:stretch;justify-content:stretch;';
|
|
25
|
+
this._inscription = document.createElement('gtk-inscription');
|
|
26
|
+
this._frame.appendChild(this._inscription);
|
|
27
|
+
this._apply();
|
|
28
|
+
this.addContent(this._frame);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateArgs(_args: StoryArgs): void {
|
|
32
|
+
this._apply();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _apply(): void {
|
|
36
|
+
if (!this._inscription) return;
|
|
37
|
+
// The ORDER is the measure, exactly as in the GTK story: the natural is
|
|
38
|
+
// `MAX (min_chars, nat_chars)` (gtkinscription.c:348), so both counts precede the
|
|
39
|
+
// text and a later `min` cannot pull the natural below the larger of the two.
|
|
40
|
+
this._inscription.setAttribute('min-chars', String(this.args.minChars as number));
|
|
41
|
+
this._inscription.setAttribute('nat-chars', String(this.args.natChars as number));
|
|
42
|
+
this._inscription.setAttribute('min-lines', String(this.args.minLines as number));
|
|
43
|
+
this._inscription.setAttribute('nat-lines', String(this.args.natLines as number));
|
|
44
|
+
this._inscription.setAttribute('text', this.args.text as string);
|
|
45
|
+
this._inscription.setAttribute('wrap-mode', this.args.wrapMode as string);
|
|
46
|
+
this._inscription.setAttribute('text-overflow', this.args.textOverflow as string);
|
|
47
|
+
this._inscription.setAttribute('xalign', String(this.args.xalign as number));
|
|
48
|
+
this._inscription.setAttribute('yalign', String(this.args.yalign as number));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const InscriptionWebStories: WebStoryModule = { stories: [InscriptionWebStory] };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Browser port of the Media Controls story. Shares metadata with media-controls.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { mediaControlsMeta } from '../../media/media-controls.meta.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The element's public surface, as the story needs it. `volume` is a real property HERE and
|
|
8
|
+
* has no counterpart in GTK: `volume_adjustment` is private to the template
|
|
9
|
+
* (`ui/gtkmediacontrols.ui`) and `Gtk.MediaControls` exposes no volume setter, which is why
|
|
10
|
+
* no `volume` CONTROL is declared in the shared meta — one meta drives three panels, so a
|
|
11
|
+
* control only the browser could honour is refused by `check-storybook-control-parity.mjs`.
|
|
12
|
+
*/
|
|
13
|
+
type MediaControlsElement = HTMLElement & { volume: number };
|
|
14
|
+
|
|
15
|
+
export class MediaControlsWebStory extends StoryElement {
|
|
16
|
+
private _video: HTMLElement | null = null;
|
|
17
|
+
private _controls: MediaControlsElement | null = null;
|
|
18
|
+
private _media: HTMLVideoElement | null = null;
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super(MediaControlsWebStory.getMetadata(), 'Default');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getMetadata(): StoryMeta {
|
|
25
|
+
return mediaControlsMeta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
initialize(): void {
|
|
29
|
+
// The controls bar lives INSIDE the video, as `ui/gtkvideo.ui`'s controls revealer
|
|
30
|
+
// does, and it adopts its stream from the nearest ancestor video — that is how the
|
|
31
|
+
// element finds the `<video>` to drive.
|
|
32
|
+
this._video = document.createElement('gtk-video');
|
|
33
|
+
this._controls = document.createElement('gtk-media-controls') as MediaControlsElement;
|
|
34
|
+
this._media = document.createElement('video');
|
|
35
|
+
this._media.muted = true;
|
|
36
|
+
this._video.append(this._media, this._controls);
|
|
37
|
+
this._apply();
|
|
38
|
+
this.addContent(this._video);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
updateArgs(_args: StoryArgs): void {
|
|
42
|
+
this._apply();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private _apply(): void {
|
|
46
|
+
if (!this._video || !this._controls) return;
|
|
47
|
+
this._video.style.width = '360px';
|
|
48
|
+
this._video.style.height = '203px';
|
|
49
|
+
// GTK's bar is the video's own controls revealer child and the video itself is the
|
|
50
|
+
// anchor, so the bar is given the same width as the surface above it.
|
|
51
|
+
this._controls.style.display = 'block';
|
|
52
|
+
// `sensitive` is the control the meta declares, and the element's own spelling is the
|
|
53
|
+
// template's: the box ships `sensitive` 0 (ui/gtkmediacontrols.ui) and
|
|
54
|
+
// `gtk_media_controls_set_sensitive` is what re-enables it. Here it is the `insensitive`
|
|
55
|
+
// CLASS the stylesheet selects on, set from the normalized property — an attribute
|
|
56
|
+
// presence selector could be left half-applied by a value the element did not take.
|
|
57
|
+
this._controls.classList.toggle('insensitive', !(this.args.sensitive as boolean));
|
|
58
|
+
// `volume` is set once and never from a control: the meta declares none, because GTK
|
|
59
|
+
// cannot honour one. A reader who wants to see the four `audio-volume-*` names move
|
|
60
|
+
// reaches the element's property directly, which is where the divergence lives.
|
|
61
|
+
this._controls.volume = 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const MediaControlsWebStories: WebStoryModule = { stories: [MediaControlsWebStory] };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Browser port of the Picture story. Shares metadata with picture.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { pictureMeta } from '../../media/picture.meta.js';
|
|
5
|
+
|
|
6
|
+
export class PictureWebStory extends StoryElement {
|
|
7
|
+
private _picture: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(PictureWebStory.getMetadata(), 'Default');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getMetadata(): StoryMeta {
|
|
14
|
+
return pictureMeta;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initialize(): void {
|
|
18
|
+
this._picture = document.createElement('gtk-picture');
|
|
19
|
+
// The light DOM carries the content, because `GdkPaintable` is not a thing a document
|
|
20
|
+
// has and `<gtk-picture>` is defined as the box that FITS one. A 320×180 inline SVG
|
|
21
|
+
// gives the same non-square intrinsic ratio the GTK story's memory texture does.
|
|
22
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
23
|
+
svg.setAttribute('viewBox', '0 0 320 180');
|
|
24
|
+
svg.setAttribute('width', '320');
|
|
25
|
+
svg.setAttribute('height', '180');
|
|
26
|
+
svg.innerHTML =
|
|
27
|
+
'<rect width="320" height="90" fill="rgb(48 64 160)"/><rect y="90" width="320" height="90" fill="rgb(144 192 160)"/>';
|
|
28
|
+
this._picture.appendChild(svg);
|
|
29
|
+
this._apply();
|
|
30
|
+
this.addContent(this._picture);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateArgs(_args: StoryArgs): void {
|
|
34
|
+
this._apply();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private _apply(): void {
|
|
38
|
+
if (!this._picture) return;
|
|
39
|
+
const width = String(this.args.width as number);
|
|
40
|
+
// 3:2 round a 16:9 child, matching the GTK story, so `cover` crops and `contain` bars.
|
|
41
|
+
this._picture.style.width = `${width}px`;
|
|
42
|
+
this._picture.style.height = `${Math.round((Number(width) * 2) / 3)}px`;
|
|
43
|
+
// The ORDER is the C's: `keep-aspect-ratio` MAPS onto `content-fit`
|
|
44
|
+
// (gtkpicture.c:1017-1021), so writing it afterwards would undo the control the reader
|
|
45
|
+
// just moved. It goes first, and only when it is on.
|
|
46
|
+
if (this.args.keepAspectRatio as boolean) this._picture.toggleAttribute('keep-aspect-ratio', true);
|
|
47
|
+
this._picture.setAttribute('content-fit', this.args.contentFit as string);
|
|
48
|
+
// A TRUE-defaulted boolean needs the STRING, not the presence: `can-shrink="false"` is
|
|
49
|
+
// the only spelling of FALSE, and `canShrink` reads absent as TRUE (gtkpicture.c:554).
|
|
50
|
+
this._picture.setAttribute('can-shrink', String(this.args.canShrink as boolean));
|
|
51
|
+
this._picture.setAttribute('isolate-contents', String(this.args.isolateContents as boolean));
|
|
52
|
+
this._picture.setAttribute('alternative-text', this.args.alternativeText as string);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const PictureWebStories: WebStoryModule = { stories: [PictureWebStory] };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Browser port of the Video story. Shares metadata with video.story.ts.
|
|
2
|
+
|
|
3
|
+
import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
4
|
+
import { videoMeta } from '../../media/video.meta.js';
|
|
5
|
+
|
|
6
|
+
/** The element's public surface, as the story needs it — the attrs are the properties. */
|
|
7
|
+
type VideoElement = HTMLElement & {
|
|
8
|
+
revealControls(): void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class VideoWebStory extends StoryElement {
|
|
12
|
+
private _video: VideoElement | null = null;
|
|
13
|
+
private _media: HTMLVideoElement | null = null;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super(VideoWebStory.getMetadata(), 'Default');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getMetadata(): StoryMeta {
|
|
20
|
+
return videoMeta;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
initialize(): void {
|
|
24
|
+
this._video = document.createElement('gtk-video') as VideoElement;
|
|
25
|
+
// A real `<video>` with NO source, which is the browser's version of the state the GTK
|
|
26
|
+
// story shows: `gtk_video_update_overlay_icon`'s FIRST arm is "no stream"
|
|
27
|
+
// (gtkvideo.c:629), and a `<video>` with no `src` has a `networkState` of NETWORK_EMPTY,
|
|
28
|
+
// so the element cannot tell the two apart and draws the same eject glyph. The story
|
|
29
|
+
// that could load a real clip would prove nothing extra about the WIDGET.
|
|
30
|
+
this._media = document.createElement('video');
|
|
31
|
+
this._media.muted = true;
|
|
32
|
+
this._video.appendChild(this._media);
|
|
33
|
+
this._apply();
|
|
34
|
+
this.addContent(this._video);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
updateArgs(_args: StoryArgs): void {
|
|
38
|
+
this._apply();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private _apply(): void {
|
|
42
|
+
if (!this._video) return;
|
|
43
|
+
const width = String(this.args.width as number);
|
|
44
|
+
this._video.style.width = `${width}px`;
|
|
45
|
+
this._video.style.height = `${Math.round((Number(width) * 9) / 16)}px`;
|
|
46
|
+
this._video.toggleAttribute('autoplay', this.args.autoplay as boolean);
|
|
47
|
+
this._video.toggleAttribute('loop', this.args.loop as boolean);
|
|
48
|
+
this._video.toggleAttribute('graphics-offload', this.args.graphicsOffload as boolean);
|
|
49
|
+
// The controls bar reveals on pointer movement in GTK (ui/gtkvideo.ui's
|
|
50
|
+
// `gtk_video_motion`), and a story the reader cannot see the bar in is a story that
|
|
51
|
+
// documents nothing — so the first reveal is explicit rather than waited for.
|
|
52
|
+
this._video.revealControls();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const VideoWebStories: WebStoryModule = { stories: [VideoWebStory] };
|