@tjakoen/grain 0.1.16 → 0.1.17
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tjakoen/grain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "GRAIN — an AI-interaction design system where every surface is operable by both a human and an AI through one shared vocabulary.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/scripts/presentation.js
CHANGED
|
@@ -203,6 +203,13 @@
|
|
|
203
203
|
case "p": window.open(`${location.pathname}?presenter=1`, "grain-presenter", "width=1100,height=760"); break;
|
|
204
204
|
case "f": togglePresent(); break;
|
|
205
205
|
case "d": {
|
|
206
|
+
// Hand this to grain's theme control when the page has one, so the key and the button
|
|
207
|
+
// agree and the choice persists like every other scheme switch on the site. Flipping the
|
|
208
|
+
// attribute here as well would look identical on screen and quietly forget the choice.
|
|
209
|
+
const ctl = document.querySelector("[data-toggle-scheme]");
|
|
210
|
+
if (ctl) { ctl.click(); break; }
|
|
211
|
+
// standalone deck, no theme island on the page: flip it ourselves and accept that it
|
|
212
|
+
// lasts as long as the tab does.
|
|
206
213
|
const root = document.documentElement;
|
|
207
214
|
const dark = root.dataset.colorScheme
|
|
208
215
|
? root.dataset.colorScheme === "dark"
|
|
@@ -57,6 +57,16 @@ test("the presenter window is the same page, synced, and never shown to the room
|
|
|
57
57
|
expect(js).toMatch(/postMessage\(\{ type: "key"/);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
test("the D key defers to grain's theme control, so it persists like the button", () => {
|
|
61
|
+
// flipping data-color-scheme here as well looks identical and forgets the choice the moment
|
|
62
|
+
// you leave the deck, which is how the key and the button came to disagree
|
|
63
|
+
const block = js.slice(js.indexOf('case "d"'), js.indexOf('case "."'));
|
|
64
|
+
expect(block).toMatch(/querySelector\("\[data-toggle-scheme\]"\)/);
|
|
65
|
+
expect(block).toMatch(/ctl\.click\(\)/);
|
|
66
|
+
// the standalone fallback stays, for a deck on a page with no theme island
|
|
67
|
+
expect(block).toMatch(/root\.dataset\.colorScheme = dark \? "light" : "dark"/);
|
|
68
|
+
});
|
|
69
|
+
|
|
60
70
|
test("typing in a field never moves the deck", () => {
|
|
61
71
|
expect(js).toMatch(/INPUT\|TEXTAREA\|SELECT/);
|
|
62
72
|
expect(js).toMatch(/isContentEditable/);
|