@gjsify/storybook-core 0.37.0 → 0.38.1
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/index.js +1 -1
- package/lib/esm/settings.js +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/settings.d.ts +80 -0
- package/lib/types/settings.spec.d.ts +2 -0
- package/package.json +5 -4
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StoryRegistry as e}from"./registry.js";import{StorybookController as t}from"./controller.js";import{bindControl as n}from"./controls.js";import{buildStorybookDevtoolsExtension as r}from"./devtools.js";import{collectStoryModules as i}from"./discover.js";import{StoryViewBase as a}from"./story-view-base.js";export*from"@gjsify/stories";export{e as StoryRegistry,a as StoryViewBase,t as StorybookController,n as bindControl,r as buildStorybookDevtoolsExtension,i as collectStoryModules};
|
|
1
|
+
import{StoryRegistry as e}from"./registry.js";import{StorybookController as t}from"./controller.js";import{bindControl as n}from"./controls.js";import{buildStorybookDevtoolsExtension as r}from"./devtools.js";import{collectStoryModules as i}from"./discover.js";import{StoryViewBase as a}from"./story-view-base.js";import{STORYBOOK_COLOR_SCHEMES as o,StorybookSettings as s}from"./settings.js";export*from"@gjsify/stories";export{o as STORYBOOK_COLOR_SCHEMES,e as StoryRegistry,a as StoryViewBase,t as StorybookController,s as StorybookSettings,n as bindControl,r as buildStorybookDevtoolsExtension,i as collectStoryModules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=[`system`,`light`,`dark`];var StorybookSettings=class{constructor(e=()=>!1){this._colorScheme=`system`,this._accentMode=`system`,this._accent=`blue`,this._listeners=new Set,this._systemDark=e}get colorScheme(){return this._colorScheme}set colorScheme(t){!e.includes(t)||t===this._colorScheme||(this._colorScheme=t,this._notify())}get accentMode(){return this._accentMode}set accentMode(e){e!==this._accentMode&&(this._accentMode=e,this._notify())}get accent(){return this._accent}set accent(e){e!==this._accent&&(this._accent=e,this._notify())}get resolvedAccent(){return this._accentMode===`custom`?this._accent:null}get resolvedDark(){return this._colorScheme===`dark`?!0:this._colorScheme===`light`?!1:this._systemDark()}get state(){return{colorScheme:this._colorScheme,accentMode:this._accentMode,accent:this._accent}}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}systemChanged(){this._colorScheme===`system`&&this._notify()}_notify(){let e=this.state;for(let t of[...this._listeners])try{t(e)}catch{}}};export{e as STORYBOOK_COLOR_SCHEMES,StorybookSettings};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AdwAccentColorName } from '@gjsify/adwaita-core';
|
|
2
|
+
/** What the user picked. `'system'` follows the desktop rather than pinning. */
|
|
3
|
+
export type StorybookColorScheme = 'system' | 'light' | 'dark';
|
|
4
|
+
/** Every colour-scheme choice, in the order a selector should offer them. */
|
|
5
|
+
export declare const STORYBOOK_COLOR_SCHEMES: readonly StorybookColorScheme[];
|
|
6
|
+
/**
|
|
7
|
+
* Whether the accent is the environment's or the storybook's own.
|
|
8
|
+
*
|
|
9
|
+
* `'system'` is the default and it is not a formality: `Adw.StyleManager:accent-color`
|
|
10
|
+
* is READ-ONLY because the desktop owns the accent, so an app that always
|
|
11
|
+
* overrode it would ignore the user's choice the moment it started. The override
|
|
12
|
+
* exists to PREVIEW the other eight, which is a storybook's job and not a
|
|
13
|
+
* default.
|
|
14
|
+
*/
|
|
15
|
+
export type StorybookAccentMode = 'system' | 'custom';
|
|
16
|
+
/** A snapshot of the appearance settings. */
|
|
17
|
+
export interface StorybookSettingsState {
|
|
18
|
+
/** The colour-scheme PREFERENCE, not the resolved value. */
|
|
19
|
+
readonly colorScheme: StorybookColorScheme;
|
|
20
|
+
/** Whether {@link accent} is applied at all. */
|
|
21
|
+
readonly accentMode: StorybookAccentMode;
|
|
22
|
+
/** The accent to override with while {@link accentMode} is `'custom'`. */
|
|
23
|
+
readonly accent: AdwAccentColorName;
|
|
24
|
+
}
|
|
25
|
+
/** How the renderer answers "is the system currently dark?". */
|
|
26
|
+
export type SystemDarkQuery = () => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The storybook's appearance settings, with change notification.
|
|
29
|
+
*
|
|
30
|
+
* Deliberately a plain observable rather than the abstract-base-plus-`applyTheme`
|
|
31
|
+
* shape: a renderer subscribing to changes can apply a scheme AND an accent
|
|
32
|
+
* through one path, where a template method would need one hook per setting and a
|
|
33
|
+
* new setting would mean a new abstract member in every target.
|
|
34
|
+
*/
|
|
35
|
+
export declare class StorybookSettings {
|
|
36
|
+
private _colorScheme;
|
|
37
|
+
private _accentMode;
|
|
38
|
+
private _accent;
|
|
39
|
+
private readonly _listeners;
|
|
40
|
+
private readonly _systemDark;
|
|
41
|
+
/**
|
|
42
|
+
* @param systemDark How to resolve `'system'`. Defaults to "not dark", which
|
|
43
|
+
* is what a renderer that cannot see the desktop should report — guessing
|
|
44
|
+
* dark would fight a light desktop on every start.
|
|
45
|
+
*/
|
|
46
|
+
constructor(systemDark?: SystemDarkQuery);
|
|
47
|
+
get colorScheme(): StorybookColorScheme;
|
|
48
|
+
set colorScheme(value: StorybookColorScheme);
|
|
49
|
+
get accentMode(): StorybookAccentMode;
|
|
50
|
+
set accentMode(value: StorybookAccentMode);
|
|
51
|
+
/**
|
|
52
|
+
* The custom accent. Setting it does NOT switch {@link accentMode} on — a
|
|
53
|
+
* selector left visible-but-disabled still reports which swatch is current,
|
|
54
|
+
* and flipping the mode as a side effect of that would apply an accent the
|
|
55
|
+
* user never enabled.
|
|
56
|
+
*/
|
|
57
|
+
get accent(): AdwAccentColorName;
|
|
58
|
+
set accent(value: AdwAccentColorName);
|
|
59
|
+
/** The accent to apply, or `null` to leave the environment's alone. */
|
|
60
|
+
get resolvedAccent(): AdwAccentColorName | null;
|
|
61
|
+
/** Whether dark is actually on screen — the preference, resolved. */
|
|
62
|
+
get resolvedDark(): boolean;
|
|
63
|
+
get state(): StorybookSettingsState;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to changes; returns an unsubscribe function.
|
|
66
|
+
*
|
|
67
|
+
* Also called when the SYSTEM scheme changes underneath `'system'` — see
|
|
68
|
+
* {@link systemChanged} — because a renderer applying an accent needs to
|
|
69
|
+
* recompute the standalone colour when light↔dark flips, not only when the
|
|
70
|
+
* user picks something.
|
|
71
|
+
*/
|
|
72
|
+
subscribe(listener: (state: StorybookSettingsState) => void): () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Tell the settings the system scheme moved. A no-op unless the preference is
|
|
75
|
+
* `'system'`, so a renderer can wire it to the platform signal unconditionally
|
|
76
|
+
* instead of guarding at every call site.
|
|
77
|
+
*/
|
|
78
|
+
systemChanged(): void;
|
|
79
|
+
private _notify;
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/storybook-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "Renderer-agnostic storybook logic (story base, registry, control binding, controller, discovery, devtools) shared by the GTK, browser and NativeScript storybook renderers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"stories"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gjsify/
|
|
43
|
+
"@gjsify/adwaita-core": "^0.38.1",
|
|
44
|
+
"@gjsify/stories": "^0.38.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@gjsify/cli": "^0.
|
|
47
|
-
"@gjsify/unit": "^0.
|
|
47
|
+
"@gjsify/cli": "^0.38.1",
|
|
48
|
+
"@gjsify/unit": "^0.38.1",
|
|
48
49
|
"@types/node": "^25.9.2",
|
|
49
50
|
"typescript": "^6.0.3"
|
|
50
51
|
},
|