@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
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Adwaita Storybook
|
|
2
|
+
|
|
3
|
+
An interactive **component browser for [Libadwaita](https://gnome.pages.gitlab.gnome.org/libadwaita/)**
|
|
4
|
+
widgets — the GNOME equivalent of a web "storybook". Each widget is rendered live, in
|
|
5
|
+
isolation, with a two-way-bound **Controls** panel so you can poke at its properties and
|
|
6
|
+
watch it update.
|
|
7
|
+
|
|
8
|
+
It is a showcase for three pieces of gjsify tooling working together:
|
|
9
|
+
|
|
10
|
+
- **[`@gjsify/storybook`](../../../packages/framework/storybook)** — the GTK/Adwaita story
|
|
11
|
+
renderer (sidebar by category, live control panel).
|
|
12
|
+
- **[`@gjsify/stories`](../../../packages/framework/stories)** — the pure-TS story contract.
|
|
13
|
+
- **[`@gjsify/devtools`](../../../packages/framework/devtools)** — a DBus + MCP control plane
|
|
14
|
+
that lets an agent (or you, with `gdbus`) drive and screenshot every story headlessly.
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
## Run it
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# from this directory
|
|
22
|
+
gjsify storybook # discover every *.story.ts, build (--app gjs), launch the browser
|
|
23
|
+
gjsify storybook --watch # rebuild + relaunch on change
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`gjsify storybook` reads the `gjsify.storybook` block in [`package.json`](package.json)
|
|
27
|
+
(application id, window title, the `src` story dir, and `--globals auto`). No per-project
|
|
28
|
+
storybook *app* — just `*.story.ts` files plus the shared renderer.
|
|
29
|
+
|
|
30
|
+
## Debug / drive it over DBus + MCP
|
|
31
|
+
|
|
32
|
+
Launch with the devtools control plane enabled, then drive it from `gdbus`, an MCP client,
|
|
33
|
+
or the bundled harness:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
GJSIFY_DEVTOOLS=1 gjsify storybook # exports org.gjsify.Devtools on the session bus
|
|
37
|
+
# in another shell — list + open stories, read/set args:
|
|
38
|
+
gdbus call --session --dest org.gjsify.AdwaitaStorybook \
|
|
39
|
+
--object-path /org/gjsify/AdwaitaStorybook/devtools \
|
|
40
|
+
--method org.gjsify.Devtools.ListStories
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Over MCP (the storybook profile adds `list_stories` / `open_story` / `get_current_story` /
|
|
44
|
+
`set_story_arg` on top of the generic `screenshot` / `swap_css` / … tools):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
gjsify debug --profile storybook # MCP bridge to a running storybook
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Screenshot every story
|
|
51
|
+
|
|
52
|
+
[`tools/shoot-stories.js`](tools/shoot-stories.js) opens each story over the devtools DBus
|
|
53
|
+
surface and saves a GSK-rendered PNG of the window — the same path used to review this
|
|
54
|
+
showcase:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
GJSIFY_DEVTOOLS=1 gjsify storybook & # launch
|
|
58
|
+
gjs -m tools/shoot-stories.js org.gjsify.AdwaitaStorybook ./shots # capture all stories
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Stories
|
|
62
|
+
|
|
63
|
+
Stories live under [`src/`](src), grouped into category folders. The sidebar group comes
|
|
64
|
+
from the `"Category/Name"` story `title`, not the folder.
|
|
65
|
+
|
|
66
|
+
| Category | Widgets |
|
|
67
|
+
|---|---|
|
|
68
|
+
| Presentation | Avatar, Banner, StatusPage, Spinner, WindowTitle |
|
|
69
|
+
| Boxed Lists | ActionRow, EntryRow, PasswordEntryRow, ComboRow, SpinRow, SwitchRow, ExpanderRow, ButtonRow, PreferencesGroup |
|
|
70
|
+
| Buttons | SplitButton, ButtonContent, ToggleGroup, button style classes |
|
|
71
|
+
| Layout | Clamp, WrapBox, ToolbarView, HeaderBar |
|
|
72
|
+
| Navigation | NavigationView, NavigationSplitView, OverlaySplitView, BottomSheet, Sidebar |
|
|
73
|
+
| View Switching | ViewSwitcher + ViewStack, InlineViewSwitcher, Carousel, TabView |
|
|
74
|
+
| Feedback | Toast, AlertDialog, AboutDialog, PreferencesDialog |
|
|
75
|
+
|
|
76
|
+
## Add a story
|
|
77
|
+
|
|
78
|
+
A story is a `StoryWidget` subclass with a `static getMetadata(): StoryMeta` (the
|
|
79
|
+
`"Category/Name"` title groups the sidebar, the `controls` drive the live panel),
|
|
80
|
+
exported as a `StoryModule`. See [`src/presentation/avatar.story.ts`](src/presentation/avatar.story.ts)
|
|
81
|
+
for the canonical pattern:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import Adw from '@girs/adw-1';
|
|
85
|
+
import GObject from '@girs/gobject-2.0';
|
|
86
|
+
import { ControlType, type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@gjsify/storybook';
|
|
87
|
+
|
|
88
|
+
export class MyStory extends StoryWidget {
|
|
89
|
+
private _widget: Adw.Avatar | null = null;
|
|
90
|
+
static {
|
|
91
|
+
GObject.registerClass({ GTypeName: 'AdwStorybookMyStory' }, MyStory);
|
|
92
|
+
}
|
|
93
|
+
constructor() {
|
|
94
|
+
super(StoryWidget.fromMeta(MyStory.getMetadata(), 'Default'));
|
|
95
|
+
}
|
|
96
|
+
static getMetadata(): StoryMeta {
|
|
97
|
+
return {
|
|
98
|
+
title: 'Presentation/My Widget',
|
|
99
|
+
controls: [{ name: 'text', label: 'Text', type: ControlType.TEXT, defaultValue: 'Hi' }],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
initialize(): void {
|
|
103
|
+
this._widget = new Adw.Avatar({ text: this.args.text as string, size: 96 });
|
|
104
|
+
this.addContent(this._widget);
|
|
105
|
+
}
|
|
106
|
+
updateArgs(_args: StoryArgs): void {
|
|
107
|
+
if (this._widget) this._widget.text = this.args.text as string;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
GObject.type_ensure(MyStory.$gtype);
|
|
111
|
+
export const MyStories: StoryModule = { stories: [MyStory] };
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Rules of thumb: globally-unique `GTypeName` (prefix `AdwStorybook…`), wrap `Adw.*Row`s in an
|
|
115
|
+
`Adw.PreferencesGroup`, give space-filling widgets a `widthRequest`/`heightRequest`, and
|
|
116
|
+
present dialogs from a button rather than embedding them.
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT © Pascal Garber. Libadwaita is LGPL-2.1+ © GNOME contributors.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import"@gjsify/node-gi/globals";var t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0});const n=e(import.meta.url);let r;function load$3(){return r===void 0&&(r=n(`@gjsify/node-gi/gi`).requireGi(`Adw`,`1`)),r}__name(load$3,`load`);var i=new Proxy(Object.create(null),{get(e,t){return load$3()[t]},has(e,t){return t in load$3()}});const a=e(import.meta.url);let o;function load$2(){return o===void 0&&(o=a(`@gjsify/node-gi/gi`).requireGi(`Gtk`,`4.0`)),o}__name(load$2,`load`);var s=new Proxy(Object.create(null),{get(e,t){return load$2()[t]},has(e,t){return t in load$2()}});const c=e(import.meta.url);let l;function load$1(){return l===void 0&&(l=c(`@gjsify/node-gi/gi`).requireGi(`Gio`,`2.0`)),l}__name(load$1,`load`);var u=new Proxy(Object.create(null),{get(e,t){return load$1()[t]},has(e,t){return t in load$1()}});const d=e(import.meta.url);let f;function load(){return f===void 0&&(f=d("@gjsify/node-gi/gi").requireGi(`GLib`,`2.0`)),f}var p=new Proxy(Object.create(null),{get(e,t){return load()[t]},has(e,t){return t in load()}});print(`A: start`);const m=new i.Application({application_id:`org.gjsify.AdwRunAsync`,flags:u.ApplicationFlags.NON_UNIQUE});m.connect(`activate`,()=>{print(`C: activate`);let e=new i.ApplicationWindow({application:m}),t=new i.ToolbarView;t.add_top_bar(new i.HeaderBar),t.set_content(new s.Label({label:`hi from node-gi`})),e.set_content(t),print(`D: window built, presenting`),e.present(),print(`E: presented`),p.timeout_add(p.PRIORITY_DEFAULT,600,()=>(print(`F: timeout in loop, windows=`+m.get_windows().length),m.quit(),p.SOURCE_REMOVE))}),print(`B: runAsync`);const h=await m.runAsync([]);print(`G: resolved status=`+h);export{};
|