@gjsify/example-gtk-adwaita-storybook 0.19.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 +120 -0
- package/dist/adw-runasync.mjs +1 -0
- package/dist/gjs.js +91 -0
- package/dist/interact-probe.node.mjs +87 -0
- package/dist/probe.node.mjs +87 -0
- package/dist/render-probe.node.mjs +87 -0
- package/dist/runasync-probe.mjs +1 -0
- package/dist/storybook.node.mjs +87 -0
- package/package.json +64 -0
- package/src/browser/buttons/button-content.web.ts +55 -0
- package/src/browser/buttons/button-styles.web.ts +79 -0
- package/src/browser/buttons/split-button.web.ts +86 -0
- package/src/browser/buttons/toggle-group.web.ts +56 -0
- package/src/browser/embed.ts +46 -0
- package/src/browser/feedback/about-dialog.web.ts +82 -0
- package/src/browser/feedback/alert-dialog.web.ts +72 -0
- package/src/browser/feedback/preferences-dialog.web.ts +106 -0
- package/src/browser/feedback/toast.web.ts +62 -0
- package/src/browser/index.html +23 -0
- package/src/browser/layout/clamp.web.ts +45 -0
- package/src/browser/layout/header-bar.web.ts +56 -0
- package/src/browser/layout/toolbar-view.web.ts +95 -0
- package/src/browser/layout/wrap-box.web.ts +45 -0
- package/src/browser/main.ts +14 -0
- package/src/browser/navigation/bottom-sheet.web.ts +119 -0
- package/src/browser/navigation/navigation-split-view.web.ts +99 -0
- package/src/browser/navigation/navigation-view.web.ts +104 -0
- package/src/browser/navigation/overlay-split-view.web.ts +106 -0
- package/src/browser/navigation/sidebar.web.ts +84 -0
- package/src/browser/presentation/avatar.web.ts +36 -0
- package/src/browser/presentation/banner.web.ts +41 -0
- package/src/browser/presentation/spinner.web.ts +28 -0
- package/src/browser/presentation/status-page.web.ts +43 -0
- package/src/browser/presentation/window-title.web.ts +34 -0
- package/src/browser/rows/action-row.web.ts +61 -0
- package/src/browser/rows/button-row.web.ts +64 -0
- package/src/browser/rows/combo-row.web.ts +44 -0
- package/src/browser/rows/entry-row.web.ts +42 -0
- package/src/browser/rows/expander-row.web.ts +53 -0
- package/src/browser/rows/password-entry-row.web.ts +43 -0
- package/src/browser/rows/preferences-group.web.ts +68 -0
- package/src/browser/rows/spin-row.web.ts +47 -0
- package/src/browser/rows/switch-row.web.ts +43 -0
- package/src/browser/stories.ts +82 -0
- package/src/browser/view-switching/carousel.web.ts +106 -0
- package/src/browser/view-switching/inline-view-switcher.web.ts +55 -0
- package/src/browser/view-switching/tab-view.web.ts +64 -0
- package/src/browser/view-switching/view-switcher.web.ts +55 -0
- package/src/buttons/button-content.meta.ts +26 -0
- package/src/buttons/button-content.story.ts +49 -0
- package/src/buttons/button-styles.meta.ts +26 -0
- package/src/buttons/button-styles.story.ts +77 -0
- package/src/buttons/split-button.meta.ts +45 -0
- package/src/buttons/split-button.story.ts +102 -0
- package/src/buttons/toggle-group.meta.ts +34 -0
- package/src/buttons/toggle-group.story.ts +56 -0
- package/src/feedback/about-dialog.meta.ts +13 -0
- package/src/feedback/about-dialog.story.ts +64 -0
- package/src/feedback/alert-dialog.meta.ts +19 -0
- package/src/feedback/alert-dialog.story.ts +61 -0
- package/src/feedback/preferences-dialog.meta.ts +13 -0
- package/src/feedback/preferences-dialog.story.ts +92 -0
- package/src/feedback/toast.meta.ts +23 -0
- package/src/feedback/toast.story.ts +66 -0
- package/src/layout/clamp.meta.ts +29 -0
- package/src/layout/clamp.story.ts +59 -0
- package/src/layout/header-bar.meta.ts +14 -0
- package/src/layout/header-bar.story.ts +66 -0
- package/src/layout/toolbar-view.meta.ts +18 -0
- package/src/layout/toolbar-view.story.ts +71 -0
- package/src/layout/wrap-box.meta.ts +29 -0
- package/src/layout/wrap-box.story.ts +52 -0
- package/src/metas.ts +41 -0
- package/src/navigation/bottom-sheet.meta.ts +13 -0
- package/src/navigation/bottom-sheet.story.ts +90 -0
- package/src/navigation/navigation-split-view.meta.ts +13 -0
- package/src/navigation/navigation-split-view.story.ts +83 -0
- package/src/navigation/navigation-view.meta.ts +19 -0
- package/src/navigation/navigation-view.story.ts +77 -0
- package/src/navigation/overlay-split-view.meta.ts +13 -0
- package/src/navigation/overlay-split-view.story.ts +82 -0
- package/src/navigation/sidebar.meta.ts +30 -0
- package/src/navigation/sidebar.story.ts +85 -0
- package/src/presentation/avatar.meta.ts +24 -0
- package/src/presentation/avatar.story.ts +46 -0
- package/src/presentation/banner.meta.ts +19 -0
- package/src/presentation/banner.story.ts +53 -0
- package/src/presentation/spinner.meta.ts +9 -0
- package/src/presentation/spinner.story.ts +47 -0
- package/src/presentation/status-page.meta.ts +29 -0
- package/src/presentation/status-page.story.ts +55 -0
- package/src/presentation/window-title.meta.ts +12 -0
- package/src/presentation/window-title.story.ts +42 -0
- package/src/rows/action-row.meta.ts +30 -0
- package/src/rows/action-row.story.ts +62 -0
- package/src/rows/button-row.meta.ts +34 -0
- package/src/rows/button-row.story.ts +61 -0
- package/src/rows/combo-row.meta.ts +29 -0
- package/src/rows/combo-row.story.ts +51 -0
- package/src/rows/entry-row.meta.ts +13 -0
- package/src/rows/entry-row.story.ts +49 -0
- package/src/rows/expander-row.meta.ts +25 -0
- package/src/rows/expander-row.story.ts +54 -0
- package/src/rows/password-entry-row.meta.ts +12 -0
- package/src/rows/password-entry-row.story.ts +47 -0
- package/src/rows/preferences-group.meta.ts +18 -0
- package/src/rows/preferences-group.story.ts +67 -0
- package/src/rows/spin-row.meta.ts +29 -0
- package/src/rows/spin-row.story.ts +56 -0
- package/src/rows/switch-row.meta.ts +18 -0
- package/src/rows/switch-row.story.ts +49 -0
- package/src/view-switching/carousel.meta.ts +35 -0
- package/src/view-switching/carousel.story.ts +131 -0
- package/src/view-switching/inline-view-switcher.meta.ts +25 -0
- package/src/view-switching/inline-view-switcher.story.ts +88 -0
- package/src/view-switching/tab-view.meta.ts +12 -0
- package/src/view-switching/tab-view.story.ts +72 -0
- package/src/view-switching/view-switcher.meta.ts +23 -0
- package/src/view-switching/view-switcher.story.ts +87 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Adw.ActionRow — a boxed-list row pairing a title/subtitle with prefix/suffix
|
|
2
|
+
// widgets, optionally activatable. original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import Gtk from '@girs/gtk-4.0';
|
|
6
|
+
import GObject from '@girs/gobject-2.0';
|
|
7
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
8
|
+
import { actionRowMeta } from './action-row.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: Adw.ActionRow with a prefix icon and a suffix button inside a boxed list. */
|
|
11
|
+
export class ActionRowStory extends StoryWidget {
|
|
12
|
+
private _row: Adw.ActionRow | null = null;
|
|
13
|
+
private _icon: Gtk.Image | null = null;
|
|
14
|
+
private _button: Gtk.Button | null = null;
|
|
15
|
+
|
|
16
|
+
static {
|
|
17
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookActionRow' }, ActionRowStory);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super(StoryWidget.fromMeta(ActionRowStory.getMetadata(), 'Default'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getMetadata(): StoryMeta {
|
|
25
|
+
return { ...actionRowMeta, component: Adw.ActionRow.$gtype };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
initialize(): void {
|
|
29
|
+
this._row = new Adw.ActionRow({
|
|
30
|
+
title: this.args.title as string,
|
|
31
|
+
subtitle: this.args.subtitle as string,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
this._icon = new Gtk.Image({ iconName: this.args.iconName as string });
|
|
35
|
+
this._row.add_prefix(this._icon);
|
|
36
|
+
|
|
37
|
+
this._button = new Gtk.Button({ iconName: 'go-next-symbolic', valign: Gtk.Align.CENTER });
|
|
38
|
+
this._button.add_css_class('flat');
|
|
39
|
+
this._row.add_suffix(this._button);
|
|
40
|
+
|
|
41
|
+
this._row.activatableWidget = this._button;
|
|
42
|
+
this._row.activatable = this.args.activatable as boolean;
|
|
43
|
+
|
|
44
|
+
const group = new Adw.PreferencesGroup();
|
|
45
|
+
group.add(this._row);
|
|
46
|
+
|
|
47
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
48
|
+
this.addContent(clamp);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
updateArgs(_args: StoryArgs): void {
|
|
52
|
+
if (!this._row || !this._icon) return;
|
|
53
|
+
this._row.title = this.args.title as string;
|
|
54
|
+
this._row.subtitle = this.args.subtitle as string;
|
|
55
|
+
this._icon.iconName = this.args.iconName as string;
|
|
56
|
+
this._row.activatable = this.args.activatable as boolean;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
GObject.type_ensure(ActionRowStory.$gtype);
|
|
61
|
+
|
|
62
|
+
export const ActionRowStories: StoryModule = { stories: [ActionRowStory] };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Button Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const buttonRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Button Row',
|
|
7
|
+
description:
|
|
8
|
+
'Adw.ButtonRow — a full-width row that acts as a button, with an optional icon and style class.',
|
|
9
|
+
controls: [
|
|
10
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Add account' },
|
|
11
|
+
{
|
|
12
|
+
name: 'startIconName',
|
|
13
|
+
label: 'Start icon',
|
|
14
|
+
type: ControlType.SELECT,
|
|
15
|
+
options: [
|
|
16
|
+
{ label: 'Add', value: 'list-add-symbolic' },
|
|
17
|
+
{ label: 'Trash', value: 'user-trash-symbolic' },
|
|
18
|
+
{ label: 'None', value: '' },
|
|
19
|
+
],
|
|
20
|
+
defaultValue: 'list-add-symbolic',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'style',
|
|
24
|
+
label: 'Style',
|
|
25
|
+
type: ControlType.SELECT,
|
|
26
|
+
options: [
|
|
27
|
+
{ label: 'None', value: 'none' },
|
|
28
|
+
{ label: 'Suggested', value: 'suggested-action' },
|
|
29
|
+
{ label: 'Destructive', value: 'destructive-action' },
|
|
30
|
+
],
|
|
31
|
+
defaultValue: 'suggested-action',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Adw.ButtonRow — a boxed-list row that behaves like a button, with an optional
|
|
2
|
+
// start icon and an applied style class. original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import GObject from '@girs/gobject-2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { buttonRowMeta } from './button-row.meta.js';
|
|
8
|
+
|
|
9
|
+
const STYLE_CLASSES = ['suggested-action', 'destructive-action'];
|
|
10
|
+
|
|
11
|
+
/** Story: Adw.ButtonRow inside a boxed list, with a switchable style class. */
|
|
12
|
+
export class ButtonRowStory extends StoryWidget {
|
|
13
|
+
private _row: Adw.ButtonRow | null = null;
|
|
14
|
+
|
|
15
|
+
static {
|
|
16
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookButtonRow' }, ButtonRowStory);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
super(StoryWidget.fromMeta(ButtonRowStory.getMetadata(), 'Default'));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static getMetadata(): StoryMeta {
|
|
24
|
+
return { ...buttonRowMeta, component: Adw.ButtonRow.$gtype };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
initialize(): void {
|
|
28
|
+
this._row = new Adw.ButtonRow({
|
|
29
|
+
title: this.args.title as string,
|
|
30
|
+
startIconName: this.args.startIconName as string,
|
|
31
|
+
});
|
|
32
|
+
this._applyStyle(this.args.style as string);
|
|
33
|
+
|
|
34
|
+
const group = new Adw.PreferencesGroup();
|
|
35
|
+
group.add(this._row);
|
|
36
|
+
|
|
37
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
38
|
+
this.addContent(clamp);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private _applyStyle(style: string): void {
|
|
42
|
+
if (!this._row) return;
|
|
43
|
+
for (const cls of STYLE_CLASSES) {
|
|
44
|
+
this._row.remove_css_class(cls);
|
|
45
|
+
}
|
|
46
|
+
if (style !== 'none') {
|
|
47
|
+
this._row.add_css_class(style);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
updateArgs(_args: StoryArgs): void {
|
|
52
|
+
if (!this._row) return;
|
|
53
|
+
this._row.title = this.args.title as string;
|
|
54
|
+
this._row.startIconName = this.args.startIconName as string;
|
|
55
|
+
this._applyStyle(this.args.style as string);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
GObject.type_ensure(ButtonRowStory.$gtype);
|
|
60
|
+
|
|
61
|
+
export const ButtonRowStories: StoryModule = { stories: [ButtonRowStory] };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Combo Row story.
|
|
2
|
+
// The drop-down model is fixed; both renderers use the same option strings.
|
|
3
|
+
|
|
4
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
5
|
+
|
|
6
|
+
export const COMBO_ROW_OPTIONS = ['Blue', 'Teal', 'Green', 'Orange', 'Purple'] as const;
|
|
7
|
+
|
|
8
|
+
export const comboRowMeta: StoryMeta = {
|
|
9
|
+
title: 'Boxed Lists/Combo Row',
|
|
10
|
+
description: 'Adw.ComboRow — a preferences row with an inline drop-down backed by a Gtk.StringList.',
|
|
11
|
+
controls: [
|
|
12
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Accent colour' },
|
|
13
|
+
{
|
|
14
|
+
name: 'subtitle',
|
|
15
|
+
label: 'Subtitle',
|
|
16
|
+
type: ControlType.TEXT,
|
|
17
|
+
defaultValue: 'Used to highlight selected items',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'selected',
|
|
21
|
+
label: 'Selected',
|
|
22
|
+
type: ControlType.NUMBER,
|
|
23
|
+
min: 0,
|
|
24
|
+
max: 4,
|
|
25
|
+
step: 1,
|
|
26
|
+
defaultValue: 1,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Adw.ComboRow — a boxed-list row presenting a drop-down backed by a string list.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import Gtk from '@girs/gtk-4.0';
|
|
6
|
+
import GObject from '@girs/gobject-2.0';
|
|
7
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
8
|
+
import { COMBO_ROW_OPTIONS, comboRowMeta } from './combo-row.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: Adw.ComboRow inside a boxed list, selecting from a Gtk.StringList. */
|
|
11
|
+
export class ComboRowStory extends StoryWidget {
|
|
12
|
+
private _row: Adw.ComboRow | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookComboRow' }, ComboRowStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(ComboRowStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...comboRowMeta, component: Adw.ComboRow.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
this._row = new Adw.ComboRow({
|
|
28
|
+
title: this.args.title as string,
|
|
29
|
+
subtitle: this.args.subtitle as string,
|
|
30
|
+
model: new Gtk.StringList({ strings: [...COMBO_ROW_OPTIONS] }),
|
|
31
|
+
selected: this.args.selected as number,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const group = new Adw.PreferencesGroup();
|
|
35
|
+
group.add(this._row);
|
|
36
|
+
|
|
37
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
38
|
+
this.addContent(clamp);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
updateArgs(_args: StoryArgs): void {
|
|
42
|
+
if (!this._row) return;
|
|
43
|
+
this._row.title = this.args.title as string;
|
|
44
|
+
this._row.subtitle = this.args.subtitle as string;
|
|
45
|
+
this._row.selected = this.args.selected as number;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
GObject.type_ensure(ComboRowStory.$gtype);
|
|
50
|
+
|
|
51
|
+
export const ComboRowStories: StoryModule = { stories: [ComboRowStory] };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Entry Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const entryRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Entry Row',
|
|
7
|
+
description: 'Adw.EntryRow — a preferences row whose title doubles as placeholder text for an inline entry.',
|
|
8
|
+
controls: [
|
|
9
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Display name' },
|
|
10
|
+
{ name: 'text', label: 'Text', type: ControlType.TEXT, defaultValue: 'Ada Lovelace' },
|
|
11
|
+
{ name: 'showApplyButton', label: 'Show apply button', type: ControlType.BOOLEAN, defaultValue: true },
|
|
12
|
+
],
|
|
13
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Adw.EntryRow — a boxed-list row with an embedded text entry and an optional
|
|
2
|
+
// apply button. original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import GObject from '@girs/gobject-2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { entryRowMeta } from './entry-row.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: Adw.EntryRow inside a boxed list, with a toggleable apply button. */
|
|
10
|
+
export class EntryRowStory extends StoryWidget {
|
|
11
|
+
private _row: Adw.EntryRow | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookEntryRow' }, EntryRowStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(EntryRowStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...entryRowMeta, component: Adw.EntryRow.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._row = new Adw.EntryRow({
|
|
27
|
+
title: this.args.title as string,
|
|
28
|
+
text: this.args.text as string,
|
|
29
|
+
showApplyButton: this.args.showApplyButton as boolean,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const group = new Adw.PreferencesGroup();
|
|
33
|
+
group.add(this._row);
|
|
34
|
+
|
|
35
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
36
|
+
this.addContent(clamp);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
updateArgs(_args: StoryArgs): void {
|
|
40
|
+
if (!this._row) return;
|
|
41
|
+
this._row.title = this.args.title as string;
|
|
42
|
+
this._row.text = this.args.text as string;
|
|
43
|
+
this._row.showApplyButton = this.args.showApplyButton as boolean;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
GObject.type_ensure(EntryRowStory.$gtype);
|
|
48
|
+
|
|
49
|
+
export const EntryRowStories: StoryModule = { stories: [EntryRowStory] };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Expander Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const expanderRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Expander Row',
|
|
7
|
+
description:
|
|
8
|
+
'Adw.ExpanderRow — a preferences row that discloses nested rows and can carry an enable switch.',
|
|
9
|
+
controls: [
|
|
10
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Proxy settings' },
|
|
11
|
+
{
|
|
12
|
+
name: 'subtitle',
|
|
13
|
+
label: 'Subtitle',
|
|
14
|
+
type: ControlType.TEXT,
|
|
15
|
+
defaultValue: 'Route traffic through a custom proxy',
|
|
16
|
+
},
|
|
17
|
+
{ name: 'expanded', label: 'Expanded', type: ControlType.BOOLEAN, defaultValue: true },
|
|
18
|
+
{
|
|
19
|
+
name: 'showEnableSwitch',
|
|
20
|
+
label: 'Show enable switch',
|
|
21
|
+
type: ControlType.BOOLEAN,
|
|
22
|
+
defaultValue: false,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Adw.ExpanderRow — a boxed-list row that reveals nested rows when expanded, with
|
|
2
|
+
// an optional enable switch. original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import GObject from '@girs/gobject-2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { expanderRowMeta } from './expander-row.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: Adw.ExpanderRow with two nested rows inside a boxed list. */
|
|
10
|
+
export class ExpanderRowStory extends StoryWidget {
|
|
11
|
+
private _row: Adw.ExpanderRow | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookExpanderRow' }, ExpanderRowStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(ExpanderRowStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...expanderRowMeta, component: Adw.ExpanderRow.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._row = new Adw.ExpanderRow({
|
|
27
|
+
title: this.args.title as string,
|
|
28
|
+
subtitle: this.args.subtitle as string,
|
|
29
|
+
expanded: this.args.expanded as boolean,
|
|
30
|
+
showEnableSwitch: this.args.showEnableSwitch as boolean,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this._row.add_row(new Adw.EntryRow({ title: 'Host', text: 'proxy.example.com' }));
|
|
34
|
+
this._row.add_row(new Adw.SwitchRow({ title: 'Use authentication', active: false }));
|
|
35
|
+
|
|
36
|
+
const group = new Adw.PreferencesGroup();
|
|
37
|
+
group.add(this._row);
|
|
38
|
+
|
|
39
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
40
|
+
this.addContent(clamp);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
updateArgs(_args: StoryArgs): void {
|
|
44
|
+
if (!this._row) return;
|
|
45
|
+
this._row.title = this.args.title as string;
|
|
46
|
+
this._row.subtitle = this.args.subtitle as string;
|
|
47
|
+
this._row.expanded = this.args.expanded as boolean;
|
|
48
|
+
this._row.showEnableSwitch = this.args.showEnableSwitch as boolean;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
GObject.type_ensure(ExpanderRowStory.$gtype);
|
|
53
|
+
|
|
54
|
+
export const ExpanderRowStories: StoryModule = { stories: [ExpanderRowStory] };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Password Entry Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const passwordEntryRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Password Entry Row',
|
|
7
|
+
description: 'Adw.PasswordEntryRow — an entry row that masks its contents and shows a peek toggle.',
|
|
8
|
+
controls: [
|
|
9
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Password' },
|
|
10
|
+
{ name: 'text', label: 'Text', type: ControlType.TEXT, defaultValue: 'correct-horse-battery' },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Adw.PasswordEntryRow — a boxed-list entry row that masks its text and offers a
|
|
2
|
+
// peek toggle. original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import GObject from '@girs/gobject-2.0';
|
|
6
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
7
|
+
import { passwordEntryRowMeta } from './password-entry-row.meta.js';
|
|
8
|
+
|
|
9
|
+
/** Story: Adw.PasswordEntryRow inside a boxed list. */
|
|
10
|
+
export class PasswordEntryRowStory extends StoryWidget {
|
|
11
|
+
private _row: Adw.PasswordEntryRow | null = null;
|
|
12
|
+
|
|
13
|
+
static {
|
|
14
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookPasswordEntryRow' }, PasswordEntryRowStory);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super(StoryWidget.fromMeta(PasswordEntryRowStory.getMetadata(), 'Default'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMetadata(): StoryMeta {
|
|
22
|
+
return { ...passwordEntryRowMeta, component: Adw.PasswordEntryRow.$gtype };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
this._row = new Adw.PasswordEntryRow({
|
|
27
|
+
title: this.args.title as string,
|
|
28
|
+
text: this.args.text as string,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const group = new Adw.PreferencesGroup();
|
|
32
|
+
group.add(this._row);
|
|
33
|
+
|
|
34
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
35
|
+
this.addContent(clamp);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
updateArgs(_args: StoryArgs): void {
|
|
39
|
+
if (!this._row) return;
|
|
40
|
+
this._row.title = this.args.title as string;
|
|
41
|
+
this._row.text = this.args.text as string;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
GObject.type_ensure(PasswordEntryRowStory.$gtype);
|
|
46
|
+
|
|
47
|
+
export const PasswordEntryRowStories: StoryModule = { stories: [PasswordEntryRowStory] };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Preferences Group story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const preferencesGroupMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Preferences Group',
|
|
7
|
+
description:
|
|
8
|
+
'Adw.PreferencesGroup — the boxed-list container that gathers a title, description, header-suffix widget and rows.',
|
|
9
|
+
controls: [
|
|
10
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Account' },
|
|
11
|
+
{
|
|
12
|
+
name: 'description',
|
|
13
|
+
label: 'Description',
|
|
14
|
+
type: ControlType.TEXT,
|
|
15
|
+
defaultValue: 'Manage how this device signs in and syncs.',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Adw.PreferencesGroup — the boxed-list container itself: a titled group with a
|
|
2
|
+
// description, a header-suffix button and a set of mixed rows. original
|
|
3
|
+
// implementation.
|
|
4
|
+
|
|
5
|
+
import Adw from '@girs/adw-1';
|
|
6
|
+
import Gtk from '@girs/gtk-4.0';
|
|
7
|
+
import GObject from '@girs/gobject-2.0';
|
|
8
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
9
|
+
import { preferencesGroupMeta } from './preferences-group.meta.js';
|
|
10
|
+
|
|
11
|
+
/** Story: Adw.PreferencesGroup wrapping several rows, with a header-suffix button. */
|
|
12
|
+
export class PreferencesGroupStory extends StoryWidget {
|
|
13
|
+
private _prefsGroup: Adw.PreferencesGroup | null = null;
|
|
14
|
+
|
|
15
|
+
static {
|
|
16
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookPreferencesGroup' }, PreferencesGroupStory);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
super(StoryWidget.fromMeta(PreferencesGroupStory.getMetadata(), 'Default'));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static getMetadata(): StoryMeta {
|
|
24
|
+
return { ...preferencesGroupMeta, component: Adw.PreferencesGroup.$gtype };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
initialize(): void {
|
|
28
|
+
const headerButton = new Gtk.Button({ label: 'Sign out', valign: Gtk.Align.CENTER });
|
|
29
|
+
headerButton.add_css_class('flat');
|
|
30
|
+
|
|
31
|
+
this._prefsGroup = new Adw.PreferencesGroup({
|
|
32
|
+
title: this.args.title as string,
|
|
33
|
+
description: this.args.description as string,
|
|
34
|
+
headerSuffix: headerButton,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const nameRow = new Adw.EntryRow({ title: 'Display name', text: 'Grace Hopper' });
|
|
38
|
+
this._prefsGroup.add(nameRow);
|
|
39
|
+
|
|
40
|
+
const syncRow = new Adw.SwitchRow({
|
|
41
|
+
title: 'Sync over Wi-Fi only',
|
|
42
|
+
subtitle: 'Avoid using mobile data for backups',
|
|
43
|
+
active: true,
|
|
44
|
+
});
|
|
45
|
+
this._prefsGroup.add(syncRow);
|
|
46
|
+
|
|
47
|
+
const regionRow = new Adw.ComboRow({
|
|
48
|
+
title: 'Region',
|
|
49
|
+
model: new Gtk.StringList({ strings: ['Europe', 'Americas', 'Asia', 'Oceania'] }),
|
|
50
|
+
selected: 0,
|
|
51
|
+
});
|
|
52
|
+
this._prefsGroup.add(regionRow);
|
|
53
|
+
|
|
54
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: this._prefsGroup });
|
|
55
|
+
this.addContent(clamp);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
updateArgs(_args: StoryArgs): void {
|
|
59
|
+
if (!this._prefsGroup) return;
|
|
60
|
+
this._prefsGroup.title = this.args.title as string;
|
|
61
|
+
this._prefsGroup.description = this.args.description as string;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
GObject.type_ensure(PreferencesGroupStory.$gtype);
|
|
66
|
+
|
|
67
|
+
export const PreferencesGroupStories: StoryModule = { stories: [PreferencesGroupStory] };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Spin Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const spinRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Spin Row',
|
|
7
|
+
description: 'Adw.SpinRow — a preferences row with an inline spin button over a numeric adjustment.',
|
|
8
|
+
controls: [
|
|
9
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Font size' },
|
|
10
|
+
{
|
|
11
|
+
name: 'value',
|
|
12
|
+
label: 'Value',
|
|
13
|
+
type: ControlType.NUMBER,
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 100,
|
|
16
|
+
step: 1,
|
|
17
|
+
defaultValue: 16,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'digits',
|
|
21
|
+
label: 'Digits',
|
|
22
|
+
type: ControlType.NUMBER,
|
|
23
|
+
min: 0,
|
|
24
|
+
max: 4,
|
|
25
|
+
step: 1,
|
|
26
|
+
defaultValue: 0,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Adw.SpinRow — a boxed-list row embedding a spin button over an adjustment.
|
|
2
|
+
// original implementation.
|
|
3
|
+
|
|
4
|
+
import Adw from '@girs/adw-1';
|
|
5
|
+
import Gtk from '@girs/gtk-4.0';
|
|
6
|
+
import GObject from '@girs/gobject-2.0';
|
|
7
|
+
import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
8
|
+
import { spinRowMeta } from './spin-row.meta.js';
|
|
9
|
+
|
|
10
|
+
/** Story: Adw.SpinRow inside a boxed list, driven by a Gtk.Adjustment. */
|
|
11
|
+
export class SpinRowStory extends StoryWidget {
|
|
12
|
+
private _row: Adw.SpinRow | null = null;
|
|
13
|
+
|
|
14
|
+
static {
|
|
15
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookSpinRow' }, SpinRowStory);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super(StoryWidget.fromMeta(SpinRowStory.getMetadata(), 'Default'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getMetadata(): StoryMeta {
|
|
23
|
+
return { ...spinRowMeta, component: Adw.SpinRow.$gtype };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initialize(): void {
|
|
27
|
+
this._row = new Adw.SpinRow({
|
|
28
|
+
title: this.args.title as string,
|
|
29
|
+
adjustment: new Gtk.Adjustment({
|
|
30
|
+
lower: 0,
|
|
31
|
+
upper: 100,
|
|
32
|
+
value: this.args.value as number,
|
|
33
|
+
stepIncrement: 1,
|
|
34
|
+
pageIncrement: 10,
|
|
35
|
+
}),
|
|
36
|
+
digits: this.args.digits as number,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const group = new Adw.PreferencesGroup();
|
|
40
|
+
group.add(this._row);
|
|
41
|
+
|
|
42
|
+
const clamp = new Adw.Clamp({ maximumSize: 400, child: group });
|
|
43
|
+
this.addContent(clamp);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
updateArgs(_args: StoryArgs): void {
|
|
47
|
+
if (!this._row) return;
|
|
48
|
+
this._row.title = this.args.title as string;
|
|
49
|
+
this._row.value = this.args.value as number;
|
|
50
|
+
this._row.digits = this.args.digits as number;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
GObject.type_ensure(SpinRowStory.$gtype);
|
|
55
|
+
|
|
56
|
+
export const SpinRowStories: StoryModule = { stories: [SpinRowStory] };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Shared, renderer-agnostic metadata for the Switch Row story.
|
|
2
|
+
|
|
3
|
+
import { ControlType, type StoryMeta } from '@gjsify/stories';
|
|
4
|
+
|
|
5
|
+
export const switchRowMeta: StoryMeta = {
|
|
6
|
+
title: 'Boxed Lists/Switch Row',
|
|
7
|
+
description: 'Adw.SwitchRow — a preferences row with a trailing switch, shown inside a boxed list.',
|
|
8
|
+
controls: [
|
|
9
|
+
{ name: 'title', label: 'Title', type: ControlType.TEXT, defaultValue: 'Automatic updates' },
|
|
10
|
+
{
|
|
11
|
+
name: 'subtitle',
|
|
12
|
+
label: 'Subtitle',
|
|
13
|
+
type: ControlType.TEXT,
|
|
14
|
+
defaultValue: 'Download and install updates without asking',
|
|
15
|
+
},
|
|
16
|
+
{ name: 'active', label: 'Active', type: ControlType.BOOLEAN, defaultValue: true },
|
|
17
|
+
],
|
|
18
|
+
};
|