@20baht/stickers 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -79,7 +79,7 @@ Light DOM, display block; the canvas fills the element's width at 1:1, so size t
79
79
  | `enter` | `number` | Seconds after first shown to pop in on the bounce entrance. |
80
80
  | `replay-on-hover` | `boolean` | Replay from frame 0 when the pointer enters. |
81
81
  | `line` | `number` | Outline weight as a multiple of the sticker's own: `0.6` thinner, `1.5` bolder. 1 by default. |
82
- | `label` | `string` | Accessible name; the sticker's name by default. |
82
+ | `label` | `string` | Accessible name; the sticker's name by default. `label=""` makes it decorative: skipped by assistive technology. |
83
83
 
84
84
  `replay()` restarts the motion. Register stickers before the element renders.
85
85
 
@@ -98,6 +98,13 @@ view waits until it scrolls in.
98
98
  | `gold` | `--baht-gold-400` | coins, stars, bells |
99
99
  | `ok` | `--baht-success` | checks, success |
100
100
  | `hot` | `--baht-error` | hearts, alerts |
101
+ | `free` | `--baht-color-text` | lines with no fill behind them |
102
+
103
+ The ink itself (`ink`, the outline of every fill) stays dark in dark mode. A line with nothing painted behind it (steam,
104
+ a stem, a signal arc) has no fill to stand on, so there it takes `free`: `--baht-color-text`, or the text colour on a
105
+ page without the tokens. A line that runs over a fill is ink on the fill and `free` past its edge. A `palette` of
106
+ your own draws those lines in its `ink` unless it sets `free`. Through `draw()`, "nothing behind it" means
107
+ transparent pixels: over a ground you painted first, lines are ink.
101
108
 
102
109
  Fixed palettes: `BAHT` (฿20) and `PALETTES.note50 | note100 | note500 | note1000`; helpers `brand(a, b)`,
103
110
  `mono(hex)`, `hue(deg)`. `paletteFromTokens(el)` reads the tokens yourself.
package/dist/element.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { Icon, Palette } from './sticker.js';
7
7
  * Give it a registered `name` (`<baht-sticker name="piggy-bank">` after `import '@20baht/stickers/all'` or
8
8
  * `registerSticker(piggyBank)`), or an `icon` object as a property, which wins over `name`.
9
9
  *
10
- * Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber) where it sits and
10
+ * Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber, text) where it sits and
11
11
  * re-reads them when the root's `data-note`, `data-theme`, `data-baht-theme`, `class` or `style`, or the colour scheme, changes,
12
12
  * so it follows the banknote theme and dark mode. It reads them when it is on screen: a sticker out of view waits
13
13
  * until it scrolls in, and one whose colours come back the same does not repaint.
@@ -19,7 +19,8 @@ import type { Icon, Palette } from './sticker.js';
19
19
  * @attr offset - Frames ahead of the page clock, to put neighbours out of phase.
20
20
  * @attr enter - Seconds after first shown to pop in on the bounce entrance; unset skips the entrance.
21
21
  * @attr replay-on-hover - Replay from frame 0 when the pointer enters.
22
- * @attr label - Accessible name; the sticker's name by default.
22
+ * @attr label - Accessible name; the sticker's name by default. Empty (`label=""`) makes the sticker decorative:
23
+ * assistive technology skips it, for one beside words that already say the same.
23
24
  * @attr line - Outline weight as a multiple of the sticker's own: `0.6` thinner, `1.5` bolder; 1 by default.
24
25
  */
25
26
  export declare class BahtSticker extends LitElement {
@@ -70,6 +71,7 @@ export declare class BahtSticker extends LitElement {
70
71
  offset: number | undefined;
71
72
  enter: number | undefined;
72
73
  replayOnHover: boolean;
74
+ /** Accessible name; unset is the sticker's name, `''` makes it decorative (hidden from assistive technology). */
73
75
  label: string | undefined;
74
76
  /** Outline weight as a multiple of the sticker's own; unset is 1. */
75
77
  line: number | undefined;
@@ -86,6 +88,8 @@ export declare class BahtSticker extends LitElement {
86
88
  connectedCallback(): void;
87
89
  disconnectedCallback(): void;
88
90
  protected updated(changed: PropertyValues<this>): void;
91
+ /** An image with a name, or, with an empty one, nothing assistive technology reads. */
92
+ private nameCanvas;
89
93
  private readonly onPointerEnter;
90
94
  /** The theme may have changed: the tokens are read again when the sticker is next painted, not here. */
91
95
  private readonly onTheme;
package/dist/element.js CHANGED
@@ -29,8 +29,10 @@ function watchTheme(stale) {
29
29
  attributes: true,
30
30
  attributeFilter: ['data-note', 'data-theme', 'data-baht-theme', 'class', 'style'],
31
31
  });
32
- schemeWatch = matchMedia('(prefers-color-scheme: dark)');
33
- schemeWatch.addEventListener('change', onTheme);
32
+ // jsdom has no matchMedia
33
+ schemeWatch =
34
+ typeof matchMedia === 'undefined' ? undefined : matchMedia('(prefers-color-scheme: dark)');
35
+ schemeWatch?.addEventListener('change', onTheme);
34
36
  }
35
37
  /** Taken down again when the last sticker leaves the page. */
36
38
  function unwatchTheme(stale) {
@@ -48,7 +50,7 @@ function unwatchTheme(stale) {
48
50
  * Give it a registered `name` (`<baht-sticker name="piggy-bank">` after `import '@20baht/stickers/all'` or
49
51
  * `registerSticker(piggyBank)`), or an `icon` object as a property, which wins over `name`.
50
52
  *
51
- * Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber) where it sits and
53
+ * Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber, text) where it sits and
52
54
  * re-reads them when the root's `data-note`, `data-theme`, `data-baht-theme`, `class` or `style`, or the colour scheme, changes,
53
55
  * so it follows the banknote theme and dark mode. It reads them when it is on screen: a sticker out of view waits
54
56
  * until it scrolls in, and one whose colours come back the same does not repaint.
@@ -60,7 +62,8 @@ function unwatchTheme(stale) {
60
62
  * @attr offset - Frames ahead of the page clock, to put neighbours out of phase.
61
63
  * @attr enter - Seconds after first shown to pop in on the bounce entrance; unset skips the entrance.
62
64
  * @attr replay-on-hover - Replay from frame 0 when the pointer enters.
63
- * @attr label - Accessible name; the sticker's name by default.
65
+ * @attr label - Accessible name; the sticker's name by default. Empty (`label=""`) makes the sticker decorative:
66
+ * assistive technology skips it, for one beside words that already say the same.
64
67
  * @attr line - Outline weight as a multiple of the sticker's own: `0.6` thinner, `1.5` bolder; 1 by default.
65
68
  */
66
69
  export class BahtSticker extends LitElement {
@@ -123,7 +126,6 @@ export class BahtSticker extends LitElement {
123
126
  this.canvas ??= document.createElement('canvas');
124
127
  if (!this.canvas.isConnected)
125
128
  this.append(this.canvas);
126
- this.canvas.setAttribute('role', 'img');
127
129
  this.addEventListener('pointerenter', this.onPointerEnter);
128
130
  watchTheme(this.onTheme);
129
131
  // the first connect starts from updated(); a reconnect has no property change to start it
@@ -140,12 +142,23 @@ export class BahtSticker extends LitElement {
140
142
  }
141
143
  updated(changed) {
142
144
  const icon = this.resolvedIcon;
143
- this.canvas?.setAttribute('aria-label', this.label ?? icon?.name ?? this.name ?? 'sticker');
145
+ this.nameCanvas(this.label ?? icon?.name ?? this.name ?? 'sticker');
144
146
  if (icon !== this.playing || !this.player)
145
147
  this.start();
146
148
  else if (changed.size)
147
149
  this.player.set(this.options());
148
150
  }
151
+ /** An image with a name, or, with an empty one, nothing assistive technology reads. */
152
+ nameCanvas(name) {
153
+ const attrs = { role: 'img', 'aria-label': name, 'aria-hidden': 'true' };
154
+ const on = name === '' ? ['aria-hidden'] : ['role', 'aria-label'];
155
+ for (const [attr, value] of Object.entries(attrs)) {
156
+ if (on.includes(attr))
157
+ this.canvas?.setAttribute(attr, value);
158
+ else
159
+ this.canvas?.removeAttribute(attr);
160
+ }
161
+ }
149
162
  options() {
150
163
  return {
151
164
  palette: this.palette ?? this.readTokens,
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const cron: Icon;
@@ -0,0 +1,86 @@
1
+ // Drawn for @20baht/stickers (kammacron's cron jobs): a week planner on the leaned face, the same day marked
2
+ // week after week, and a repeat arrow that spins once round its disc.
3
+ import { jolt, springTurn, twinkle } from '../motions.js';
4
+ import { arc, ellipse, line, pill, poly, rect } from '../sticker.js';
5
+ import { EXT, FACE, glow, LINE } from './shared.js';
6
+ const X0 = -122;
7
+ const Y0 = -50;
8
+ const CW = 49;
9
+ const RH = 46;
10
+ // the grid of days: five columns, three weeks
11
+ const grid = [
12
+ ...[1, 2].map((r) => ({ d: line([X0, Y0 + r * RH], [X0 + 5 * CW, Y0 + r * RH]) })),
13
+ ...[1, 2, 3, 4].map((c) => ({
14
+ d: line([X0 + c * CW, Y0 + 8], [X0 + c * CW, Y0 + 3 * RH - 8]),
15
+ })),
16
+ ];
17
+ // the day that repeats: Tuesday, every week
18
+ const day = (week) => [X0 + 1.5 * CW, Y0 + (week + 0.5) * RH];
19
+ const mark = (week, start) => {
20
+ const [x, y] = day(week);
21
+ return {
22
+ parent: 'face',
23
+ a: [x, y],
24
+ p: [x, y],
25
+ m: [twinkle(start), twinkle(130 + week * 4, true)],
26
+ shapes: [{ d: rect(x - 15, y - 13, 30, 26, 7), fill: 'main', depth: 0.3 }],
27
+ };
28
+ };
29
+ const DISC = [104, 104];
30
+ const R = 30;
31
+ const head = () => {
32
+ const a = (200 * Math.PI) / 180;
33
+ const [x, y] = [DISC[0] + Math.cos(a) * R, DISC[1] + Math.sin(a) * R];
34
+ return poly([
35
+ [x - 11, y + 2],
36
+ [x + 11, y + 2],
37
+ [x, y - 14],
38
+ ], 3);
39
+ };
40
+ export const cron = {
41
+ name: 'cron',
42
+ frames: 180,
43
+ still: 100,
44
+ line: LINE,
45
+ extrude: EXT,
46
+ layers: [
47
+ { id: 'cron', p: [250, 280], m: { ...jolt(), at: 8 }, shapes: [] },
48
+ {
49
+ id: 'face',
50
+ parent: 'cron',
51
+ tilt: FACE,
52
+ shapes: [
53
+ { d: rect(-140, -126, 280, 260, 22), fill: 'tint', depth: 0.6 },
54
+ { d: rect(-140, -140, 280, 260, 22), fill: 'white', depth: 0.4 },
55
+ { d: rect(-140, -140, 280, 72, 22), fill: 'deep' },
56
+ ...grid,
57
+ ],
58
+ },
59
+ mark(0, 30),
60
+ mark(1, 42),
61
+ mark(2, 54),
62
+ {
63
+ parent: 'face',
64
+ shapes: [-70, 70].map((x) => ({
65
+ d: pill(x - 10, -160, 20, 46),
66
+ fill: 'main',
67
+ depth: 0.6,
68
+ })),
69
+ },
70
+ {
71
+ id: 'disc',
72
+ parent: 'face',
73
+ a: DISC,
74
+ p: DISC,
75
+ shapes: [{ d: ellipse(DISC[0], DISC[1], 54), fill: 'gold', depth: 0.8 }],
76
+ },
77
+ {
78
+ parent: 'disc',
79
+ a: DISC,
80
+ p: DISC,
81
+ m: { r: springTurn(360, 18, 1.2) },
82
+ shapes: [{ d: arc(DISC[0], DISC[1], R, -150, 190) }, { d: head(), fill: 'ink' }],
83
+ },
84
+ glow('cron', [150, -150], 24, [twinkle(64), twinkle(140, true)]),
85
+ ],
86
+ };
@@ -12,6 +12,9 @@ import { scissors } from './scissors.js';
12
12
  import { clipboard } from './clipboard.js';
13
13
  import { highlighter } from './highlighter.js';
14
14
  import { eyedropper } from './eyedropper.js';
15
+ import { ticketSearch } from './ticket-search.js';
16
+ import { ticketStamped } from './ticket-stamped.js';
17
+ import { ticketWallet } from './ticket-wallet.js';
15
18
  import { timer } from './timer.js';
16
19
  import { snapshots } from './snapshots.js';
17
20
  import { remoteDesktop } from './remote-desktop.js';
@@ -150,6 +153,8 @@ import { calculator } from './calculator.js';
150
153
  import { budgetJar } from './budget-jar.js';
151
154
  import { pieChart } from './pie-chart.js';
152
155
  import { calendarMonth } from './calendar-month.js';
156
+ import { cron } from './cron.js';
157
+ import { kanban } from './kanban.js';
153
158
  import { goal } from './goal.js';
154
159
  import { overBudget } from './over-budget.js';
155
160
  import { savingStreak } from './saving-streak.js';
@@ -180,6 +185,6 @@ import { redmiNote9sPro } from './redmi-note-9s-pro.js';
180
185
  import { nas2bay } from './nas-2bay.js';
181
186
  import { powerStation } from './power-station.js';
182
187
  import { studioMonitors } from './studio-monitors.js';
183
- export { file, trash, copyFiles, compare, remoteFolder, photo, hardDrive, usbDrive, snip, scissors, clipboard, highlighter, eyedropper, timer, snapshots, remoteDesktop, cursor, keyboard, terminal, tunnel, wakeOnLan, lockScreen, aiAgent, certificate, sslCertificate, piggyBank, stock, bahtNote, dollarNote, bond, goldBar, kaprao, noodleSoup, padSeeEw, trainTicket, tukTuk, chaYen, mangoStickyRice, twoFactor, otp, sms, email, register, support, idCard, fingerprint, faceId, password, verified, qrCode, accessPoint, allInOne, badgeReader, bear, bladeChassis, cctv, classicPhone, cooling, coreSwitch, database, desktopTower, firewall, homeRouter, hsm, iotSensor, ipPhone, key, kvm, laptop, loadBalancer, miniPc, modem, monitor, nas, notebook, patchPanel, pdu, pos, printer, rack, router, server, serverCabinet, shield, smartphone, smartTv, storageArray, switchBox, tablet, tapeLibrary, ups, vpnGateway, wallet, macMini, thinkpadL380, macbookAir, ipadGen8, iphone17, redmiNote9sPro, nas2bay, powerStation, studioMonitors, receipt, income, expense, coins, calculator, budgetJar, pieChart, calendarMonth, goal, overBudget, savingStreak, emptyState, exportFile, scanSlip, interest, btsCard, motorbikeTaxi, convenienceBag, electricBill, phoneTopup, rent, marketBasket, lottery, templeDonation, fuel, shoppingBox, salary, angpao, freelance, spiritHouse, thaiHouse, woodenWindow, waterJar, streetFoodCart, plasticStool, powerPole, streetSign, mailboxThai, chedi, marigold, phuangMalai, bananaTree, bamboo, longTailBoat, bananaLeaf, thaiLantern, lotus, sun, moon, cloud, rainCloud, storm, rainbow, star, shootingStar, rock, pottedPlant, cactus, monstera, flower, tulip, tree, palmTree, campfire, tent, confetti, musicNote, mediaPlayer, paperBoat, kite, alarmClock, books, hotDrink, lamp, discImage, keyPair, metrics, virtualMachine, floatingIp, };
188
+ export { file, trash, copyFiles, compare, remoteFolder, photo, hardDrive, usbDrive, snip, scissors, clipboard, highlighter, eyedropper, timer, snapshots, remoteDesktop, cursor, keyboard, terminal, tunnel, wakeOnLan, lockScreen, aiAgent, certificate, sslCertificate, piggyBank, stock, bahtNote, dollarNote, bond, goldBar, kaprao, noodleSoup, padSeeEw, trainTicket, ticketStamped, ticketSearch, ticketWallet, tukTuk, chaYen, mangoStickyRice, twoFactor, otp, sms, email, register, support, idCard, fingerprint, faceId, password, verified, qrCode, accessPoint, allInOne, badgeReader, bear, bladeChassis, cctv, classicPhone, cooling, coreSwitch, database, desktopTower, firewall, homeRouter, hsm, iotSensor, ipPhone, key, kvm, laptop, loadBalancer, miniPc, modem, monitor, nas, notebook, patchPanel, pdu, pos, printer, rack, router, server, serverCabinet, shield, smartphone, smartTv, storageArray, switchBox, tablet, tapeLibrary, ups, vpnGateway, wallet, macMini, thinkpadL380, macbookAir, ipadGen8, iphone17, redmiNote9sPro, nas2bay, powerStation, studioMonitors, receipt, income, expense, coins, calculator, budgetJar, pieChart, calendarMonth, cron, kanban, goal, overBudget, savingStreak, emptyState, exportFile, scanSlip, interest, btsCard, motorbikeTaxi, convenienceBag, electricBill, phoneTopup, rent, marketBasket, lottery, templeDonation, fuel, shoppingBox, salary, angpao, freelance, spiritHouse, thaiHouse, woodenWindow, waterJar, streetFoodCart, plasticStool, powerPole, streetSign, mailboxThai, chedi, marigold, phuangMalai, bananaTree, bamboo, longTailBoat, bananaLeaf, thaiLantern, lotus, sun, moon, cloud, rainCloud, storm, rainbow, star, shootingStar, rock, pottedPlant, cactus, monstera, flower, tulip, tree, palmTree, campfire, tent, confetti, musicNote, mediaPlayer, paperBoat, kite, alarmClock, books, hotDrink, lamp, discImage, keyPair, metrics, virtualMachine, floatingIp, };
184
189
  /** The whole set, in catalogue order. */
185
190
  export declare const ICONS: readonly Icon[];
@@ -11,6 +11,9 @@ import { scissors } from './scissors.js';
11
11
  import { clipboard } from './clipboard.js';
12
12
  import { highlighter } from './highlighter.js';
13
13
  import { eyedropper } from './eyedropper.js';
14
+ import { ticketSearch } from './ticket-search.js';
15
+ import { ticketStamped } from './ticket-stamped.js';
16
+ import { ticketWallet } from './ticket-wallet.js';
14
17
  import { timer } from './timer.js';
15
18
  import { snapshots } from './snapshots.js';
16
19
  import { remoteDesktop } from './remote-desktop.js';
@@ -149,6 +152,8 @@ import { calculator } from './calculator.js';
149
152
  import { budgetJar } from './budget-jar.js';
150
153
  import { pieChart } from './pie-chart.js';
151
154
  import { calendarMonth } from './calendar-month.js';
155
+ import { cron } from './cron.js';
156
+ import { kanban } from './kanban.js';
152
157
  import { goal } from './goal.js';
153
158
  import { overBudget } from './over-budget.js';
154
159
  import { savingStreak } from './saving-streak.js';
@@ -179,7 +184,7 @@ import { redmiNote9sPro } from './redmi-note-9s-pro.js';
179
184
  import { nas2bay } from './nas-2bay.js';
180
185
  import { powerStation } from './power-station.js';
181
186
  import { studioMonitors } from './studio-monitors.js';
182
- export { file, trash, copyFiles, compare, remoteFolder, photo, hardDrive, usbDrive, snip, scissors, clipboard, highlighter, eyedropper, timer, snapshots, remoteDesktop, cursor, keyboard, terminal, tunnel, wakeOnLan, lockScreen, aiAgent, certificate, sslCertificate, piggyBank, stock, bahtNote, dollarNote, bond, goldBar, kaprao, noodleSoup, padSeeEw, trainTicket, tukTuk, chaYen, mangoStickyRice, twoFactor, otp, sms, email, register, support, idCard, fingerprint, faceId, password, verified, qrCode, accessPoint, allInOne, badgeReader, bear, bladeChassis, cctv, classicPhone, cooling, coreSwitch, database, desktopTower, firewall, homeRouter, hsm, iotSensor, ipPhone, key, kvm, laptop, loadBalancer, miniPc, modem, monitor, nas, notebook, patchPanel, pdu, pos, printer, rack, router, server, serverCabinet, shield, smartphone, smartTv, storageArray, switchBox, tablet, tapeLibrary, ups, vpnGateway, wallet, macMini, thinkpadL380, macbookAir, ipadGen8, iphone17, redmiNote9sPro, nas2bay, powerStation, studioMonitors, receipt, income, expense, coins, calculator, budgetJar, pieChart, calendarMonth, goal, overBudget, savingStreak, emptyState, exportFile, scanSlip, interest, btsCard, motorbikeTaxi, convenienceBag, electricBill, phoneTopup, rent, marketBasket, lottery, templeDonation, fuel, shoppingBox, salary, angpao, freelance, spiritHouse, thaiHouse, woodenWindow, waterJar, streetFoodCart, plasticStool, powerPole, streetSign, mailboxThai, chedi, marigold, phuangMalai, bananaTree, bamboo, longTailBoat, bananaLeaf, thaiLantern, lotus, sun, moon, cloud, rainCloud, storm, rainbow, star, shootingStar, rock, pottedPlant, cactus, monstera, flower, tulip, tree, palmTree, campfire, tent, confetti, musicNote, mediaPlayer, paperBoat, kite, alarmClock, books, hotDrink, lamp, discImage, keyPair, metrics, virtualMachine, floatingIp, };
187
+ export { file, trash, copyFiles, compare, remoteFolder, photo, hardDrive, usbDrive, snip, scissors, clipboard, highlighter, eyedropper, timer, snapshots, remoteDesktop, cursor, keyboard, terminal, tunnel, wakeOnLan, lockScreen, aiAgent, certificate, sslCertificate, piggyBank, stock, bahtNote, dollarNote, bond, goldBar, kaprao, noodleSoup, padSeeEw, trainTicket, ticketStamped, ticketSearch, ticketWallet, tukTuk, chaYen, mangoStickyRice, twoFactor, otp, sms, email, register, support, idCard, fingerprint, faceId, password, verified, qrCode, accessPoint, allInOne, badgeReader, bear, bladeChassis, cctv, classicPhone, cooling, coreSwitch, database, desktopTower, firewall, homeRouter, hsm, iotSensor, ipPhone, key, kvm, laptop, loadBalancer, miniPc, modem, monitor, nas, notebook, patchPanel, pdu, pos, printer, rack, router, server, serverCabinet, shield, smartphone, smartTv, storageArray, switchBox, tablet, tapeLibrary, ups, vpnGateway, wallet, macMini, thinkpadL380, macbookAir, ipadGen8, iphone17, redmiNote9sPro, nas2bay, powerStation, studioMonitors, receipt, income, expense, coins, calculator, budgetJar, pieChart, calendarMonth, cron, kanban, goal, overBudget, savingStreak, emptyState, exportFile, scanSlip, interest, btsCard, motorbikeTaxi, convenienceBag, electricBill, phoneTopup, rent, marketBasket, lottery, templeDonation, fuel, shoppingBox, salary, angpao, freelance, spiritHouse, thaiHouse, woodenWindow, waterJar, streetFoodCart, plasticStool, powerPole, streetSign, mailboxThai, chedi, marigold, phuangMalai, bananaTree, bamboo, longTailBoat, bananaLeaf, thaiLantern, lotus, sun, moon, cloud, rainCloud, storm, rainbow, star, shootingStar, rock, pottedPlant, cactus, monstera, flower, tulip, tree, palmTree, campfire, tent, confetti, musicNote, mediaPlayer, paperBoat, kite, alarmClock, books, hotDrink, lamp, discImage, keyPair, metrics, virtualMachine, floatingIp, };
183
188
  /** The whole set, in catalogue order. */
184
189
  export const ICONS = [
185
190
  wallet,
@@ -200,6 +205,8 @@ export const ICONS = [
200
205
  budgetJar,
201
206
  pieChart,
202
207
  calendarMonth,
208
+ cron,
209
+ kanban,
203
210
  goal,
204
211
  overBudget,
205
212
  savingStreak,
@@ -335,6 +342,9 @@ export const ICONS = [
335
342
  noodleSoup,
336
343
  padSeeEw,
337
344
  trainTicket,
345
+ ticketStamped,
346
+ ticketSearch,
347
+ ticketWallet,
338
348
  tukTuk,
339
349
  chaYen,
340
350
  mangoStickyRice,
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const kanban: Icon;
@@ -0,0 +1,85 @@
1
+ // Drawn for @20baht/stickers (kammacron's board): three columns of cards on the leaned face; one card is
2
+ // lifted out of To do, carried to Doing and set down there.
3
+ import { SNAP, twinkle } from '../motions.js';
4
+ import { line, pill, rect } from '../sticker.js';
5
+ import { EXT, FACE, glow, LINE } from './shared.js';
6
+ const COL = 92;
7
+ const X0 = -146;
8
+ const TOP = -70;
9
+ const CARD_H = 52;
10
+ const GAP = 14;
11
+ const colX = (c) => X0 + c * (COL + 8);
12
+ // a card: a white slab with a line of text on it
13
+ const card = (c, row, fill = 'white') => {
14
+ const x = colX(c) + 8;
15
+ const y = TOP + row * (CARD_H + GAP);
16
+ return [
17
+ { d: rect(x, y, COL - 16, CARD_H, 10), fill, depth: 0.3 },
18
+ { d: line([x + 12, y + 20], [x + COL - 30, y + 20]) },
19
+ { d: line([x + 12, y + 34], [x + 38, y + 34]) },
20
+ ];
21
+ };
22
+ const FROM = [colX(0) + COL / 2, TOP + CARD_H + GAP + CARD_H / 2];
23
+ const MOVE = [COL + 8, -(CARD_H + GAP)];
24
+ export const kanban = {
25
+ name: 'kanban',
26
+ frames: 180,
27
+ still: 110,
28
+ line: LINE,
29
+ extrude: EXT,
30
+ layers: [
31
+ { id: 'kanban', p: [250, 290], shapes: [] },
32
+ {
33
+ id: 'face',
34
+ parent: 'kanban',
35
+ tilt: FACE,
36
+ shapes: [
37
+ { d: rect(-160, -116, 316, 220, 22), fill: 'tint', depth: 0.6 },
38
+ { d: rect(-160, -130, 316, 220, 22), fill: 'white', depth: 0.4 },
39
+ ...[0, 1, 2].map((c) => ({
40
+ d: pill(colX(c) + 8, -116, COL - 16, 26),
41
+ fill: c === 2 ? 'ok' : 'main',
42
+ depth: 0.3,
43
+ })),
44
+ ...[1, 2].map((c) => ({ d: line([colX(c) - 4, -110], [colX(c) - 4, 76]) })),
45
+ ...card(0, 0),
46
+ ...card(2, 0),
47
+ ...card(2, 1),
48
+ ],
49
+ },
50
+ {
51
+ id: 'card',
52
+ parent: 'face',
53
+ a: FROM,
54
+ p: FROM,
55
+ m: [
56
+ {
57
+ p: [
58
+ [20, [0, 0], SNAP],
59
+ [64, MOVE, 0],
60
+ [140, MOVE, SNAP],
61
+ [170, [0, 0]],
62
+ ],
63
+ },
64
+ {
65
+ s: [
66
+ [14, [100, 100], SNAP],
67
+ [26, [112, 112], 0],
68
+ [58, [112, 112], SNAP],
69
+ [70, [100, 100], 0],
70
+ ],
71
+ },
72
+ {
73
+ x: [
74
+ [14, 0, SNAP],
75
+ [26, 10, 0],
76
+ [58, 10, SNAP],
77
+ [70, 0],
78
+ ],
79
+ },
80
+ ],
81
+ shapes: card(0, 1, 'gold'),
82
+ },
83
+ glow('kanban', [70, -170], 22, [twinkle(66), twinkle(140, true)]),
84
+ ],
85
+ };
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const ticketSearch: Icon;
@@ -0,0 +1,50 @@
1
+ // Nothing matches: a magnifier goes over a blank coupon and finds no line on it.
2
+ // Drawn for ITSM (itsm-web), moved here from its repo.
3
+ import { jolt, slide, twinkle } from '../motions.js';
4
+ import { ellipse, line, poly, rect, ring } from '../sticker.js';
5
+ import { EXT, FACE, glow, LINE } from './shared.js';
6
+ const BAND = [
7
+ [-165, -100],
8
+ [165, -100],
9
+ [165, -64],
10
+ [-165, -64],
11
+ ];
12
+ const PERF = [-54, -26, 2, 30, 58].map((y) => ({
13
+ d: line([-84, y], [-84, y + 14]),
14
+ line: 4,
15
+ }));
16
+ export const ticketSearch = {
17
+ name: 'ticket-search',
18
+ frames: 180,
19
+ line: LINE,
20
+ extrude: EXT,
21
+ still: 80,
22
+ layers: [
23
+ { id: 'root', p: [246, 262], shapes: [] },
24
+ {
25
+ id: 'ticket',
26
+ parent: 'root',
27
+ tilt: FACE,
28
+ m: { ...jolt(), k: 0.5 },
29
+ shapes: [
30
+ { d: rect(-165, -100, 330, 190, 16), fill: 'white', depth: 0.8 },
31
+ { d: poly(BAND, [16, 16, 0, 0]), fill: 'main' },
32
+ ...PERF,
33
+ { d: line([-146, -24], [-106, -24]), line: 9 },
34
+ { d: line([-146, 4], [-116, 4]) },
35
+ ],
36
+ },
37
+ {
38
+ parent: 'root',
39
+ tilt: FACE,
40
+ m: slide([86, 10], 14, 50, 50),
41
+ shapes: [
42
+ { d: rect(8, 84, 28, 96, 12), fill: 'gold', depth: 0.8 },
43
+ { d: ellipse(22, 22, 52), fill: 'tint' },
44
+ { d: ring(22, 22, 66, 48), fill: 'deep', depth: 0.6 },
45
+ { d: line([-4, 12], [12, -4]), line: 7 },
46
+ ],
47
+ },
48
+ glow('root', [-160, -120], 24, [twinkle(60), twinkle(140, true)]),
49
+ ],
50
+ };
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const ticketStamped: Icon;
@@ -0,0 +1,66 @@
1
+ // A request handed in: a coupon lies on the desk, a rubber stamp comes down on it and leaves a green check.
2
+ // Drawn for ITSM (itsm-web), moved here from its repo.
3
+ import { impact, slide, twinkle } from '../motions.js';
4
+ import { line } from '../sticker.js';
5
+ import { block, dot, faceOf, ISO, quad, solid, stroke } from '../iso.js';
6
+ import { drum } from './object-drum.js';
7
+ import { glow, LINE } from './shared.js';
8
+ const TICKET = block([-170, -95, 0], [340, 0, 0], [0, 190, 0], [0, 0, 14]);
9
+ const TOP = faceOf(TICKET, 'top');
10
+ // the coupon's tear line, left of the stub
11
+ const PERF = [0.1, 0.24, 0.38, 0.52, 0.66].map((t) => ({
12
+ d: stroke(TOP, [0.27, t], [0.27, t + 0.07]),
13
+ line: 4,
14
+ }));
15
+ // the mark sits where the stamp lands
16
+ const MARK = [0.64, 0.38];
17
+ const [mx, my] = TOP.at(...MARK);
18
+ const PAD = block([-8, -63, 14], [112, 0, 0], [0, 80, 0], [0, 0, 24]);
19
+ const NECK = drum([48, -23, 38], [0, 0, 44], 15, 15, { side: 'grey', cap: 'grey' });
20
+ const KNOB = drum([48, -23, 78], [0, 0, 34], 34, 34, { side: 'main', cap: 'main' });
21
+ const RAISED = 120;
22
+ export const ticketStamped = {
23
+ name: 'ticket-stamped',
24
+ frames: 180,
25
+ line: LINE,
26
+ extrude: [0, 0],
27
+ still: 130,
28
+ layers: [
29
+ { id: 'desk', p: [250, 320], shapes: [] },
30
+ {
31
+ id: 'ticket',
32
+ parent: 'desk',
33
+ m: { ...impact([0, 6]), at: 14 },
34
+ shapes: [
35
+ ...solid(TICKET, { fill: 'white' }, 4),
36
+ { d: quad(TOP, 0, 0.8, 1, 0.2, 4), fill: 'main' },
37
+ ...PERF,
38
+ { d: stroke(TOP, [0.07, 0.56], [0.2, 0.56]), line: 9 },
39
+ { d: stroke(TOP, [0.07, 0.36], [0.17, 0.36]) },
40
+ { d: stroke(TOP, [0.34, 0.64], [0.46, 0.64]) },
41
+ { d: stroke(TOP, [0.34, 0.44], [0.44, 0.44]) },
42
+ { d: stroke(TOP, [0.34, 0.24], [0.46, 0.24]) },
43
+ ],
44
+ },
45
+ {
46
+ parent: 'ticket',
47
+ a: [mx, my],
48
+ p: [mx, my],
49
+ m: [twinkle(26), twinkle(150, true)],
50
+ shapes: [
51
+ { d: dot(TOP, MARK[0], MARK[1], 0.12, 0.215), fill: 'ok' },
52
+ {
53
+ d: line(TOP.at(MARK[0] - 0.055, MARK[1] + 0.01), TOP.at(MARK[0] - 0.01, MARK[1] - 0.08), TOP.at(MARK[0] + 0.065, MARK[1] + 0.1)),
54
+ line: 9,
55
+ },
56
+ ],
57
+ },
58
+ {
59
+ parent: 'desk',
60
+ p: [0, -RAISED],
61
+ m: slide([0, RAISED], 6, 14, 34),
62
+ shapes: [...solid(PAD, { fill: 'deep', top: 'main' }, 4), ...NECK.shapes, ...KNOB.shapes],
63
+ },
64
+ glow('desk', [ISO([-170, 0, 0])[0] + 10, -120], 24, [twinkle(64), twinkle(140, true)]),
65
+ ],
66
+ };
@@ -0,0 +1,2 @@
1
+ import type { Icon } from '../sticker.js';
2
+ export declare const ticketWallet: Icon;
@@ -0,0 +1,44 @@
1
+ // No request yet: a ticket wallet with a blank coupon that slides up out of its pocket, ready to fill in.
2
+ // Drawn for ITSM (itsm-web), moved here from its repo.
3
+ import { jolt, slide, twinkle } from '../motions.js';
4
+ import { line, pill, rect } from '../sticker.js';
5
+ import { EXT, FACE, glow, LINE } from './shared.js';
6
+ const PERF = [-118, -88, -58, -28, 2, 32, 62, 92].map((x) => ({
7
+ d: line([x, -62], [x + 16, -62]),
8
+ line: 4,
9
+ }));
10
+ export const ticketWallet = {
11
+ name: 'ticket-wallet',
12
+ frames: 180,
13
+ line: LINE,
14
+ extrude: EXT,
15
+ still: 90,
16
+ layers: [
17
+ { id: 'root', p: [250, 290], m: { ...jolt(), k: 0.5 }, shapes: [] },
18
+ { id: 'face', parent: 'root', tilt: FACE, shapes: [] },
19
+ {
20
+ parent: 'face',
21
+ shapes: [{ d: rect(-150, -110, 300, 220, 20), fill: 'deep', depth: 1 }],
22
+ },
23
+ {
24
+ parent: 'face',
25
+ m: slide([0, -56], 12, 60, 48),
26
+ shapes: [
27
+ { d: rect(-128, -100, 256, 180, 12), fill: 'white', depth: 0.3 },
28
+ { d: line([-104, -80], [-30, -80]), line: 9 },
29
+ { d: pill(66, -88, 40, 16), fill: 'ok' },
30
+ ...PERF,
31
+ { d: line([-104, -36], [40, -36]) },
32
+ ],
33
+ },
34
+ {
35
+ parent: 'face',
36
+ shapes: [
37
+ { d: rect(-150, -18, 300, 128, 20), fill: 'main', depth: 0.6 },
38
+ { d: rect(-46, 26, 92, 40, 8), fill: 'white', depth: 0.2 },
39
+ { d: line([-26, 46], [26, 46]) },
40
+ ],
41
+ },
42
+ glow('root', [-170, -130], 24, [twinkle(60), twinkle(140, true)]),
43
+ ],
44
+ };
package/dist/load.d.ts CHANGED
@@ -19,6 +19,8 @@ declare const LOADERS: {
19
19
  cactus: () => Promise<Icon>;
20
20
  calculator: () => Promise<Icon>;
21
21
  'calendar-month': () => Promise<Icon>;
22
+ cron: () => Promise<Icon>;
23
+ kanban: () => Promise<Icon>;
22
24
  campfire: () => Promise<Icon>;
23
25
  cctv: () => Promise<Icon>;
24
26
  certificate: () => Promise<Icon>;
@@ -164,6 +166,9 @@ declare const LOADERS: {
164
166
  'thai-house': () => Promise<Icon>;
165
167
  'thai-lantern': () => Promise<Icon>;
166
168
  'thinkpad-l380': () => Promise<Icon>;
169
+ 'ticket-search': () => Promise<Icon>;
170
+ 'ticket-stamped': () => Promise<Icon>;
171
+ 'ticket-wallet': () => Promise<Icon>;
167
172
  timer: () => Promise<Icon>;
168
173
  'train-ticket': () => Promise<Icon>;
169
174
  trash: () => Promise<Icon>;
package/dist/load.js CHANGED
@@ -18,6 +18,8 @@ const LOADERS = {
18
18
  cactus: async () => (await import('./icons/cactus.js')).cactus,
19
19
  calculator: async () => (await import('./icons/calculator.js')).calculator,
20
20
  'calendar-month': async () => (await import('./icons/calendar-month.js')).calendarMonth,
21
+ cron: async () => (await import('./icons/cron.js')).cron,
22
+ kanban: async () => (await import('./icons/kanban.js')).kanban,
21
23
  campfire: async () => (await import('./icons/campfire.js')).campfire,
22
24
  cctv: async () => (await import('./icons/cctv.js')).cctv,
23
25
  certificate: async () => (await import('./icons/certificate.js')).certificate,
@@ -163,6 +165,9 @@ const LOADERS = {
163
165
  'thai-house': async () => (await import('./icons/thai-house.js')).thaiHouse,
164
166
  'thai-lantern': async () => (await import('./icons/thai-lantern.js')).thaiLantern,
165
167
  'thinkpad-l380': async () => (await import('./icons/thinkpad-l380.js')).thinkpadL380,
168
+ 'ticket-search': async () => (await import('./icons/ticket-search.js')).ticketSearch,
169
+ 'ticket-stamped': async () => (await import('./icons/ticket-stamped.js')).ticketStamped,
170
+ 'ticket-wallet': async () => (await import('./icons/ticket-wallet.js')).ticketWallet,
166
171
  timer: async () => (await import('./icons/timer.js')).timer,
167
172
  'train-ticket': async () => (await import('./icons/train-ticket.js')).trainTicket,
168
173
  trash: async () => (await import('./icons/trash.js')).trash,
package/dist/sticker.d.ts CHANGED
@@ -44,6 +44,8 @@ export interface Palette {
44
44
  grey: string;
45
45
  paper: string;
46
46
  ink: string;
47
+ /** Lines with nothing painted behind them (steam, a stem, a signal arc), so they read on a dark page; `ink` when unset. */
48
+ free?: string;
47
49
  }
48
50
  export declare const ACCENTS: readonly ["main", "gold", "tint", "ok", "hot", "deep"];
49
51
  export type Accent = (typeof ACCENTS)[number];
@@ -63,6 +65,8 @@ export declare const PALETTES: {
63
65
  grey: string;
64
66
  paper: string;
65
67
  ink: string;
68
+ /** Lines with nothing painted behind them (steam, a stem, a signal arc), so they read on a dark page; `ink` when unset. */
69
+ free?: string;
66
70
  };
67
71
  note100: {
68
72
  main: string;
@@ -75,6 +79,8 @@ export declare const PALETTES: {
75
79
  grey: string;
76
80
  paper: string;
77
81
  ink: string;
82
+ /** Lines with nothing painted behind them (steam, a stem, a signal arc), so they read on a dark page; `ink` when unset. */
83
+ free?: string;
78
84
  };
79
85
  note500: {
80
86
  main: string;
@@ -87,6 +93,8 @@ export declare const PALETTES: {
87
93
  grey: string;
88
94
  paper: string;
89
95
  ink: string;
96
+ /** Lines with nothing painted behind them (steam, a stem, a signal arc), so they read on a dark page; `ink` when unset. */
97
+ free?: string;
90
98
  };
91
99
  note1000: {
92
100
  main: string;
@@ -99,11 +107,13 @@ export declare const PALETTES: {
99
107
  grey: string;
100
108
  paper: string;
101
109
  ink: string;
110
+ /** Lines with nothing painted behind them (steam, a stem, a signal arc), so they read on a dark page; `ink` when unset. */
111
+ free?: string;
102
112
  };
103
113
  };
104
114
  export type PaletteName = keyof typeof PALETTES;
105
115
  /** A slot, so the colour follows the palette it is drawn with, or a fixed hex. */
106
- export type Swatch = keyof Palette | `#${string}`;
116
+ export type Swatch = Exclude<keyof Palette, 'free'> | `#${string}`;
107
117
  /** Which way flat faces turn, as the layer tilt and icon extrude that draw it. `right` is the house view. */
108
118
  export declare const VIEWS: {
109
119
  readonly right: {
@@ -189,7 +199,10 @@ export declare const shift: <T>(track: Track<T>, by: number) => Track<T>;
189
199
  /** Where a point drawn on a face with this tilt lands in the layer's parent, for pivots and sparkles. */
190
200
  export declare function onFace(tilt: Vec, [x, y]: Vec): Vec;
191
201
  type Ctx = CanvasRenderingContext2D;
192
- /** Paints frame f of an icon into ctx, whose current transform maps icon units (0..size) to its box; `line` scales every outline. */
202
+ /**
203
+ * Paints frame f of an icon into ctx, whose current transform maps icon units (0..size) to its box; `line` scales
204
+ * every outline. The palette's `free` goes on lines over transparent pixels: over a ground already painted they are ink.
205
+ */
193
206
  export declare function draw(ctx: Ctx, icon: Icon, frame: number, palette?: Partial<Palette>, line?: number): void;
194
207
  /** Every accent turned `deg` around the hue wheel, each keeping its own lightness and strength. */
195
208
  export declare function hue(deg: number, from?: Palette): Palette;
@@ -200,7 +213,8 @@ export declare function mono(color: string, from?: Palette): Palette;
200
213
  /** The --baht-* token each accent reads, so a sticker follows the page's banknote theme and dark mode. */
201
214
  export declare const TOKENS: Record<Accent, string>;
202
215
  /**
203
- * The accents as `el` sees the --baht-* tokens right now, as hex. Unset tokens fall back to BAHT.
216
+ * The accents as `el` sees the --baht-* tokens right now, as hex, and the text colour as `free`. Unset tokens fall
217
+ * back to BAHT. The ink is not read: it outlines fills, which stay light or coloured in dark mode.
204
218
  * Colours are resolved by the browser (var(), color-mix()) and read back through a 1px canvas.
205
219
  */
206
220
  export declare function paletteFromTokens(el: Element): Palette;
package/dist/sticker.js CHANGED
@@ -418,6 +418,38 @@ function drawShape(pen, S, d, trim, pose, width, scale = 1) {
418
418
  drawSlab(pen, { ...S, fill }, d, path, pose, w);
419
419
  fillOutlined(pen, path, w, pen.colour(fill));
420
420
  }
421
+ /**
422
+ * A layer's shapes, back to front. With a `free` colour, lines go down in two passes: ink where something is painted
423
+ * already, `free` where nothing is. Lines in a row share the passes, or the second would find the first behind it
424
+ * and turn to ink where they cross.
425
+ */
426
+ function drawLayer(pen, shapes, free, one) {
427
+ const { ctx } = pen;
428
+ const isLine = (S) => S !== undefined && S.fill === undefined;
429
+ for (let i = 0; i < shapes.length; i++) {
430
+ const S = shapes[i];
431
+ if (!S)
432
+ continue;
433
+ if (free === undefined || !isLine(S)) {
434
+ one(pen, S, i);
435
+ continue;
436
+ }
437
+ const from = i;
438
+ while (isLine(shapes[i + 1]))
439
+ i++;
440
+ const run = shapes.slice(from, i + 1);
441
+ const over = ctx.globalCompositeOperation;
442
+ ctx.globalCompositeOperation = 'source-atop';
443
+ run.forEach((L, j) => {
444
+ one(pen, L, from + j);
445
+ });
446
+ ctx.globalCompositeOperation = 'destination-over';
447
+ run.forEach((L, j) => {
448
+ one({ ...pen, ink: free }, L, from + j);
449
+ });
450
+ ctx.globalCompositeOperation = over;
451
+ }
452
+ }
421
453
  /** Clips to a matte layer's shapes, like an After Effects track matte. */
422
454
  function clipTo(pen, mask, sc) {
423
455
  const region = new Path2D();
@@ -430,7 +462,7 @@ function clipTo(pen, mask, sc) {
430
462
  }
431
463
  function render(ctx, icon, sc, palette, line = 1) {
432
464
  const base = ctx.getTransform();
433
- const colour = (c) => (c.startsWith('#') ? c : palette[c]);
465
+ const colour = (c) => c.startsWith('#') ? c : palette[c];
434
466
  const pen = {
435
467
  ctx,
436
468
  base,
@@ -441,6 +473,8 @@ function render(ctx, icon, sc, palette, line = 1) {
441
473
  dev: Math.sqrt(Math.abs(base.a * base.d - base.b * base.c)) || 1,
442
474
  step: new DOMMatrix(),
443
475
  };
476
+ // an icon that names its ink means it on every line
477
+ const free = icon.ink === undefined && palette.free !== pen.ink ? palette.free : undefined;
444
478
  ctx.save();
445
479
  ctx.miterLimit = 4;
446
480
  for (const { L, pose, ds, trims } of sc.parts) {
@@ -448,8 +482,8 @@ function render(ctx, icon, sc, palette, line = 1) {
448
482
  const mask = L.clip ? sc.byId.get(L.clip) : undefined;
449
483
  if (mask)
450
484
  clipTo(pen, mask, sc);
451
- L.shapes.forEach((S, i) => {
452
- drawShape(pen, S, ds[i] ?? '', trims[i] ?? 1, pose, (icon.line ?? 4) * line, line);
485
+ drawLayer(pen, L.shapes, free, (nib, S, i) => {
486
+ drawShape(nib, S, ds[i] ?? '', trims[i] ?? 1, pose, (icon.line ?? 4) * line, line);
453
487
  });
454
488
  if (mask)
455
489
  ctx.restore();
@@ -464,7 +498,10 @@ function resolve(p) {
464
498
  const key = JSON.stringify(p);
465
499
  return themed.get(key) ?? remember(themed, key, { ...BAHT, ...p }, 200);
466
500
  }
467
- /** Paints frame f of an icon into ctx, whose current transform maps icon units (0..size) to its box; `line` scales every outline. */
501
+ /**
502
+ * Paints frame f of an icon into ctx, whose current transform maps icon units (0..size) to its box; `line` scales
503
+ * every outline. The palette's `free` goes on lines over transparent pixels: over a ground already painted they are ink.
504
+ */
468
505
  export function draw(ctx, icon, frame, palette, line = 1) {
469
506
  render(ctx, icon, scene(icon, frame), resolve(palette), line);
470
507
  }
@@ -569,6 +606,8 @@ export const TOKENS = {
569
606
  ok: '--baht-success',
570
607
  hot: '--baht-error',
571
608
  };
609
+ /** What a line with nothing behind it reads: the text token, or the text colour on a page without the tokens. */
610
+ const FREE = 'var(--baht-color-text, currentColor)';
572
611
  let probing;
573
612
  /** The span and the 1px canvas every token read goes through, made once. */
574
613
  function probeKit() {
@@ -582,26 +621,30 @@ function probeKit() {
582
621
  return probing;
583
622
  }
584
623
  /**
585
- * The accents as `el` sees the --baht-* tokens right now, as hex. Unset tokens fall back to BAHT.
624
+ * The accents as `el` sees the --baht-* tokens right now, as hex, and the text colour as `free`. Unset tokens fall
625
+ * back to BAHT. The ink is not read: it outlines fills, which stay light or coloured in dark mode.
586
626
  * Colours are resolved by the browser (var(), color-mix()) and read back through a 1px canvas.
587
627
  */
588
628
  export function paletteFromTokens(el) {
589
629
  const { probe, ctx } = probeKit();
590
630
  el.appendChild(probe);
591
631
  const out = { ...BAHT };
592
- for (const k of ACCENTS) {
632
+ const read = (value, fallback) => {
593
633
  probe.style.color = '';
594
- probe.style.color = `var(${TOKENS[k]}, ${BAHT[k]})`;
634
+ probe.style.color = value;
595
635
  const css = getComputedStyle(probe).color;
596
636
  if (!ctx || !css)
597
- continue;
637
+ return fallback;
598
638
  ctx.clearRect(0, 0, 1, 1);
599
- ctx.fillStyle = BAHT[k];
639
+ ctx.fillStyle = fallback;
600
640
  ctx.fillStyle = css;
601
641
  ctx.fillRect(0, 0, 1, 1);
602
642
  const [r = 0, g = 0, b = 0] = ctx.getImageData(0, 0, 1, 1).data;
603
- out[k] = `#${[r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('')}`;
604
- }
643
+ return `#${[r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('')}`;
644
+ };
645
+ for (const k of ACCENTS)
646
+ out[k] = read(`var(${TOKENS[k]}, ${BAHT[k]})`, BAHT[k]);
647
+ out.free = read(FREE, BAHT.ink);
605
648
  probe.remove();
606
649
  return out;
607
650
  }
@@ -866,7 +909,8 @@ function reread(l) {
866
909
  if (typeof from !== 'function')
867
910
  return;
868
911
  const next = resolve(from());
869
- const slots = Object.keys(next);
912
+ // both: `free` may be in one and not the other
913
+ const slots = Object.keys({ ...l.pal, ...next });
870
914
  if (next === l.pal || slots.every((k) => next[k] === l.pal[k]))
871
915
  return;
872
916
  l.pal = next;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@20baht/stickers",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Animated isometric slab stickers for bahtui: a <baht-sticker> Lit element that follows the --baht-* tokens and banknote themes, a growing set of illustrations, and the canvas runtime that plays them on After Effects keyframe presets.",
6
6
  "license": "MIT",
@@ -90,7 +90,7 @@
90
90
  },
91
91
  "devDependencies": {
92
92
  "happy-dom": "^20.0.0",
93
- "typescript": "^5.8.3",
93
+ "typescript": "^5.9.3",
94
94
  "vitest": "^3.2.4"
95
95
  },
96
96
  "main": "./dist/index.js",