@gjsify/storybook 0.51.0 → 0.52.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 +10 -0
- package/lib/esm/window.js +1 -1
- package/lib/esm/window2.js +141 -0
- package/lib/types/window.d.ts +6 -5
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -116,6 +116,16 @@ That is how `gjsify storybook --runtime node` proves the full Libadwaita gallery
|
|
|
116
116
|
on Linux AND on Windows (the `--windowing` GTK bundle, no gvsbuild): CI
|
|
117
117
|
`storybook-node-gi-bundle` feeds `gtk-smoke` and `windows-gtk-storybook`.
|
|
118
118
|
|
|
119
|
+
**Both are `node-gi.yml` legs, so read the Windows half with its condition attached.**
|
|
120
|
+
`windows-gtk-storybook` needs `windows`, and `node-gi.yml`'s `scope` job runs the Windows
|
|
121
|
+
matrix only when `packages/node-gi/**` (or the consumer harness, the workflow itself, or
|
|
122
|
+
`.github/scripts/**`) changed — plus every `workflow_dispatch` and the 03:17 UTC nightly,
|
|
123
|
+
which run the full matrix by definition. So "renders on Windows" is a statement about the
|
|
124
|
+
last run that EXECUTED that leg, not about this commit: on a consumer-only `main` push the
|
|
125
|
+
leg is `skipped`, which is the same colour as green, and `ci-summary`'s gate-history table
|
|
126
|
+
is what names the SHA where it last actually ran. The Linux `gtk-smoke` leg has no such
|
|
127
|
+
caveat.
|
|
128
|
+
|
|
119
129
|
## Exports
|
|
120
130
|
|
|
121
131
|
- `StoryWidget` — Adw.Bin base class; `fromMeta()`, `addContent()`, `initialize()`/`updateArgs()`/`teardown()` hooks
|
package/lib/esm/window.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{StorybookAppearance as e,buildAppearanceDialog as t}from"./appearance.js";import n from"gi://Adw?version=1";import
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{StorybookAppearance as e,buildAppearanceDialog as t}from"./appearance.js";import n from"./window2.js";import r from"gi://Adw?version=1";import i from"gi://Gdk?version=4.0";import a from"gi://Gtk?version=4.0";import{StorybookController as o,bindControl as s}from"@gjsify/storybook-core";import c from"gi://GObject?version=2.0";function adwControlWidgetFactory(){return{text(e,t){let n=new r.EntryRow({title:e});t&&n.set_tooltip_text(t);let i=null;return n.connect(`changed`,()=>i?.(n.get_text())),{node:n,get:()=>n.get_text(),set:e=>n.set_text(e),onChange:e=>{i=e}}},boolean(e,t){let n=new r.SwitchRow({title:e,subtitle:t??``}),i=null;return n.connect(`notify::active`,()=>i?.(n.get_active())),{node:n,get:()=>n.get_active(),set:e=>n.set_active(e),onChange:e=>{i=e}}},number(e){let t=r.SpinRow.new_with_range(e.min??0,e.max??100,e.step??1);t.set_title(e.label||e.name),e.description&&t.set_subtitle(e.description);let n=null;return t.connect(`changed`,()=>n?.(t.get_value())),{node:t,get:()=>t.get_value(),set:e=>t.set_value(e),onChange:e=>{n=e}}},range(e){return buildRangeWidget(e)},select(e){return buildSelectWidget(e)},color(e,t){return buildColorWidget(e,t)}}}function buildRangeWidget(e){let t=e.min??0,n=e.max??100,r=e.step??1,i=typeof e.min==`number`?e.min:0,o=Number.isInteger(r)&&Number.isInteger(i),s=new a.Adjustment({lower:t,upper:n,step_increment:r,value:i});s.step_increment=r;let c=new a.ListBoxRow({selectable:!1,activatable:!1});c.add_css_class(`story-range-row`);let l=new a.Box({orientation:a.Orientation.VERTICAL,spacing:6,margin_top:12,margin_bottom:12,margin_start:12,margin_end:12}),u=new a.Box({orientation:a.Orientation.HORIZONTAL,spacing:12}),d=new a.Label({label:e.label||e.name,halign:a.Align.START,hexpand:!0,ellipsize:3});d.add_css_class(`heading`);let formatValue=e=>o?String(Math.round(e)):e.toFixed(2),f=new a.Label({label:formatValue(i),halign:a.Align.END});if(f.add_css_class(`numeric`),f.add_css_class(`dim-label`),u.append(d),u.append(f),l.append(u),e.description){let t=new a.Label({label:e.description,halign:a.Align.START,xalign:0,wrap:!0,max_width_chars:32});t.add_css_class(`caption`),t.add_css_class(`dim-label`),l.append(t)}let p=new a.Scale({orientation:a.Orientation.HORIZONTAL,adjustment:s,draw_value:!1,hexpand:!0}),m=null,h=!1;return p.connect(`value-changed`,()=>{if(h)return;let e=p.get_value();if(o){let t=Math.round(e);if(t!==e){p.set_value(t);return}e=t}f.set_label(formatValue(e)),m?.(e)}),l.append(p),c.set_child(l),{node:c,get:()=>p.get_value(),set:e=>{h=!0,p.set_value(e),h=!1,f.set_label(formatValue(e))},onChange:e=>{m=e}}}function buildSelectWidget(e){let t=e.options??[],n=a.StringList.new(t.map(e=>e.label)),i=new r.ComboRow({title:e.label||e.name,subtitle:e.description??``,model:n}),o=null;return i.connect(`notify::selected`,()=>o?.(i.get_selected())),{node:i,get:()=>i.get_selected(),set:e=>i.set_selected(e),onChange:e=>{o=e}}}function buildColorWidget(e,t){let n=new r.ActionRow({title:e,subtitle:t??``}),o=new a.ColorDialogButton({dialog:new a.ColorDialog({title:e}),valign:a.Align.CENTER});n.add_suffix(o),n.set_activatable_widget(o);let channel=e=>Math.round(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`),rgbaToHex=e=>`#${channel(e.red)}${channel(e.green)}${channel(e.blue)}`,s=null,c=!1;return o.connect(`notify::rgba`,()=>{c||s?.(rgbaToHex(o.get_rgba()))}),{node:n,get:()=>rgbaToHex(o.get_rgba()),set:e=>{let t=new i.RGBA;t.parse(e)&&(c=!0,o.set_rgba(t),c=!1)},onChange:e=>{s=e}}}var l=class StorybookWindow extends r.ApplicationWindow{static{c.registerClass({GTypeName:`StorybookWindow`,Template:n,InternalChildren:[`sidebar_list`,`content_area`,`control_panel`,`preview_title`,`show_controls_button`,`controls_split_view`,`main_split_view`]},StorybookWindow)}constructor(t){super(t),this._appearance=new e,this._controlRows=[],this._rowByTitle=new Map,this._onSelect=null,this._suppressSelect=!1,this._controller=new o(this,e=>this._buildControls(e))}_onRowSelected(e,t){if(this._suppressSelect||!t)return;let n=t;n.storyWidget&&this._onSelect?.(n.storyWidget)}get controller(){return this._controller}_buildControls(e){let t=e.meta.controls;if(!Array.isArray(t))return[];let n=adwControlWidgetFactory(),r=[];for(let i of t){if(!i?.name||!i?.type){console.warn(`Invalid control configuration:`,i);continue}let t=s(e,i,n);t&&r.push(t)}return r}_onAppearanceClicked(){t(this._appearance).present(this)}_onToggleControls(e){this._controls_split_view.set_show_sidebar(e.get_active())}populateSidebar(e){this._controller.mount(e,!0)}renderSidebar(e,t){this._onSelect=t,this._suppressSelect=!0,this._clearSidebar(),this._rowByTitle.clear();for(let t of e){this._addCategoryToSidebar(t.category);for(let{instance:e,name:n}of t.stories)this._addStoryToSidebar(e,n)}this._suppressSelect=!1}markSelected(e){let t=this._rowByTitle.get(e);t&&this._sidebar_list.get_selected_row()!==t&&(this._suppressSelect=!0,this._sidebar_list.select_row(t),this._suppressSelect=!1)}setPreviewTitle(e){this._preview_title.set_title(e)}showPreview(e){this._content_area.set_child(e),this._main_split_view.get_collapsed()&&this._main_split_view.set_show_content(!0)}renderControls(e){this._clearControlPanel();for(let t of e){let e=t.view;e instanceof r.PreferencesRow&&e.set_use_markup(!1),this._control_panel.add(e),this._controlRows.push(e)}this._show_controls_button.set_active(!0)}_clearSidebar(){let e=this._sidebar_list.get_first_child();for(;e;){let t=e.get_next_sibling();e.unparent(),e=t}}_addCategoryToSidebar(e){let t=new a.ListBoxRow({selectable:!1}),n=new a.Label({label:e,halign:a.Align.START,margin_top:10,margin_bottom:4,margin_start:12,margin_end:12});n.add_css_class(`heading`),n.add_css_class(`dim-label`),t.set_child(n),this._sidebar_list.append(t)}_addStoryToSidebar(e,t){let n=new a.ListBoxRow,r=new a.Label({label:t||`Unnamed Story`,halign:a.Align.START,margin_start:20,margin_top:6,margin_bottom:6});n.set_child(r),this._sidebar_list.append(n),n.storyWidget=e,this._rowByTitle.set(e.meta.title,n)}_clearControlPanel(){for(let e of this._controlRows)this._control_panel.remove(e);this._controlRows=[]}get activeStory(){return this._controller.activeStory}openStoryByTitle(e){return this._controller.openStoryByTitle(e)}setActiveArg(e,t){return this._controller.setActiveArg(e,t)}};c.type_ensure(l.$gtype);export{l as StorybookWindow};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var e=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
DO NOT EDIT!
|
|
4
|
+
This file was @generated by blueprint-compiler. Instead, edit the
|
|
5
|
+
corresponding .blp file and regenerate this file with blueprint-compiler.
|
|
6
|
+
-->
|
|
7
|
+
<interface>
|
|
8
|
+
<requires lib="gtk" version="4.0"/>
|
|
9
|
+
<template class="StorybookWindow" parent="AdwApplicationWindow">
|
|
10
|
+
<property name="default-width">1200</property>
|
|
11
|
+
<property name="default-height">800</property>
|
|
12
|
+
<property name="width-request">360</property>
|
|
13
|
+
<property name="height-request">320</property>
|
|
14
|
+
<property name="title">Storybook</property>
|
|
15
|
+
<property name="content">
|
|
16
|
+
<object class="AdwNavigationSplitView" id="main_split_view">
|
|
17
|
+
<property name="min-sidebar-width">220</property>
|
|
18
|
+
<property name="max-sidebar-width">320</property>
|
|
19
|
+
<property name="sidebar">
|
|
20
|
+
<object class="AdwNavigationPage">
|
|
21
|
+
<property name="title">Stories</property>
|
|
22
|
+
<property name="tag">stories</property>
|
|
23
|
+
<property name="child">
|
|
24
|
+
<object class="AdwToolbarView">
|
|
25
|
+
<property name="top-bar-style">0</property>
|
|
26
|
+
<child type="top">
|
|
27
|
+
<object class="AdwHeaderBar">
|
|
28
|
+
<property name="show-end-title-buttons">false</property>
|
|
29
|
+
<property name="title-widget">
|
|
30
|
+
<object class="AdwWindowTitle">
|
|
31
|
+
<property name="title">Stories</property>
|
|
32
|
+
</object>
|
|
33
|
+
</property>
|
|
34
|
+
</object>
|
|
35
|
+
</child>
|
|
36
|
+
<property name="content">
|
|
37
|
+
<object class="GtkScrolledWindow">
|
|
38
|
+
<property name="hexpand">true</property>
|
|
39
|
+
<property name="vexpand">true</property>
|
|
40
|
+
<child>
|
|
41
|
+
<object class="GtkListBox" id="sidebar_list">
|
|
42
|
+
<property name="selection-mode">1</property>
|
|
43
|
+
<signal name="row-selected" handler="_onRowSelected"/>
|
|
44
|
+
<style>
|
|
45
|
+
<class name="navigation-sidebar"/>
|
|
46
|
+
</style>
|
|
47
|
+
</object>
|
|
48
|
+
</child>
|
|
49
|
+
</object>
|
|
50
|
+
</property>
|
|
51
|
+
</object>
|
|
52
|
+
</property>
|
|
53
|
+
</object>
|
|
54
|
+
</property>
|
|
55
|
+
<property name="content">
|
|
56
|
+
<object class="AdwNavigationPage">
|
|
57
|
+
<property name="title">Preview</property>
|
|
58
|
+
<property name="tag">preview</property>
|
|
59
|
+
<property name="child">
|
|
60
|
+
<object class="AdwToolbarView">
|
|
61
|
+
<property name="top-bar-style">0</property>
|
|
62
|
+
<child type="top">
|
|
63
|
+
<object class="AdwHeaderBar">
|
|
64
|
+
<property name="title-widget">
|
|
65
|
+
<object class="AdwWindowTitle" id="preview_title">
|
|
66
|
+
<property name="title">Preview</property>
|
|
67
|
+
</object>
|
|
68
|
+
</property>
|
|
69
|
+
<child type="end">
|
|
70
|
+
<object class="GtkToggleButton" id="show_controls_button">
|
|
71
|
+
<property name="icon-name">sidebar-show-right-symbolic</property>
|
|
72
|
+
<property name="tooltip-text">Toggle Controls</property>
|
|
73
|
+
<property name="active">true</property>
|
|
74
|
+
<signal name="toggled" handler="_onToggleControls"/>
|
|
75
|
+
</object>
|
|
76
|
+
</child>
|
|
77
|
+
<child type="end">
|
|
78
|
+
<object class="GtkButton">
|
|
79
|
+
<property name="icon-name">applications-graphics-symbolic</property>
|
|
80
|
+
<property name="tooltip-text">Appearance</property>
|
|
81
|
+
<signal name="clicked" handler="_onAppearanceClicked"/>
|
|
82
|
+
</object>
|
|
83
|
+
</child>
|
|
84
|
+
</object>
|
|
85
|
+
</child>
|
|
86
|
+
<property name="content">
|
|
87
|
+
<object class="AdwOverlaySplitView" id="controls_split_view">
|
|
88
|
+
<property name="show-sidebar">true</property>
|
|
89
|
+
<property name="sidebar-position">1</property>
|
|
90
|
+
<property name="min-sidebar-width">280</property>
|
|
91
|
+
<property name="max-sidebar-width">360</property>
|
|
92
|
+
<style>
|
|
93
|
+
<class name="storybook-controls"/>
|
|
94
|
+
</style>
|
|
95
|
+
<property name="content">
|
|
96
|
+
<object class="GtkScrolledWindow">
|
|
97
|
+
<property name="hexpand">true</property>
|
|
98
|
+
<property name="vexpand">true</property>
|
|
99
|
+
<style>
|
|
100
|
+
<class name="sb-preview-area"/>
|
|
101
|
+
</style>
|
|
102
|
+
<child>
|
|
103
|
+
<object class="AdwBin" id="content_area">
|
|
104
|
+
<property name="hexpand">true</property>
|
|
105
|
+
<property name="vexpand">true</property>
|
|
106
|
+
</object>
|
|
107
|
+
</child>
|
|
108
|
+
</object>
|
|
109
|
+
</property>
|
|
110
|
+
<property name="sidebar">
|
|
111
|
+
<object class="GtkScrolledWindow">
|
|
112
|
+
<property name="vexpand">true</property>
|
|
113
|
+
<child>
|
|
114
|
+
<object class="AdwPreferencesPage">
|
|
115
|
+
<child>
|
|
116
|
+
<object class="AdwPreferencesGroup" id="control_panel">
|
|
117
|
+
<property name="title">Controls</property>
|
|
118
|
+
</object>
|
|
119
|
+
</child>
|
|
120
|
+
</object>
|
|
121
|
+
</child>
|
|
122
|
+
</object>
|
|
123
|
+
</property>
|
|
124
|
+
</object>
|
|
125
|
+
</property>
|
|
126
|
+
</object>
|
|
127
|
+
</property>
|
|
128
|
+
</object>
|
|
129
|
+
</property>
|
|
130
|
+
</object>
|
|
131
|
+
</property>
|
|
132
|
+
<child>
|
|
133
|
+
<object class="AdwBreakpoint">
|
|
134
|
+
<condition>max-width: 720sp</condition>
|
|
135
|
+
<setter object="main_split_view" property="collapsed">true</setter>
|
|
136
|
+
<setter object="controls_split_view" property="collapsed">true</setter>
|
|
137
|
+
</object>
|
|
138
|
+
</child>
|
|
139
|
+
</template>
|
|
140
|
+
</interface>
|
|
141
|
+
`;export{e as default};
|
package/lib/types/window.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Adw from 'gi://Adw?version=1';
|
|
2
|
+
import Gtk from 'gi://Gtk?version=4.0';
|
|
2
3
|
import type { StoryArgValue } from '@gjsify/stories';
|
|
3
4
|
import { type CategoryGroup, type ControlRow, StorybookController, type StorybookView } from '@gjsify/storybook-core';
|
|
4
5
|
import type { StoryModule, StoryWidget } from './story-widget.js';
|
|
@@ -15,22 +16,22 @@ export declare class StorybookWindow extends Adw.ApplicationWindow implements St
|
|
|
15
16
|
private _control_panel;
|
|
16
17
|
private _preview_title;
|
|
17
18
|
private _show_controls_button;
|
|
18
|
-
/** Colour scheme + accent for the whole storybook, not for one story. */
|
|
19
|
-
private _appearance;
|
|
20
19
|
private _controls_split_view;
|
|
21
20
|
private _main_split_view;
|
|
21
|
+
/** Colour scheme + accent for the whole storybook, not for one story. */
|
|
22
|
+
private _appearance;
|
|
22
23
|
private _controlRows;
|
|
23
24
|
private _rowByTitle;
|
|
24
25
|
private _controller;
|
|
25
26
|
private _onSelect;
|
|
26
27
|
private _suppressSelect;
|
|
27
28
|
constructor(params: Partial<Adw.ApplicationWindow.ConstructorProps>);
|
|
28
|
-
|
|
29
|
+
protected _onRowSelected(_listbox: Gtk.ListBox, row: Gtk.ListBoxRow | null): void;
|
|
29
30
|
/** The controller driving this window (exposed for the devtools extension). */
|
|
30
31
|
get controller(): StorybookController<StoryWidget>;
|
|
31
32
|
private _buildControls;
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
protected _onAppearanceClicked(): void;
|
|
34
|
+
protected _onToggleControls(button: Gtk.ToggleButton): void;
|
|
34
35
|
/**
|
|
35
36
|
* Populate the sidebar with story modules. Registers + instantiates them via
|
|
36
37
|
* the controller (which renders the sidebar through this view's
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Reusable GTK/Adwaita storybook for GJS — author *.story.ts and browse them in a generic component explorer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -34,22 +34,23 @@
|
|
|
34
34
|
"ui"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@girs/adw-1": "5.
|
|
38
|
-
"@girs/gdk-4.0": "5.
|
|
39
|
-
"@girs/gio-2.0": "5.
|
|
40
|
-
"@girs/gjs": "5.
|
|
41
|
-
"@girs/glib-2.0": "5.
|
|
42
|
-
"@girs/gobject-2.0": "5.
|
|
43
|
-
"@girs/gtk-4.0": "5.
|
|
44
|
-
"@gjsify/adwaita-app": "^0.
|
|
45
|
-
"@gjsify/adwaita-core": "^0.
|
|
46
|
-
"@gjsify/devtools": "^0.
|
|
47
|
-
"@gjsify/stories": "^0.
|
|
48
|
-
"@gjsify/storybook-core": "^0.
|
|
37
|
+
"@girs/adw-1": "5.4.0",
|
|
38
|
+
"@girs/gdk-4.0": "5.4.0",
|
|
39
|
+
"@girs/gio-2.0": "5.4.0",
|
|
40
|
+
"@girs/gjs": "5.4.0",
|
|
41
|
+
"@girs/glib-2.0": "5.4.0",
|
|
42
|
+
"@girs/gobject-2.0": "5.4.0",
|
|
43
|
+
"@girs/gtk-4.0": "5.4.0",
|
|
44
|
+
"@gjsify/adwaita-app": "^0.52.0",
|
|
45
|
+
"@gjsify/adwaita-core": "^0.52.0",
|
|
46
|
+
"@gjsify/devtools": "^0.52.0",
|
|
47
|
+
"@gjsify/stories": "^0.52.0",
|
|
48
|
+
"@gjsify/storybook-core": "^0.52.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@gjsify/cli": "^0.
|
|
52
|
-
"@gjsify/unit": "^0.
|
|
51
|
+
"@gjsify/cli": "^0.52.0",
|
|
52
|
+
"@gjsify/unit": "^0.52.0",
|
|
53
|
+
"@gjsify/vite-plugin-blueprint": "^0.52.0",
|
|
53
54
|
"@types/node": "^25.9.2",
|
|
54
55
|
"typescript": "^6.0.3"
|
|
55
56
|
},
|