@gjsify/example-gtk-adwaita-storybook 0.38.0 → 0.39.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/dist/browser-main.js +54 -8
- package/dist/gjs.js +33 -11
- package/dist/gjs.node.mjs +32 -10
- package/package.json +5 -5
- package/src/browser/overview/widgets.web.ts +33 -14
- package/src/browser/stories.ts +11 -2
- package/src/overview/widgets.meta.ts +48 -0
- package/src/overview/widgets.story.ts +42 -19
|
@@ -5,7 +5,10 @@ import { StoryElement, type StoryArgs, type StoryMeta, type WebStoryModule } fro
|
|
|
5
5
|
import {
|
|
6
6
|
OVERVIEW_ACCENT_OPTIONS,
|
|
7
7
|
OVERVIEW_ADVANCED_ROWS,
|
|
8
|
+
OVERVIEW_DEVICES,
|
|
9
|
+
OVERVIEW_GROUP_TITLES,
|
|
8
10
|
OVERVIEW_SHORTCUTS,
|
|
11
|
+
OVERVIEW_TEXT,
|
|
9
12
|
overviewWidgetsMeta,
|
|
10
13
|
} from '../../overview/widgets.meta.js';
|
|
11
14
|
|
|
@@ -33,7 +36,10 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
33
36
|
host.style.flexDirection = 'column';
|
|
34
37
|
host.style.width = '100%';
|
|
35
38
|
|
|
36
|
-
this._banner = el('adw-banner', {
|
|
39
|
+
this._banner = el('adw-banner', {
|
|
40
|
+
title: OVERVIEW_TEXT.bannerTitle,
|
|
41
|
+
'button-label': OVERVIEW_TEXT.bannerButton,
|
|
42
|
+
});
|
|
37
43
|
this._syncBanner();
|
|
38
44
|
host.append(this._banner);
|
|
39
45
|
|
|
@@ -42,12 +48,16 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
42
48
|
// --- Appearance: a widget demo only. The storybook's OWN appearance is in
|
|
43
49
|
// the chrome, and wiring these to it would give one setting two controls
|
|
44
50
|
// that disagree.
|
|
45
|
-
const appearance = el('adw-preferences-group', { title:
|
|
51
|
+
const appearance = el('adw-preferences-group', { title: OVERVIEW_GROUP_TITLES.appearance });
|
|
46
52
|
appearance.append(
|
|
47
|
-
el('adw-switch-row', { title:
|
|
48
|
-
el('adw-switch-row', {
|
|
53
|
+
el('adw-switch-row', { title: OVERVIEW_TEXT.darkMode, subtitle: OVERVIEW_TEXT.darkModeSubtitle }),
|
|
54
|
+
el('adw-switch-row', {
|
|
55
|
+
title: OVERVIEW_TEXT.notifications,
|
|
56
|
+
subtitle: OVERVIEW_TEXT.notificationsSubtitle,
|
|
57
|
+
active: '',
|
|
58
|
+
}),
|
|
49
59
|
el('adw-combo-row', {
|
|
50
|
-
title:
|
|
60
|
+
title: OVERVIEW_TEXT.accentColor,
|
|
51
61
|
// `items` is JSON, not a comma list — the element parses it.
|
|
52
62
|
items: JSON.stringify([...OVERVIEW_ACCENT_OPTIONS]),
|
|
53
63
|
selected: '0',
|
|
@@ -56,14 +66,23 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
56
66
|
page.append(appearance);
|
|
57
67
|
|
|
58
68
|
// --- Account ---
|
|
59
|
-
const account = el('adw-preferences-group', { title:
|
|
69
|
+
const account = el('adw-preferences-group', { title: OVERVIEW_GROUP_TITLES.account });
|
|
60
70
|
account.append(
|
|
61
|
-
el('adw-entry-row', { title:
|
|
62
|
-
el('adw-entry-row', { title:
|
|
63
|
-
el('adw-spin-row', {
|
|
71
|
+
el('adw-entry-row', { title: OVERVIEW_TEXT.name, text: OVERVIEW_TEXT.nameValue }),
|
|
72
|
+
el('adw-entry-row', { title: OVERVIEW_TEXT.email, text: OVERVIEW_TEXT.emailValue }),
|
|
73
|
+
el('adw-spin-row', {
|
|
74
|
+
title: OVERVIEW_TEXT.devices,
|
|
75
|
+
min: String(OVERVIEW_DEVICES.lower),
|
|
76
|
+
max: String(OVERVIEW_DEVICES.upper),
|
|
77
|
+
step: String(OVERVIEW_DEVICES.step),
|
|
78
|
+
value: String(OVERVIEW_DEVICES.value),
|
|
79
|
+
}),
|
|
64
80
|
);
|
|
65
81
|
|
|
66
|
-
const advanced = el('adw-expander-row', {
|
|
82
|
+
const advanced = el('adw-expander-row', {
|
|
83
|
+
title: OVERVIEW_TEXT.advanced,
|
|
84
|
+
subtitle: OVERVIEW_TEXT.advancedSubtitle,
|
|
85
|
+
});
|
|
67
86
|
advanced.toggleAttribute('expanded', true);
|
|
68
87
|
for (const row of OVERVIEW_ADVANCED_ROWS) {
|
|
69
88
|
advanced.append(
|
|
@@ -76,7 +95,7 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
76
95
|
page.append(account);
|
|
77
96
|
|
|
78
97
|
// --- Shortcuts: the newest widget, in context ---
|
|
79
|
-
const shortcuts = el('adw-preferences-group', { title:
|
|
98
|
+
const shortcuts = el('adw-preferences-group', { title: OVERVIEW_GROUP_TITLES.shortcuts });
|
|
80
99
|
for (const shortcut of OVERVIEW_SHORTCUTS) {
|
|
81
100
|
const row = el('adw-action-row', { title: shortcut.title });
|
|
82
101
|
const label = el('adw-shortcut-label', { accelerator: shortcut.accelerator, slot: 'suffix' });
|
|
@@ -86,7 +105,7 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
86
105
|
page.append(shortcuts);
|
|
87
106
|
|
|
88
107
|
// --- Actions ---
|
|
89
|
-
const actions = el('adw-preferences-group', { title:
|
|
108
|
+
const actions = el('adw-preferences-group', { title: OVERVIEW_GROUP_TITLES.actions });
|
|
90
109
|
const buttons = document.createElement('div');
|
|
91
110
|
buttons.style.display = 'flex';
|
|
92
111
|
buttons.style.gap = '12px';
|
|
@@ -94,10 +113,10 @@ export class OverviewWidgetsWebStory extends StoryElement {
|
|
|
94
113
|
|
|
95
114
|
const save = document.createElement('button');
|
|
96
115
|
save.className = 'adw-button suggested-action';
|
|
97
|
-
save.textContent =
|
|
116
|
+
save.textContent = OVERVIEW_TEXT.save;
|
|
98
117
|
const remove = document.createElement('button');
|
|
99
118
|
remove.className = 'adw-button destructive-action';
|
|
100
|
-
remove.textContent =
|
|
119
|
+
remove.textContent = OVERVIEW_TEXT.delete;
|
|
101
120
|
buttons.append(save, remove);
|
|
102
121
|
actions.append(buttons);
|
|
103
122
|
page.append(actions);
|
package/src/browser/stories.ts
CHANGED
|
@@ -3,8 +3,17 @@
|
|
|
3
3
|
// embeddable `mount(container)` (`embed.ts`, used by the gjsify website) draw
|
|
4
4
|
// from this single list so the two stay in lockstep.
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
6
|
+
// THE ORDER OF THIS ARRAY NO LONGER DECIDES THE SIDEBAR. Categories are ordered
|
|
7
|
+
// by STORYBOOK_CATEGORY_ORDER in @gjsify/storybook-core, which every target's
|
|
8
|
+
// controller applies, so this list only decides which stories exist and how they
|
|
9
|
+
// sit WITHIN their category.
|
|
10
|
+
//
|
|
11
|
+
// It used to claim it mirrored the native sidebar's order. It measurably did not:
|
|
12
|
+
// the GTK and NativeScript storybooks took their order from a path glob
|
|
13
|
+
// (alphabetical by directory), so `Overview` led here and sat fifth there. One
|
|
14
|
+
// sentence was the only thing holding an invariant across three files, and the
|
|
15
|
+
// sentence was wrong — which is why the order moved somewhere a build gate can
|
|
16
|
+
// check it.
|
|
8
17
|
|
|
9
18
|
import type { WebStoryModule } from '@gjsify/adwaita-storybook';
|
|
10
19
|
import { OverviewWidgetsWebStories } from './overview/widgets.web.js';
|
|
@@ -33,6 +33,54 @@ export const OVERVIEW_ADVANCED_ROWS: ReadonlyArray<OverviewExpanderRow> = [
|
|
|
33
33
|
/** The accent names the gallery's combo row offers — a plain widget demo, not the real setting. */
|
|
34
34
|
export const OVERVIEW_ACCENT_OPTIONS: readonly string[] = ['Blue', 'Teal', 'Green', 'Orange'];
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* The gallery's preference-group headings.
|
|
38
|
+
*
|
|
39
|
+
* Shared for the same reason the rows are: they were literals repeated in all
|
|
40
|
+
* three renderings, and the NativeScript copy had drifted to UPPERCASE
|
|
41
|
+
* (`APPEARANCE`) while GTK and the browser used title case. It was the only file
|
|
42
|
+
* in that showcase spelling group titles that way, so it read as a house style
|
|
43
|
+
* without being one — `Adw.PreferencesGroup:title` is rendered as given on every
|
|
44
|
+
* target, and libadwaita does not upper-case it.
|
|
45
|
+
*/
|
|
46
|
+
export const OVERVIEW_GROUP_TITLES = {
|
|
47
|
+
appearance: 'Appearance',
|
|
48
|
+
account: 'Account',
|
|
49
|
+
shortcuts: 'Shortcuts',
|
|
50
|
+
actions: 'Actions',
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Every remaining string the gallery puts on screen.
|
|
55
|
+
*
|
|
56
|
+
* The rows, shortcuts and accent names were already shared; the labels around
|
|
57
|
+
* them were not, and that is where the uppercase drift got in. Sharing only the
|
|
58
|
+
* headings would fix the one instance and leave the class — a literal repeated in
|
|
59
|
+
* three renderings, with nothing comparing them — so the whole content of the
|
|
60
|
+
* gallery lives here and each target only decides how to BUILD it.
|
|
61
|
+
*/
|
|
62
|
+
export const OVERVIEW_TEXT = {
|
|
63
|
+
bannerTitle: 'You have unsaved changes',
|
|
64
|
+
bannerButton: 'Save',
|
|
65
|
+
darkMode: 'Dark mode',
|
|
66
|
+
darkModeSubtitle: 'Use the dark Adwaita palette',
|
|
67
|
+
notifications: 'Notifications',
|
|
68
|
+
notificationsSubtitle: 'Show toasts for events',
|
|
69
|
+
accentColor: 'Accent color',
|
|
70
|
+
name: 'Name',
|
|
71
|
+
nameValue: 'Ada Lovelace',
|
|
72
|
+
email: 'Email',
|
|
73
|
+
emailValue: 'ada@example.com',
|
|
74
|
+
devices: 'Devices',
|
|
75
|
+
advanced: 'Advanced',
|
|
76
|
+
advancedSubtitle: 'More options',
|
|
77
|
+
save: 'Save changes',
|
|
78
|
+
delete: 'Delete account',
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
/** The spin row's range and starting value, shared so the three agree on it too. */
|
|
82
|
+
export const OVERVIEW_DEVICES = { value: 3, lower: 1, upper: 10, step: 1 } as const;
|
|
83
|
+
|
|
36
84
|
/** The shortcut rows, so the newest widget appears in context and not only alone. */
|
|
37
85
|
export const OVERVIEW_SHORTCUTS: ReadonlyArray<{ title: string; accelerator: string }> = [
|
|
38
86
|
{ title: 'Copy', accelerator: '<Control>C' },
|
|
@@ -8,7 +8,10 @@ import { type StoryArgs, type StoryMeta, type StoryModule, StoryWidget } from '@
|
|
|
8
8
|
import {
|
|
9
9
|
OVERVIEW_ACCENT_OPTIONS,
|
|
10
10
|
OVERVIEW_ADVANCED_ROWS,
|
|
11
|
+
OVERVIEW_DEVICES,
|
|
12
|
+
OVERVIEW_GROUP_TITLES,
|
|
11
13
|
OVERVIEW_SHORTCUTS,
|
|
14
|
+
OVERVIEW_TEXT,
|
|
12
15
|
overviewWidgetsMeta,
|
|
13
16
|
} from './widgets.meta.js';
|
|
14
17
|
|
|
@@ -32,8 +35,8 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
32
35
|
const box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, hexpand: true });
|
|
33
36
|
|
|
34
37
|
this._banner = new Adw.Banner({
|
|
35
|
-
title:
|
|
36
|
-
button_label:
|
|
38
|
+
title: OVERVIEW_TEXT.bannerTitle,
|
|
39
|
+
button_label: OVERVIEW_TEXT.bannerButton,
|
|
37
40
|
revealed: this.args.revealed as boolean,
|
|
38
41
|
});
|
|
39
42
|
box.append(this._banner);
|
|
@@ -43,14 +46,24 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
43
46
|
// --- Appearance: switches and a combo. A widget demo only — the
|
|
44
47
|
// storybook's OWN appearance lives in the header bar's dialog, and wiring
|
|
45
48
|
// these to it would give one setting two controls that disagree.
|
|
46
|
-
const appearance = new Adw.PreferencesGroup({ title:
|
|
49
|
+
const appearance = new Adw.PreferencesGroup({ title: OVERVIEW_GROUP_TITLES.appearance });
|
|
47
50
|
appearance.add(
|
|
48
|
-
new Adw.SwitchRow({
|
|
51
|
+
new Adw.SwitchRow({
|
|
52
|
+
title: OVERVIEW_TEXT.darkMode,
|
|
53
|
+
subtitle: OVERVIEW_TEXT.darkModeSubtitle,
|
|
54
|
+
active: false,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
appearance.add(
|
|
58
|
+
new Adw.SwitchRow({
|
|
59
|
+
title: OVERVIEW_TEXT.notifications,
|
|
60
|
+
subtitle: OVERVIEW_TEXT.notificationsSubtitle,
|
|
61
|
+
active: true,
|
|
62
|
+
}),
|
|
49
63
|
);
|
|
50
|
-
appearance.add(new Adw.SwitchRow({ title: 'Notifications', subtitle: 'Show toasts for events', active: true }));
|
|
51
64
|
appearance.add(
|
|
52
65
|
new Adw.ComboRow({
|
|
53
|
-
title:
|
|
66
|
+
title: OVERVIEW_TEXT.accentColor,
|
|
54
67
|
model: Gtk.StringList.new([...OVERVIEW_ACCENT_OPTIONS]),
|
|
55
68
|
selected: 0,
|
|
56
69
|
}),
|
|
@@ -58,26 +71,36 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
58
71
|
page.add(appearance);
|
|
59
72
|
|
|
60
73
|
// --- Account: entries, a spin row, and a nested expander ---
|
|
61
|
-
const account = new Adw.PreferencesGroup({ title:
|
|
74
|
+
const account = new Adw.PreferencesGroup({ title: OVERVIEW_GROUP_TITLES.account });
|
|
62
75
|
|
|
63
|
-
const name = new Adw.EntryRow({ title:
|
|
64
|
-
name.set_text(
|
|
76
|
+
const name = new Adw.EntryRow({ title: OVERVIEW_TEXT.name });
|
|
77
|
+
name.set_text(OVERVIEW_TEXT.nameValue);
|
|
65
78
|
account.add(name);
|
|
66
79
|
|
|
67
|
-
const email = new Adw.EntryRow({ title:
|
|
68
|
-
email.set_text(
|
|
80
|
+
const email = new Adw.EntryRow({ title: OVERVIEW_TEXT.email });
|
|
81
|
+
email.set_text(OVERVIEW_TEXT.emailValue);
|
|
69
82
|
account.add(email);
|
|
70
83
|
|
|
71
84
|
const devices = new Adw.SpinRow({
|
|
72
|
-
title:
|
|
73
|
-
adjustment: new Gtk.Adjustment({
|
|
85
|
+
title: OVERVIEW_TEXT.devices,
|
|
86
|
+
adjustment: new Gtk.Adjustment({
|
|
87
|
+
value: OVERVIEW_DEVICES.value,
|
|
88
|
+
lower: OVERVIEW_DEVICES.lower,
|
|
89
|
+
upper: OVERVIEW_DEVICES.upper,
|
|
90
|
+
step_increment: OVERVIEW_DEVICES.step,
|
|
91
|
+
page_increment: OVERVIEW_DEVICES.step,
|
|
92
|
+
}),
|
|
74
93
|
});
|
|
75
94
|
// The displayed value does not always follow the adjustment through
|
|
76
95
|
// property-init ordering, so it is set explicitly.
|
|
77
|
-
devices.set_value(
|
|
96
|
+
devices.set_value(OVERVIEW_DEVICES.value);
|
|
78
97
|
account.add(devices);
|
|
79
98
|
|
|
80
|
-
const advanced = new Adw.ExpanderRow({
|
|
99
|
+
const advanced = new Adw.ExpanderRow({
|
|
100
|
+
title: OVERVIEW_TEXT.advanced,
|
|
101
|
+
subtitle: OVERVIEW_TEXT.advancedSubtitle,
|
|
102
|
+
expanded: true,
|
|
103
|
+
});
|
|
81
104
|
for (const row of OVERVIEW_ADVANCED_ROWS) {
|
|
82
105
|
advanced.add_row(
|
|
83
106
|
row.kind === 'switch'
|
|
@@ -89,7 +112,7 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
89
112
|
page.add(account);
|
|
90
113
|
|
|
91
114
|
// --- Shortcuts: the newest widget, in context ---
|
|
92
|
-
const shortcuts = new Adw.PreferencesGroup({ title:
|
|
115
|
+
const shortcuts = new Adw.PreferencesGroup({ title: OVERVIEW_GROUP_TITLES.shortcuts });
|
|
93
116
|
for (const shortcut of OVERVIEW_SHORTCUTS) {
|
|
94
117
|
const row = new Adw.ActionRow({ title: shortcut.title });
|
|
95
118
|
row.add_suffix(new Adw.ShortcutLabel({ accelerator: shortcut.accelerator, valign: Gtk.Align.CENTER }));
|
|
@@ -98,7 +121,7 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
98
121
|
page.add(shortcuts);
|
|
99
122
|
|
|
100
123
|
// --- Actions: the two button styles side by side ---
|
|
101
|
-
const actions = new Adw.PreferencesGroup({ title:
|
|
124
|
+
const actions = new Adw.PreferencesGroup({ title: OVERVIEW_GROUP_TITLES.actions });
|
|
102
125
|
const buttons = new Gtk.Box({
|
|
103
126
|
orientation: Gtk.Orientation.HORIZONTAL,
|
|
104
127
|
spacing: 12,
|
|
@@ -106,10 +129,10 @@ export class OverviewWidgetsStory extends StoryWidget {
|
|
|
106
129
|
margin_top: 6,
|
|
107
130
|
margin_bottom: 6,
|
|
108
131
|
});
|
|
109
|
-
const save = new Gtk.Button({ label:
|
|
132
|
+
const save = new Gtk.Button({ label: OVERVIEW_TEXT.save });
|
|
110
133
|
save.add_css_class('suggested-action');
|
|
111
134
|
buttons.append(save);
|
|
112
|
-
const remove = new Gtk.Button({ label:
|
|
135
|
+
const remove = new Gtk.Button({ label: OVERVIEW_TEXT.delete });
|
|
113
136
|
remove.add_css_class('destructive-action');
|
|
114
137
|
buttons.append(remove);
|
|
115
138
|
actions.add(buttons);
|