@sdeck/plugin-basics 1.1.0 → 1.3.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/clock.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -145
- package/dist/index.js.map +8 -7
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/theme.d.ts +1 -3
- package/dist/theme.d.ts.map +1 -1
- package/dist/timers.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/clock.tsx +18 -24
- package/src/index.tsx +66 -103
- package/src/plugin.ts +9 -0
- package/src/theme.ts +2 -2
- package/src/timers.tsx +25 -23
package/dist/clock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.tsx"],"names":[],"mappings":"AAMA,2DAA2D;AAC3D,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACtE,OAAO,EAAE,OAAO,GACf,MAAM,CAiBR;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO;;;;EAQpD;AAED,eAAO,MAAM,KAAK,gCAsFhB,CAAC;AAEH,eAAO,MAAM,IAAI,gCA6Df,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAqM1D,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOlD;AAED,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxF;AAkDD,2FAA2F"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
// src/index.tsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { setting as setting3, useKeyPress as useKeyPress2, useKeyPressed as useKeyPressed2 } from "@sdeck/plugin";
|
|
3
|
+
import {
|
|
4
|
+
iconLayer,
|
|
5
|
+
iconLook,
|
|
6
|
+
surface,
|
|
7
|
+
surfaceStyle as surfaceStyle3,
|
|
8
|
+
textLayer
|
|
9
|
+
} from "@sdeck/schema";
|
|
4
10
|
|
|
5
11
|
// src/clock.tsx
|
|
6
|
-
import {
|
|
12
|
+
import { setting, useNow } from "@sdeck/plugin";
|
|
13
|
+
import { surfaceStyle } from "@sdeck/schema";
|
|
14
|
+
|
|
15
|
+
// src/plugin.ts
|
|
16
|
+
import { createPlugin } from "@sdeck/plugin";
|
|
17
|
+
var plugin = createPlugin({
|
|
18
|
+
id: "@sdeck/plugin-basics",
|
|
19
|
+
name: "Basics",
|
|
20
|
+
version: "1.3.0",
|
|
21
|
+
description: "Labels, a clock, the date, timers, a counter, page navigation and brightness.",
|
|
22
|
+
author: "sdeck"
|
|
23
|
+
});
|
|
7
24
|
|
|
8
25
|
// src/theme.ts
|
|
26
|
+
import { KEY } from "@sdeck/schema";
|
|
9
27
|
var THEME = {
|
|
10
|
-
background:
|
|
28
|
+
background: KEY,
|
|
11
29
|
text: "#f4f4f5",
|
|
12
30
|
muted: "#8b8d98",
|
|
13
31
|
faint: "#2b2d36",
|
|
@@ -62,7 +80,7 @@ function timeParts(date, hour12) {
|
|
|
62
80
|
period: hour12 ? hours < 12 ? "AM" : "PM" : ""
|
|
63
81
|
};
|
|
64
82
|
}
|
|
65
|
-
var clock =
|
|
83
|
+
var clock = plugin.action({
|
|
66
84
|
id: "clock",
|
|
67
85
|
name: "Clock",
|
|
68
86
|
description: "The time, as digits or hands, and optionally the date.",
|
|
@@ -70,21 +88,13 @@ var clock = defineAction({
|
|
|
70
88
|
icon: "clock",
|
|
71
89
|
slots: ["key", "window"],
|
|
72
90
|
settings: {
|
|
73
|
-
style: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]
|
|
81
|
-
},
|
|
82
|
-
hour12: { type: "boolean", label: "12-hour clock", visibleIf: { style: "digital" } },
|
|
83
|
-
seconds: { type: "boolean", label: "Show seconds", default: true },
|
|
84
|
-
date: { type: "boolean", label: "Show the date" },
|
|
85
|
-
color: { type: "color", label: "Colour", default: THEME.text },
|
|
86
|
-
accent: { type: "color", label: "Accent", default: THEME.accent },
|
|
87
|
-
background: { type: "color", label: "Background", default: THEME.background }
|
|
91
|
+
style: setting.select("Style", { digital: "Digits", analog: "Hands" }),
|
|
92
|
+
hour12: setting.boolean("12-hour clock", { visibleIf: { style: "digital" } }),
|
|
93
|
+
seconds: setting.boolean("Show seconds", { default: true }),
|
|
94
|
+
date: setting.boolean("Show the date"),
|
|
95
|
+
color: setting.color("Colour", { default: THEME.text }),
|
|
96
|
+
accent: setting.color("Accent", { default: THEME.accent }),
|
|
97
|
+
background: setting.color("Background", { default: THEME.background })
|
|
88
98
|
},
|
|
89
99
|
component: ({ settings, slot }) => {
|
|
90
100
|
const now = useNow(settings.seconds ? 1000 : 1e4);
|
|
@@ -102,7 +112,7 @@ var clock = defineAction({
|
|
|
102
112
|
...fill,
|
|
103
113
|
flexDirection: wide ? "row" : "column",
|
|
104
114
|
gap: wide ? 12 : 4,
|
|
105
|
-
|
|
115
|
+
...surfaceStyle(settings.background)
|
|
106
116
|
},
|
|
107
117
|
children: [
|
|
108
118
|
/* @__PURE__ */ jsx("img", {
|
|
@@ -129,7 +139,7 @@ var clock = defineAction({
|
|
|
129
139
|
return /* @__PURE__ */ jsxs("div", {
|
|
130
140
|
style: {
|
|
131
141
|
...column,
|
|
132
|
-
|
|
142
|
+
...surfaceStyle(settings.background),
|
|
133
143
|
color: settings.color,
|
|
134
144
|
fontWeight: 700,
|
|
135
145
|
gap: wide ? 0 : 2,
|
|
@@ -161,7 +171,7 @@ var clock = defineAction({
|
|
|
161
171
|
});
|
|
162
172
|
}
|
|
163
173
|
});
|
|
164
|
-
var date =
|
|
174
|
+
var date = plugin.action({
|
|
165
175
|
id: "date",
|
|
166
176
|
name: "Date",
|
|
167
177
|
description: "Today's date, like a page torn off a calendar.",
|
|
@@ -169,8 +179,8 @@ var date = defineAction({
|
|
|
169
179
|
icon: "calendar",
|
|
170
180
|
slots: ["key", "window"],
|
|
171
181
|
settings: {
|
|
172
|
-
accent:
|
|
173
|
-
background:
|
|
182
|
+
accent: setting.color("Accent", { default: THEME.danger }),
|
|
183
|
+
background: setting.color("Background", { default: THEME.background })
|
|
174
184
|
},
|
|
175
185
|
component: ({ settings, slot }) => {
|
|
176
186
|
const now = useNow(60000);
|
|
@@ -178,7 +188,7 @@ var date = defineAction({
|
|
|
178
188
|
const month = now.toLocaleDateString(undefined, { month: "short" });
|
|
179
189
|
if (slot.kind === "window") {
|
|
180
190
|
return /* @__PURE__ */ jsxs("div", {
|
|
181
|
-
style: { ...fill, gap: 14,
|
|
191
|
+
style: { ...fill, gap: 14, ...surfaceStyle(settings.background), fontWeight: 700 },
|
|
182
192
|
children: [
|
|
183
193
|
/* @__PURE__ */ jsx("div", {
|
|
184
194
|
style: { display: "flex", fontSize: 36, color: THEME.text },
|
|
@@ -204,7 +214,7 @@ var date = defineAction({
|
|
|
204
214
|
style: {
|
|
205
215
|
...column,
|
|
206
216
|
justifyContent: "flex-start",
|
|
207
|
-
|
|
217
|
+
...surfaceStyle(settings.background),
|
|
208
218
|
fontWeight: 700
|
|
209
219
|
},
|
|
210
220
|
children: [
|
|
@@ -236,14 +246,8 @@ var date = defineAction({
|
|
|
236
246
|
});
|
|
237
247
|
|
|
238
248
|
// src/timers.tsx
|
|
239
|
-
import {
|
|
240
|
-
|
|
241
|
-
defineTrigger,
|
|
242
|
-
useKeyPress,
|
|
243
|
-
useKeyPressed,
|
|
244
|
-
useNow as useNow2,
|
|
245
|
-
usePage
|
|
246
|
-
} from "@sdeck/plugin";
|
|
249
|
+
import { setting as setting2, useKeyPress, useKeyPressed, useNow as useNow2, usePage } from "@sdeck/plugin";
|
|
250
|
+
import { surfaceStyle as surfaceStyle2 } from "@sdeck/schema";
|
|
247
251
|
import { useEffect, useReducer } from "react";
|
|
248
252
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
249
253
|
var elapsed = (run, now) => run.banked + (run.startedAt === undefined ? 0 : now - run.startedAt);
|
|
@@ -254,7 +258,7 @@ var runs = new Map;
|
|
|
254
258
|
var runOf = (id) => runs.get(id) ?? { banked: 0 };
|
|
255
259
|
var slotId = (page, slot, kind) => `${kind}|${page}|${slot.kind}|${"index" in slot ? slot.index : 0}`;
|
|
256
260
|
var ended = new Set;
|
|
257
|
-
var timerEnded =
|
|
261
|
+
var timerEnded = plugin.trigger({
|
|
258
262
|
id: "timer-ended",
|
|
259
263
|
name: "When a timer ends",
|
|
260
264
|
description: "Fires when any Basics timer reaches zero.",
|
|
@@ -275,7 +279,13 @@ function Countdown(props) {
|
|
|
275
279
|
const color = done ? "#ffffff" : running ? THEME.text : THEME.muted;
|
|
276
280
|
if (wide) {
|
|
277
281
|
return /* @__PURE__ */ jsxs2("div", {
|
|
278
|
-
style: {
|
|
282
|
+
style: {
|
|
283
|
+
...column,
|
|
284
|
+
...surfaceStyle2(background),
|
|
285
|
+
padding: "0 16px",
|
|
286
|
+
gap: 6,
|
|
287
|
+
fontWeight: 700
|
|
288
|
+
},
|
|
279
289
|
children: [
|
|
280
290
|
/* @__PURE__ */ jsxs2("div", {
|
|
281
291
|
style: {
|
|
@@ -317,7 +327,7 @@ function Countdown(props) {
|
|
|
317
327
|
});
|
|
318
328
|
}
|
|
319
329
|
return /* @__PURE__ */ jsxs2("div", {
|
|
320
|
-
style: { ...fill, background, position: "relative" },
|
|
330
|
+
style: { ...fill, ...surfaceStyle2(background), position: "relative" },
|
|
321
331
|
children: [
|
|
322
332
|
/* @__PURE__ */ jsx2("img", {
|
|
323
333
|
src: ring(1 - remaining / total, done ? "#ffffff" : accent, THEME.faint),
|
|
@@ -347,7 +357,7 @@ function Countdown(props) {
|
|
|
347
357
|
]
|
|
348
358
|
});
|
|
349
359
|
}
|
|
350
|
-
var timer =
|
|
360
|
+
var timer = plugin.action({
|
|
351
361
|
id: "timer",
|
|
352
362
|
name: "Timer",
|
|
353
363
|
description: "Counts down. Press to start or pause, hold to reset. Blinks when it ends.",
|
|
@@ -355,13 +365,13 @@ var timer = defineAction2({
|
|
|
355
365
|
icon: "timer",
|
|
356
366
|
slots: ["key", "window"],
|
|
357
367
|
settings: {
|
|
358
|
-
minutes:
|
|
359
|
-
seconds:
|
|
360
|
-
label:
|
|
361
|
-
accent:
|
|
362
|
-
background:
|
|
368
|
+
minutes: setting2.number("Minutes", { default: 5, min: 0, max: 600 }),
|
|
369
|
+
seconds: setting2.number("Seconds", { default: 0, min: 0, max: 59 }),
|
|
370
|
+
label: setting2.text("Label", { placeholder: "Tea, Focus…" }),
|
|
371
|
+
accent: setting2.color("Ring colour", { default: THEME.warm }),
|
|
372
|
+
background: setting2.color("Background", { default: THEME.background })
|
|
363
373
|
},
|
|
364
|
-
component: ({ settings, slot, plugin }) => {
|
|
374
|
+
component: ({ settings, slot, plugin: plugin2 }) => {
|
|
365
375
|
const page = usePage();
|
|
366
376
|
const id = slotId(page, slot, "timer");
|
|
367
377
|
const total = Math.max(1, (settings.minutes * 60 + settings.seconds) * 1000);
|
|
@@ -379,9 +389,9 @@ var timer = defineAction2({
|
|
|
379
389
|
const event = { label: settings.label, seconds: total / 1000 };
|
|
380
390
|
for (const listener of [...ended])
|
|
381
391
|
listener(event);
|
|
382
|
-
|
|
392
|
+
plugin2.emit("timer-ended", event);
|
|
383
393
|
redraw();
|
|
384
|
-
}, [finished, id, total, settings.label,
|
|
394
|
+
}, [finished, id, total, settings.label, plugin2]);
|
|
385
395
|
useKeyPress(() => {
|
|
386
396
|
const current = runOf(id);
|
|
387
397
|
runs.set(id, elapsed(current, Date.now()) >= total ? { banked: 0, startedAt: Date.now() } : toggled(current, Date.now()));
|
|
@@ -404,7 +414,7 @@ var timer = defineAction2({
|
|
|
404
414
|
});
|
|
405
415
|
}
|
|
406
416
|
});
|
|
407
|
-
var stopwatch =
|
|
417
|
+
var stopwatch = plugin.action({
|
|
408
418
|
id: "stopwatch",
|
|
409
419
|
name: "Stopwatch",
|
|
410
420
|
description: "Counts up. Press to start or stop, hold to reset.",
|
|
@@ -412,9 +422,9 @@ var stopwatch = defineAction2({
|
|
|
412
422
|
icon: "watch",
|
|
413
423
|
slots: ["key", "window"],
|
|
414
424
|
settings: {
|
|
415
|
-
label:
|
|
416
|
-
accent:
|
|
417
|
-
background:
|
|
425
|
+
label: setting2.text("Label", { placeholder: "Shown under the time" }),
|
|
426
|
+
accent: setting2.color("Colour while running", { default: THEME.success }),
|
|
427
|
+
background: setting2.color("Background", { default: THEME.background })
|
|
418
428
|
},
|
|
419
429
|
component: ({ settings, slot }) => {
|
|
420
430
|
const page = usePage();
|
|
@@ -443,7 +453,7 @@ var stopwatch = defineAction2({
|
|
|
443
453
|
style: {
|
|
444
454
|
...column,
|
|
445
455
|
...wide && { flexDirection: "row", gap: 14 },
|
|
446
|
-
|
|
456
|
+
...surfaceStyle2(pressed ? THEME.faint : settings.background),
|
|
447
457
|
fontWeight: 700
|
|
448
458
|
},
|
|
449
459
|
children: [
|
|
@@ -474,21 +484,7 @@ var stopwatch = defineAction2({
|
|
|
474
484
|
|
|
475
485
|
// src/index.tsx
|
|
476
486
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
477
|
-
|
|
478
|
-
const { icon, iconColor, caption, captionColor, background } = options;
|
|
479
|
-
return {
|
|
480
|
-
background,
|
|
481
|
-
layers: [
|
|
482
|
-
iconLayer("icon", icon, {
|
|
483
|
-
color: iconColor,
|
|
484
|
-
size: caption ? 44 : 54,
|
|
485
|
-
position: caption ? "top" : "middle"
|
|
486
|
-
}),
|
|
487
|
-
...caption ? [textLayer("label", caption, { color: captionColor, size: 13, position: "bottom" })] : []
|
|
488
|
-
]
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
var label = defineAction3({
|
|
487
|
+
var label = plugin.action({
|
|
492
488
|
id: "label",
|
|
493
489
|
name: "Label",
|
|
494
490
|
description: "Text and an icon or picture. The text can show live values: CPU {{system.cpu}}%.",
|
|
@@ -496,11 +492,11 @@ var label = defineAction3({
|
|
|
496
492
|
icon: "type",
|
|
497
493
|
slots: ["key", "sensor", "window"],
|
|
498
494
|
settings: {
|
|
499
|
-
text:
|
|
500
|
-
image:
|
|
501
|
-
background:
|
|
502
|
-
color:
|
|
503
|
-
fontSize:
|
|
495
|
+
text: setting3.text("Text", { default: "Hello" }),
|
|
496
|
+
image: setting3.image("Icon or picture"),
|
|
497
|
+
background: setting3.color("Background", { default: THEME.background }),
|
|
498
|
+
color: setting3.color("Text colour", { default: THEME.text }),
|
|
499
|
+
fontSize: setting3.number("Text size", { default: 18, min: 8, max: 60 })
|
|
504
500
|
},
|
|
505
501
|
display: true,
|
|
506
502
|
look: (s) => {
|
|
@@ -510,33 +506,32 @@ var label = defineAction3({
|
|
|
510
506
|
id: "icon",
|
|
511
507
|
type: "image",
|
|
512
508
|
src: s.image,
|
|
513
|
-
size: s.text ?
|
|
514
|
-
position:
|
|
509
|
+
size: s.text ? 48 : 68,
|
|
510
|
+
position: "middle",
|
|
515
511
|
color: s.color
|
|
516
512
|
});
|
|
517
513
|
}
|
|
518
514
|
if (s.text) {
|
|
519
515
|
layers.push(textLayer("label", s.text, {
|
|
520
516
|
color: s.color,
|
|
521
|
-
size: s.image ? Math.min(s.fontSize, 14) : s.fontSize
|
|
522
|
-
position: s.image ? "bottom" : "middle"
|
|
517
|
+
size: s.image ? Math.min(s.fontSize, 14) : s.fontSize
|
|
523
518
|
}));
|
|
524
519
|
}
|
|
525
|
-
return { background: s.background, layers };
|
|
520
|
+
return { background: surface(s.background), layers };
|
|
526
521
|
}
|
|
527
522
|
});
|
|
528
|
-
var counter =
|
|
523
|
+
var counter = plugin.action({
|
|
529
524
|
id: "counter",
|
|
530
525
|
name: "Counter",
|
|
531
526
|
description: "Counts presses. Hold to reset. The count is saved.",
|
|
532
527
|
category: "Display",
|
|
533
528
|
icon: "hash",
|
|
534
529
|
settings: {
|
|
535
|
-
title:
|
|
536
|
-
count:
|
|
537
|
-
step:
|
|
538
|
-
accent:
|
|
539
|
-
background:
|
|
530
|
+
title: setting3.text("Title", { default: "" }),
|
|
531
|
+
count: setting3.number("Count", { default: 0 }),
|
|
532
|
+
step: setting3.number("Step", { default: 1 }),
|
|
533
|
+
accent: setting3.color("Colour", { default: THEME.accent }),
|
|
534
|
+
background: setting3.color("Background", { default: THEME.background })
|
|
540
535
|
},
|
|
541
536
|
component: ({ settings, setSettings }) => {
|
|
542
537
|
const pressed = useKeyPressed2();
|
|
@@ -548,7 +543,7 @@ var counter = defineAction3({
|
|
|
548
543
|
return /* @__PURE__ */ jsxs3("div", {
|
|
549
544
|
style: {
|
|
550
545
|
...column,
|
|
551
|
-
|
|
546
|
+
...surfaceStyle3(pressed ? settings.accent : settings.background),
|
|
552
547
|
fontWeight: 700,
|
|
553
548
|
gap: 2
|
|
554
549
|
},
|
|
@@ -597,7 +592,7 @@ var targets = {
|
|
|
597
592
|
home: "Home",
|
|
598
593
|
favorite: "Favorites"
|
|
599
594
|
};
|
|
600
|
-
var navigate =
|
|
595
|
+
var navigate = plugin.action({
|
|
601
596
|
id: "navigate",
|
|
602
597
|
name: "Navigate",
|
|
603
598
|
description: "Go to a page, back, forward, or to the next or previous page.",
|
|
@@ -605,30 +600,23 @@ var navigate = defineAction3({
|
|
|
605
600
|
icon: "move-right",
|
|
606
601
|
slots: ["key", "sensor"],
|
|
607
602
|
settings: {
|
|
608
|
-
to: {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
{ value: "favorite", label: "Next favorite page" }
|
|
620
|
-
]
|
|
621
|
-
},
|
|
622
|
-
page: { type: "page", label: "Page", visibleIf: { to: "page" } },
|
|
623
|
-
wrap: {
|
|
624
|
-
type: "boolean",
|
|
625
|
-
label: "Wrap around",
|
|
603
|
+
to: setting3.select("Go to", {
|
|
604
|
+
page: "A page",
|
|
605
|
+
back: "Back (history)",
|
|
606
|
+
forward: "Forward (history)",
|
|
607
|
+
next: "Next page",
|
|
608
|
+
previous: "Previous page",
|
|
609
|
+
home: "First page",
|
|
610
|
+
favorite: "Next favorite page"
|
|
611
|
+
}),
|
|
612
|
+
page: setting3.page("Page", { required: true, visibleIf: { to: "page" } }),
|
|
613
|
+
wrap: setting3.boolean("Wrap around", {
|
|
626
614
|
description: "After the last page comes the first.",
|
|
627
615
|
visibleIf: { to: ["next", "previous"] }
|
|
628
|
-
},
|
|
629
|
-
text:
|
|
630
|
-
background:
|
|
631
|
-
color:
|
|
616
|
+
}),
|
|
617
|
+
text: setting3.text("Text", { placeholder: "Defaults to the target", appearance: true }),
|
|
618
|
+
background: setting3.color("Background", { default: THEME.background, appearance: true }),
|
|
619
|
+
color: setting3.color("Icon colour", { default: THEME.accent, appearance: true })
|
|
632
620
|
},
|
|
633
621
|
run: ({ settings, deck }) => {
|
|
634
622
|
if (settings.to === "page") {
|
|
@@ -639,15 +627,14 @@ var navigate = defineAction3({
|
|
|
639
627
|
deck.navigate(settings.to, undefined, { wrap: settings.wrap });
|
|
640
628
|
return { label: settings.to === "page" ? `Go to ${settings.page}` : targets[settings.to] };
|
|
641
629
|
},
|
|
642
|
-
look: (s) =>
|
|
630
|
+
look: (s) => iconLook({
|
|
643
631
|
icon: NAVIGATE_ICONS[s.to],
|
|
644
|
-
|
|
632
|
+
color: s.to === "favorite" ? THEME.warm : s.color,
|
|
645
633
|
caption: s.text || (s.to === "page" ? s.page : ""),
|
|
646
|
-
captionColor: THEME.text,
|
|
647
634
|
background: s.background
|
|
648
635
|
})
|
|
649
636
|
});
|
|
650
|
-
var pageName =
|
|
637
|
+
var pageName = plugin.action({
|
|
651
638
|
id: "page-name",
|
|
652
639
|
name: "Page name",
|
|
653
640
|
description: "Shows which page is open.",
|
|
@@ -655,14 +642,14 @@ var pageName = defineAction3({
|
|
|
655
642
|
icon: "file-text",
|
|
656
643
|
slots: ["key", "sensor", "window"],
|
|
657
644
|
settings: {
|
|
658
|
-
color:
|
|
659
|
-
accent:
|
|
660
|
-
background:
|
|
661
|
-
fontSize:
|
|
645
|
+
color: setting3.color("Text colour", { default: THEME.text }),
|
|
646
|
+
accent: setting3.color("Icon colour", { default: THEME.accent }),
|
|
647
|
+
background: setting3.color("Background", { default: THEME.background }),
|
|
648
|
+
fontSize: setting3.number("Text size", { default: 20, min: 8, max: 60 })
|
|
662
649
|
},
|
|
663
650
|
display: true,
|
|
664
651
|
look: (s) => ({
|
|
665
|
-
background: s.background,
|
|
652
|
+
background: surface(s.background),
|
|
666
653
|
layers: [
|
|
667
654
|
iconLayer("icon", "lucide/layers", { color: s.accent, size: 30, row: "name" }),
|
|
668
655
|
textLayer("label", "{{page.name}}", { color: s.color, size: s.fontSize, row: "name" })
|
|
@@ -678,7 +665,7 @@ function nextLevel(levels, current) {
|
|
|
678
665
|
const i = levels.indexOf(current);
|
|
679
666
|
return levels[(i + 1) % levels.length];
|
|
680
667
|
}
|
|
681
|
-
var brightness =
|
|
668
|
+
var brightness = plugin.action({
|
|
682
669
|
id: "brightness",
|
|
683
670
|
name: "Brightness",
|
|
684
671
|
description: "Set the deck's brightness, or cycle through levels.",
|
|
@@ -686,30 +673,20 @@ var brightness = defineAction3({
|
|
|
686
673
|
icon: "sun",
|
|
687
674
|
slots: ["key", "sensor"],
|
|
688
675
|
settings: {
|
|
689
|
-
mode: {
|
|
690
|
-
|
|
691
|
-
label: "Mode",
|
|
692
|
-
default: "cycle",
|
|
693
|
-
options: [
|
|
694
|
-
{ value: "cycle", label: "Cycle through levels" },
|
|
695
|
-
{ value: "set", label: "Set a level" }
|
|
696
|
-
]
|
|
697
|
-
},
|
|
698
|
-
level: {
|
|
699
|
-
type: "number",
|
|
700
|
-
label: "Level (%)",
|
|
676
|
+
mode: setting3.select("Mode", { cycle: "Cycle through levels", set: "Set a level" }),
|
|
677
|
+
level: setting3.number("Level (%)", {
|
|
701
678
|
default: 100,
|
|
702
679
|
min: 0,
|
|
703
680
|
max: 100,
|
|
704
681
|
visibleIf: { mode: "set" }
|
|
705
|
-
},
|
|
706
|
-
levels: {
|
|
707
|
-
type: "text",
|
|
708
|
-
label: "Levels to cycle",
|
|
682
|
+
}),
|
|
683
|
+
levels: setting3.text("Levels to cycle", {
|
|
709
684
|
default: "10, 40, 70, 100",
|
|
685
|
+
required: true,
|
|
686
|
+
validate: (list) => parseLevels(list).length > 0 ? undefined : "should be numbers from 0 to 100, like 10, 50, 100",
|
|
710
687
|
visibleIf: { mode: "cycle" }
|
|
711
|
-
},
|
|
712
|
-
background:
|
|
688
|
+
}),
|
|
689
|
+
background: setting3.color("Background", { default: THEME.background, appearance: true })
|
|
713
690
|
},
|
|
714
691
|
run: async ({ settings, deck }) => {
|
|
715
692
|
const before = deck.brightness();
|
|
@@ -723,20 +700,14 @@ var brightness = defineAction3({
|
|
|
723
700
|
undo: () => deck.setBrightness(before)
|
|
724
701
|
};
|
|
725
702
|
},
|
|
726
|
-
look: (s) =>
|
|
703
|
+
look: (s) => iconLook({
|
|
727
704
|
icon: s.mode === "cycle" ? "lucide/sun-medium" : s.level < 50 ? "lucide/sun-dim" : "lucide/sun",
|
|
728
|
-
|
|
705
|
+
color: THEME.warm,
|
|
729
706
|
caption: s.mode === "cycle" ? "" : `${s.level}%`,
|
|
730
|
-
captionColor: THEME.text,
|
|
731
707
|
background: s.background
|
|
732
708
|
})
|
|
733
709
|
});
|
|
734
|
-
var src_default =
|
|
735
|
-
id: "@sdeck/plugin-basics",
|
|
736
|
-
name: "Basics",
|
|
737
|
-
version: "1.1.0",
|
|
738
|
-
description: "Labels, a clock, the date, timers, a counter, page navigation and brightness.",
|
|
739
|
-
author: "sdeck",
|
|
710
|
+
var src_default = plugin.define({
|
|
740
711
|
actions: [label, clock, date, timer, stopwatch, counter, navigate, pageName, brightness],
|
|
741
712
|
triggers: [timerEnded]
|
|
742
713
|
});
|
|
@@ -751,4 +722,4 @@ export {
|
|
|
751
722
|
toggled
|
|
752
723
|
};
|
|
753
724
|
|
|
754
|
-
//# debugId=
|
|
725
|
+
//# debugId=91D40EAA3A09022764756E2164756E21
|