@gjsify/storybook-nativescript 0.12.0 → 0.13.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/lib/esm/app.js +1 -1
- package/lib/esm/story-view.js +1 -1
- package/lib/types/app.d.ts +51 -0
- package/package.json +8 -8
- package/src/theme/storybook.css +40 -15
package/lib/esm/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{createControlRow as e}from"./controls.js";import{StorybookController as t}from"@gjsify/storybook-core";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{createControlRow as e}from"./controls.js";import{StorybookController as t}from"@gjsify/storybook-core";import{AdwBreakpoint as n,AdwHeaderBar as r,AdwImageButton as i,AdwNavigationSplitView as a,AdwOverlaySplitView as o,AdwPreferencesGroup as s,AdwToolbarView as c,AdwWindowTitle as l,addBreakpoints as u,attachRowPressFeedback as d,setAdwaitaColorScheme as f}from"@gjsify/adwaita-nativescript";import{goPreviousSymbolic as p,sidebarShowRightSymbolic as m}from"@gjsify/adwaita-icons/actions";import{Label as h,Screen as g,ScrollView as _,StackLayout as v}from"@nativescript/core";var StorybookNativeApp=class{_controller=new t(this,e=>this._buildControls(e));_options;root;_listColumn;_previewSlot;_previewTitle;_controlsGroup;_controlsSplit;_backButton;_rowByTitle=new Map;_collapsed=!0;_disposeBreakpoint=null;constructor(e){this._options=e,this.root=new a,this._collapsed=!this._isWideWidth(g.mainScreen?.widthDIPs??0),this.root.collapsed=this._collapsed,this.root.className=`sb-window`}_isWideWidth(e){return e>=720}mount(){return this._buildUI(),this._controller.mount(this._options.stories,this._options.openFirst!==!1),this._wireColorScheme(),this._wireBreakpoint(),this.root}_wireBreakpoint(){let e=new n(`max-width: 720sp`,{onApply:()=>this._applyLayoutMode(!0),onUnapply:()=>this._applyLayoutMode(!1)});this._disposeBreakpoint=u(this.root,[e])}_applyLayoutMode(e){e===this._collapsed&&this.root.collapsed===e||(this._collapsed=e,this.root.collapsed=e,this._controlsSplit.collapsed=e,e?(this.root.showSidebarPane(),this._controlsSplit.hideSidebarPane(),this._backButton.visibility=`visible`):(this.root.showSidebarPane(),this._controlsSplit.showSidebarPane(),this._backButton.visibility=`collapse`))}get activeStory(){return this._controller.activeStory}listStories(){return this._controller.listStories()}openStoryByTitle(e){return this._controller.openStoryByTitle(e)}getCurrentStory(){return this._controller.getCurrentStory()}setActiveArg(e,t){return this._controller.setActiveArg(e,t)}get controller(){return this._controller}_wireColorScheme(){let e=this._options.application;e?.systemAppearance&&f(e.systemAppearance()===`dark`?`dark`:`light`)}renderSidebar(e,t){this._listColumn.removeChildren(),this._rowByTitle.clear();for(let{category:n,stories:r}of e){let e=new h;e.text=n,e.className=`sb-category`,this._listColumn.addChild(e);for(let{instance:e,name:n}of r){let r=new v;r.orientation=`vertical`,r.className=`sb-story-row`;let i=new h;i.text=n,i.className=`sb-story-row-label`,r.addChild(i),d(r),r.addEventListener(`tap`,()=>{t(e),this._collapsed&&this.root.hideSidebarPane()}),this._listColumn.addChild(r),this._rowByTitle.set(e.meta.title,r)}}}markSelected(e){for(let[t,n]of this._rowByTitle)n.className=t===e?`sb-story-row sb-story-row-selected`:`sb-story-row`}setPreviewTitle(e){this._previewTitle.title=e}showPreview(e){this._previewSlot.removeChildren(),this._previewSlot.addChild(e.view)}renderControls(e){this._controlsGroup.listbox.removeChildren();for(let t of e)this._controlsGroup.addRow(t.view)}_buildControls(t){let n=[],r=t.meta.controls;if(Array.isArray(r))for(let i of r){if(!i?.name||!i?.type){console.warn(`Invalid control configuration:`,i);continue}let r=e(t,i);r&&n.push(r)}return n}_buildUI(){let e=new c;e.className=`${e.className} sb-sidebar-pane`.trim();let t=new r;t.className=`${t.className} sb-sidebar-header`.trim();let n=new l;n.title=this._options.title??`Stories`,t.setTitleWidget(n),e.addTopBar(t),this._listColumn=new v,this._listColumn.orientation=`vertical`,this._listColumn.className=`sb-sidebar-list`;let a=new _;a.className=`sb-sidebar-scroll`,a.content=this._listColumn,e.setContent(a),this.root.setSidebar(e);let u=new c;u.className=`${u.className} sb-content-pane`.trim();let d=new r;d.className=`${d.className} sb-detail-header`.trim();let f=new i;f.icon=p,f.className=`${f.className} sb-back-button`.trim(),f.addEventListener(`tap`,()=>this.root.showSidebarPane()),f.visibility=this._collapsed?`visible`:`collapse`,this._backButton=f,d.packStart(f),this._previewTitle=new l,this._previewTitle.title=`Preview`,d.setTitleWidget(this._previewTitle);let h=new i;h.icon=m,h.className=`${h.className} sb-controls-toggle`.trim(),h.addEventListener(`tap`,()=>{this._controlsSplit.showSidebar=!this._controlsSplit.showSidebar}),d.packEnd(h),u.addTopBar(d),this._controlsSplit=new o,this._controlsSplit.collapsed=this._collapsed,this._controlsSplit.sidebarPosition=`end`,this._controlsSplit.sidebarWidth=320,this._controlsSplit.className=`${this._controlsSplit.className} sb-controls-split`.trim(),this._previewSlot=new v,this._previewSlot.orientation=`vertical`,this._previewSlot.className=`sb-preview-pane`;let g=new _;g.className=`sb-preview-scroll`,g.content=this._previewSlot,this._controlsSplit.setContent(g),this._controlsGroup=new s,this._controlsGroup.title=`Controls`,this._controlsGroup.className=`${this._controlsGroup.className} sb-controls-group`.trim();let y=new _;y.className=`sb-controls-scroll`,y.content=this._controlsGroup,this._controlsSplit.setSidebar(y),this._collapsed?this._controlsSplit.hideSidebarPane():this._controlsSplit.showSidebarPane(),u.setContent(this._controlsSplit),this.root.setContent(u),this.root.showSidebarPane()}};function runStorybook(e){let t=new StorybookNativeApp(e);return t.mount(),t}export{StorybookNativeApp,runStorybook};
|
package/lib/esm/story-view.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{StoryViewBase as e}from"@gjsify/storybook-core";import{AdwClamp as t
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{StoryViewBase as e}from"@gjsify/storybook-core";import{AdwClamp as t}from"@gjsify/adwaita-nativescript";import{Label as n,StackLayout as r}from"@nativescript/core";var StoryView=class extends e{constructor(e,t=`Default`,n){super(),this.initBase(e,t,n)}get view(){return this.root}createChrome(e,t){return t?{root:t,hasStage:!1,setStageContent:()=>{},setChromeText:()=>{}}:this._installDefaultChrome()}_installDefaultChrome(){let e=new r;e.orientation=`vertical`,e.className=`sb-story-page`;let i=new t;i.className=`${i.className} sb-story-clamp`.trim();let a=new r;a.orientation=`vertical`,a.className=`sb-story-group`;let o=new r;o.orientation=`vertical`,o.className=`sb-story-group-header`;let s=new n;s.className=`sb-story-group-title`,s.textWrap=!0,o.addChild(s);let c=new n;c.className=`sb-story-group-description`,c.textWrap=!0;let l=!1,u=new r;return u.orientation=`vertical`,u.className=`story-stage`,u.horizontalAlignment=`center`,a.addChild(o),a.addChild(u),i.setChild(a),e.addChild(i),{root:e,hasStage:!0,setStageContent:e=>{u.removeChildren(),u.addChild(e)},setChromeText:(e,t)=>{s.text=e,c.text=t;let n=t.length>0;n&&!l?(o.addChild(c),l=!0):!n&&l&&(o.removeChild(c),l=!1)}}}};export{StoryView};
|
package/lib/types/app.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ import { type View } from '@nativescript/core';
|
|
|
5
5
|
import type { StoryView } from './story-view.js';
|
|
6
6
|
import type { NsStoryModule } from './types.js';
|
|
7
7
|
export type { StorySummary } from '@gjsify/storybook-core';
|
|
8
|
+
/**
|
|
9
|
+
* The slice of NativeScript's `Application` the storybook reads to follow the OS
|
|
10
|
+
* color scheme. Pass `Application` from `@nativescript/core` — it satisfies this
|
|
11
|
+
* shape. Kept structural so the package needs no `@nativescript/core` value import.
|
|
12
|
+
*/
|
|
13
|
+
export interface NsAppearanceSource {
|
|
14
|
+
/** Current OS appearance (`'light'` / `'dark'`), or null when unknown. */
|
|
15
|
+
systemAppearance(): 'light' | 'dark' | null | undefined;
|
|
16
|
+
}
|
|
8
17
|
/** Options that adapt the storybook to a host project. */
|
|
9
18
|
export interface StorybookNativeOptions {
|
|
10
19
|
/** Story modules to display. */
|
|
@@ -13,6 +22,13 @@ export interface StorybookNativeOptions {
|
|
|
13
22
|
title?: string;
|
|
14
23
|
/** Auto-select the first story on mount (default true). */
|
|
15
24
|
openFirst?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The NativeScript `Application` (optional). When given, the storybook follows
|
|
27
|
+
* the OS color scheme: NS already flips the `ns-dark` CSS class on the root view
|
|
28
|
+
* (so backgrounds/text follow the system theme), and this keeps the symbolic
|
|
29
|
+
* ICON bitmaps recoloured to match (they are pre-coloured, outside CSS's reach).
|
|
30
|
+
*/
|
|
31
|
+
application?: NsAppearanceSource;
|
|
16
32
|
}
|
|
17
33
|
export declare class StorybookNativeApp implements StorybookView<StoryView> {
|
|
18
34
|
private _controller;
|
|
@@ -26,10 +42,31 @@ export declare class StorybookNativeApp implements StorybookView<StoryView> {
|
|
|
26
42
|
private _controlsGroup;
|
|
27
43
|
/** Right controls overlay (the GTK OverlaySplitView, sidebar_position=END). */
|
|
28
44
|
private _controlsSplit;
|
|
45
|
+
/** Back button (visible only in collapsed/phone layout). */
|
|
46
|
+
private _backButton;
|
|
29
47
|
private _rowByTitle;
|
|
48
|
+
/** Current layout mode — true = collapsed (phone), false = three-pane (wide). */
|
|
49
|
+
private _collapsed;
|
|
50
|
+
/** Detaches the responsive breakpoint listeners on teardown. */
|
|
51
|
+
private _disposeBreakpoint;
|
|
30
52
|
constructor(options: StorybookNativeOptions);
|
|
53
|
+
/** Whether `width` (DIPs) is at/above the three-pane breakpoint (720sp). */
|
|
54
|
+
private _isWideWidth;
|
|
31
55
|
/** Build the UI, instantiate stories, and select the first one. Returns the root view. */
|
|
32
56
|
mount(): View;
|
|
57
|
+
/**
|
|
58
|
+
* Collapse to phone layout below 720sp, expand to three side-by-side panes at
|
|
59
|
+
* or above it — the GTK storybook's `Adw.Breakpoint`, driven by the root
|
|
60
|
+
* view's post-layout width. Seeds immediately so the first paint is correct.
|
|
61
|
+
*/
|
|
62
|
+
private _wireBreakpoint;
|
|
63
|
+
/**
|
|
64
|
+
* Switch between collapsed (phone) and expanded (wide) chrome. Collapsed: the
|
|
65
|
+
* master/detail nav swaps panes, the controls are a tap-to-reveal overlay, and
|
|
66
|
+
* the back button shows. Expanded: sidebar + preview + controls sit side by
|
|
67
|
+
* side and the back button hides (no navigation needed).
|
|
68
|
+
*/
|
|
69
|
+
private _applyLayoutMode;
|
|
33
70
|
/** The currently-displayed story, or null. */
|
|
34
71
|
get activeStory(): StoryView | null;
|
|
35
72
|
/** Every story flattened to a summary. */
|
|
@@ -46,6 +83,20 @@ export declare class StorybookNativeApp implements StorybookView<StoryView> {
|
|
|
46
83
|
setActiveArg(name: string, value: StoryArgValue): boolean;
|
|
47
84
|
/** The underlying controller (e.g. to build a devtools extension over it). */
|
|
48
85
|
get controller(): StorybookController<StoryView>;
|
|
86
|
+
/**
|
|
87
|
+
* Match the OS color scheme at mount. NS applies the `ns-dark` CSS class to the
|
|
88
|
+
* root BEFORE the first style pass (so backgrounds/text/borders follow the
|
|
89
|
+
* system theme via `autoSystemAppearanceChanged`); the pre-coloured symbolic
|
|
90
|
+
* ICON bitmaps are outside CSS's reach, so this sets the global icon scheme to
|
|
91
|
+
* the matching fg (dark icons on light, near-white on dark). No-op without an
|
|
92
|
+
* `application` option.
|
|
93
|
+
*
|
|
94
|
+
* Seed-only (mount-time): a clean launch is the dependable path because NS
|
|
95
|
+
* 9.1-alpha does not reliably RE-APPLY the `.ns-dark` overrides at runtime, so a
|
|
96
|
+
* live OS theme switch is picked up on the next launch rather than risking the
|
|
97
|
+
* icons getting ahead of a CSS that didn't flip.
|
|
98
|
+
*/
|
|
99
|
+
private _wireColorScheme;
|
|
49
100
|
renderSidebar(groups: Array<CategoryGroup<StoryView>>, onSelect: (instance: StoryView) => void): void;
|
|
50
101
|
markSelected(title: string): void;
|
|
51
102
|
setPreviewTitle(title: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/storybook-nativescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "NativeScript renderer for the @gjsify/stories contract — the NS counterpart of @gjsify/storybook (GTK) and @gjsify/adwaita-storybook (browser), built on @gjsify/adwaita-nativescript real native widgets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"gnome"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gjsify/adwaita-icons": "^0.
|
|
43
|
-
"@gjsify/adwaita-nativescript": "^0.
|
|
44
|
-
"@gjsify/devtools-nativescript": "^0.
|
|
45
|
-
"@gjsify/stories": "^0.
|
|
46
|
-
"@gjsify/storybook-core": "^0.
|
|
42
|
+
"@gjsify/adwaita-icons": "^0.13.0",
|
|
43
|
+
"@gjsify/adwaita-nativescript": "^0.13.0",
|
|
44
|
+
"@gjsify/devtools-nativescript": "^0.13.0",
|
|
45
|
+
"@gjsify/stories": "^0.13.0",
|
|
46
|
+
"@gjsify/storybook-core": "^0.13.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@nativescript/core": "*"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@gjsify/cli": "^0.
|
|
58
|
-
"@gjsify/unit": "^0.
|
|
57
|
+
"@gjsify/cli": "^0.13.0",
|
|
58
|
+
"@gjsify/unit": "^0.13.0",
|
|
59
59
|
"@nativescript/types": "~9.0.0",
|
|
60
60
|
"@types/node": "^25.9.2",
|
|
61
61
|
"typescript": "^6.0.3"
|
package/src/theme/storybook.css
CHANGED
|
@@ -52,8 +52,11 @@
|
|
|
52
52
|
padding: 4;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/* Category separator = Adwaita `.heading` + `.dim-label`: BODY size (same as the
|
|
56
|
+
* story rows), bold, dimmed — NOT a shrunk caption (matches the native GTK
|
|
57
|
+
* `.navigation-sidebar` section header). */
|
|
55
58
|
.sb-category {
|
|
56
|
-
font-size:
|
|
59
|
+
font-size: 14;
|
|
57
60
|
font-weight: 700;
|
|
58
61
|
color: rgba(0, 0, 0, 0.55);
|
|
59
62
|
padding: 10 8 4 8;
|
|
@@ -66,20 +69,29 @@
|
|
|
66
69
|
background-color: transparent;
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
/* Press/hover shade — Adwaita `.navigation-sidebar row.activatable:hover`
|
|
73
|
+
* ($hover_color = currentColor 7%). Wired via attachRowPressFeedback() (NS only
|
|
74
|
+
* auto-applies :highlighted to Button). */
|
|
75
|
+
.sb-story-row:highlighted {
|
|
76
|
+
background-color: rgba(0, 0, 0, 0.07);
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
.sb-story-row-label {
|
|
70
80
|
font-size: 15;
|
|
71
81
|
color: rgba(0, 0, 0, 0.8);
|
|
72
82
|
}
|
|
73
83
|
|
|
84
|
+
/* Selected row — Adwaita `row:selected` uses $selected_color (currentColor 10%),
|
|
85
|
+
* a GREY shade, NOT the accent; the label stays the normal dark fg. */
|
|
74
86
|
.sb-story-row-selected {
|
|
75
|
-
background-color:
|
|
87
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
76
88
|
border-radius: 6;
|
|
77
89
|
margin: 1 4 1 4;
|
|
78
90
|
padding: 8 12 8 12;
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
.sb-story-row-selected
|
|
82
|
-
color:
|
|
93
|
+
.sb-story-row-selected:highlighted {
|
|
94
|
+
background-color: rgba(0, 0, 0, 0.13);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
/* ===== Detail header (back + story title + controls toggle) ===== */
|
|
@@ -113,15 +125,15 @@
|
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
.sb-story-group-title {
|
|
116
|
-
font-size:
|
|
128
|
+
font-size: 17;
|
|
117
129
|
font-weight: 700;
|
|
118
130
|
color: rgba(0, 0, 0, 0.8);
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
.sb-story-group-description {
|
|
122
|
-
font-size:
|
|
134
|
+
font-size: 14;
|
|
123
135
|
color: rgba(0, 0, 0, 0.55);
|
|
124
|
-
margin:
|
|
136
|
+
margin: 3 0 0 0;
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
/*
|
|
@@ -130,11 +142,11 @@
|
|
|
130
142
|
*/
|
|
131
143
|
.story-stage {
|
|
132
144
|
border-width: 1;
|
|
133
|
-
border-color: rgba(
|
|
145
|
+
border-color: rgba(0, 0, 0, 0.28);
|
|
134
146
|
border-style: dashed;
|
|
135
147
|
border-radius: 12;
|
|
136
|
-
padding:
|
|
137
|
-
margin:
|
|
148
|
+
padding: 18;
|
|
149
|
+
margin: 12 0 0 0;
|
|
138
150
|
}
|
|
139
151
|
|
|
140
152
|
/* ===== Controls panel — a RIGHT overlay (sidebar_position=END) ===== */
|
|
@@ -142,14 +154,14 @@
|
|
|
142
154
|
fill read as a distinct sidebar (the GTK OverlaySplitView controls pane). */
|
|
143
155
|
|
|
144
156
|
.sb-controls-scroll {
|
|
145
|
-
background-color: #
|
|
157
|
+
background-color: #f3f3f5;
|
|
146
158
|
border-left-width: 1;
|
|
147
159
|
border-left-color: rgba(0, 0, 0, 0.1);
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
.sb-controls-group {
|
|
151
163
|
margin: 8 12 12 12;
|
|
152
|
-
background-color: #
|
|
164
|
+
background-color: #f3f3f5;
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
/* ===== Dark mode ===== */
|
|
@@ -166,14 +178,14 @@
|
|
|
166
178
|
|
|
167
179
|
.ns-dark .sb-controls-scroll,
|
|
168
180
|
.ns-dark .sb-controls-group {
|
|
169
|
-
background-color: #
|
|
181
|
+
background-color: #28282c;
|
|
170
182
|
border-left-color: rgba(255, 255, 255, 0.1);
|
|
171
183
|
}
|
|
172
184
|
|
|
173
185
|
.ns-dark .sb-sidebar-pane,
|
|
174
186
|
.ns-dark .sb-sidebar-header,
|
|
175
187
|
.ns-dark .sb-sidebar-scroll {
|
|
176
|
-
background-color: #
|
|
188
|
+
background-color: #2e2e32;
|
|
177
189
|
}
|
|
178
190
|
|
|
179
191
|
.ns-dark .sb-category {
|
|
@@ -184,6 +196,19 @@
|
|
|
184
196
|
color: rgba(255, 255, 255, 0.8);
|
|
185
197
|
}
|
|
186
198
|
|
|
199
|
+
/* Dark selection/press — currentColor (white) overlay, mirroring the light rules. */
|
|
200
|
+
.ns-dark .sb-story-row:highlighted {
|
|
201
|
+
background-color: rgba(255, 255, 255, 0.07);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.ns-dark .sb-story-row-selected {
|
|
205
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.ns-dark .sb-story-row-selected:highlighted {
|
|
209
|
+
background-color: rgba(255, 255, 255, 0.13);
|
|
210
|
+
}
|
|
211
|
+
|
|
187
212
|
.ns-dark .sb-story-group-title {
|
|
188
213
|
color: rgba(255, 255, 255, 0.85);
|
|
189
214
|
}
|
|
@@ -193,5 +218,5 @@
|
|
|
193
218
|
}
|
|
194
219
|
|
|
195
220
|
.ns-dark .story-stage {
|
|
196
|
-
border-color: rgba(
|
|
221
|
+
border-color: rgba(255, 255, 255, 0.28);
|
|
197
222
|
}
|