@20baht/stickers 0.0.0-stage → 0.1.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/LICENSE +48 -0
- package/README.md +173 -2
- package/dist/all.d.ts +4 -0
- package/dist/all.js +7 -0
- package/dist/element.d.ts +103 -0
- package/dist/element.js +181 -0
- package/dist/graph.d.ts +172 -0
- package/dist/graph.js +374 -0
- package/dist/icons/access-point.d.ts +2 -0
- package/dist/icons/access-point.js +34 -0
- package/dist/icons/ai-agent.d.ts +2 -0
- package/dist/icons/ai-agent.js +50 -0
- package/dist/icons/alarm-clock.d.ts +2 -0
- package/dist/icons/alarm-clock.js +46 -0
- package/dist/icons/all-in-one.d.ts +2 -0
- package/dist/icons/all-in-one.js +37 -0
- package/dist/icons/angpao.d.ts +2 -0
- package/dist/icons/angpao.js +46 -0
- package/dist/icons/badge-reader.d.ts +2 -0
- package/dist/icons/badge-reader.js +51 -0
- package/dist/icons/baht-note.d.ts +2 -0
- package/dist/icons/baht-note.js +42 -0
- package/dist/icons/bamboo.d.ts +2 -0
- package/dist/icons/bamboo.js +57 -0
- package/dist/icons/banana-leaf.d.ts +2 -0
- package/dist/icons/banana-leaf.js +87 -0
- package/dist/icons/banana-tree.d.ts +2 -0
- package/dist/icons/banana-tree.js +75 -0
- package/dist/icons/bear.d.ts +2 -0
- package/dist/icons/bear.js +39 -0
- package/dist/icons/blade-chassis.d.ts +2 -0
- package/dist/icons/blade-chassis.js +43 -0
- package/dist/icons/bond.d.ts +2 -0
- package/dist/icons/bond.js +48 -0
- package/dist/icons/books.d.ts +2 -0
- package/dist/icons/books.js +44 -0
- package/dist/icons/bts-card.d.ts +2 -0
- package/dist/icons/bts-card.js +47 -0
- package/dist/icons/budget-jar.d.ts +2 -0
- package/dist/icons/budget-jar.js +43 -0
- package/dist/icons/cactus.d.ts +2 -0
- package/dist/icons/cactus.js +42 -0
- package/dist/icons/calculator.d.ts +2 -0
- package/dist/icons/calculator.js +46 -0
- package/dist/icons/calendar-month.d.ts +2 -0
- package/dist/icons/calendar-month.js +66 -0
- package/dist/icons/campfire.d.ts +2 -0
- package/dist/icons/campfire.js +63 -0
- package/dist/icons/cctv.d.ts +2 -0
- package/dist/icons/cctv.js +38 -0
- package/dist/icons/certificate.d.ts +2 -0
- package/dist/icons/certificate.js +50 -0
- package/dist/icons/cha-yen.d.ts +2 -0
- package/dist/icons/cha-yen.js +68 -0
- package/dist/icons/chedi.d.ts +2 -0
- package/dist/icons/chedi.js +56 -0
- package/dist/icons/classic-phone.d.ts +2 -0
- package/dist/icons/classic-phone.js +32 -0
- package/dist/icons/clipboard.d.ts +2 -0
- package/dist/icons/clipboard.js +61 -0
- package/dist/icons/cloud.d.ts +2 -0
- package/dist/icons/cloud.js +28 -0
- package/dist/icons/coins.d.ts +2 -0
- package/dist/icons/coins.js +34 -0
- package/dist/icons/compare.d.ts +2 -0
- package/dist/icons/compare.js +33 -0
- package/dist/icons/confetti.d.ts +2 -0
- package/dist/icons/confetti.js +72 -0
- package/dist/icons/convenience-bag.d.ts +2 -0
- package/dist/icons/convenience-bag.js +51 -0
- package/dist/icons/cooling.d.ts +2 -0
- package/dist/icons/cooling.js +46 -0
- package/dist/icons/copy-files.d.ts +2 -0
- package/dist/icons/copy-files.js +37 -0
- package/dist/icons/core-switch.d.ts +2 -0
- package/dist/icons/core-switch.js +48 -0
- package/dist/icons/cursor.d.ts +2 -0
- package/dist/icons/cursor.js +27 -0
- package/dist/icons/database.d.ts +2 -0
- package/dist/icons/database.js +24 -0
- package/dist/icons/desktop-tower.d.ts +2 -0
- package/dist/icons/desktop-tower.js +41 -0
- package/dist/icons/disc-image.d.ts +2 -0
- package/dist/icons/disc-image.js +54 -0
- package/dist/icons/dollar-note.d.ts +2 -0
- package/dist/icons/dollar-note.js +44 -0
- package/dist/icons/electric-bill.d.ts +2 -0
- package/dist/icons/electric-bill.js +51 -0
- package/dist/icons/email.d.ts +2 -0
- package/dist/icons/email.js +57 -0
- package/dist/icons/empty-state.d.ts +2 -0
- package/dist/icons/empty-state.js +75 -0
- package/dist/icons/expense.d.ts +2 -0
- package/dist/icons/expense.js +36 -0
- package/dist/icons/export-file.d.ts +2 -0
- package/dist/icons/export-file.js +35 -0
- package/dist/icons/eyedropper.d.ts +2 -0
- package/dist/icons/eyedropper.js +69 -0
- package/dist/icons/face-id.d.ts +2 -0
- package/dist/icons/face-id.js +51 -0
- package/dist/icons/file.d.ts +2 -0
- package/dist/icons/file.js +15 -0
- package/dist/icons/finance-b-coins.d.ts +8 -0
- package/dist/icons/finance-b-coins.js +14 -0
- package/dist/icons/finance-tray.d.ts +11 -0
- package/dist/icons/finance-tray.js +41 -0
- package/dist/icons/fingerprint.d.ts +2 -0
- package/dist/icons/fingerprint.js +45 -0
- package/dist/icons/firewall.d.ts +2 -0
- package/dist/icons/firewall.js +76 -0
- package/dist/icons/floating-ip.d.ts +2 -0
- package/dist/icons/floating-ip.js +59 -0
- package/dist/icons/flower.d.ts +2 -0
- package/dist/icons/flower.js +49 -0
- package/dist/icons/food.d.ts +6 -0
- package/dist/icons/food.js +18 -0
- package/dist/icons/freelance.d.ts +2 -0
- package/dist/icons/freelance.js +51 -0
- package/dist/icons/fuel.d.ts +2 -0
- package/dist/icons/fuel.js +46 -0
- package/dist/icons/goal.d.ts +2 -0
- package/dist/icons/goal.js +51 -0
- package/dist/icons/gold-bar.d.ts +2 -0
- package/dist/icons/gold-bar.js +60 -0
- package/dist/icons/hard-drive.d.ts +2 -0
- package/dist/icons/hard-drive.js +42 -0
- package/dist/icons/highlighter.d.ts +2 -0
- package/dist/icons/highlighter.js +75 -0
- package/dist/icons/home-router.d.ts +2 -0
- package/dist/icons/home-router.js +32 -0
- package/dist/icons/hot-drink.d.ts +2 -0
- package/dist/icons/hot-drink.js +33 -0
- package/dist/icons/hsm.d.ts +2 -0
- package/dist/icons/hsm.js +54 -0
- package/dist/icons/id-card.d.ts +2 -0
- package/dist/icons/id-card.js +36 -0
- package/dist/icons/income.d.ts +2 -0
- package/dist/icons/income.js +28 -0
- package/dist/icons/index.d.ts +185 -0
- package/dist/icons/index.js +366 -0
- package/dist/icons/interest.d.ts +2 -0
- package/dist/icons/interest.js +66 -0
- package/dist/icons/iot-sensor.d.ts +2 -0
- package/dist/icons/iot-sensor.js +35 -0
- package/dist/icons/ip-phone.d.ts +2 -0
- package/dist/icons/ip-phone.js +47 -0
- package/dist/icons/ipad-gen8.d.ts +2 -0
- package/dist/icons/ipad-gen8.js +58 -0
- package/dist/icons/iphone-17.d.ts +2 -0
- package/dist/icons/iphone-17.js +37 -0
- package/dist/icons/iso.d.ts +2 -0
- package/dist/icons/iso.js +3 -0
- package/dist/icons/kaprao.d.ts +2 -0
- package/dist/icons/kaprao.js +70 -0
- package/dist/icons/key-pair.d.ts +2 -0
- package/dist/icons/key-pair.js +54 -0
- package/dist/icons/key.d.ts +3 -0
- package/dist/icons/key.js +37 -0
- package/dist/icons/keyboard.d.ts +2 -0
- package/dist/icons/keyboard.js +35 -0
- package/dist/icons/kite.d.ts +2 -0
- package/dist/icons/kite.js +53 -0
- package/dist/icons/kvm.d.ts +2 -0
- package/dist/icons/kvm.js +53 -0
- package/dist/icons/lamp.d.ts +2 -0
- package/dist/icons/lamp.js +49 -0
- package/dist/icons/laptop.d.ts +2 -0
- package/dist/icons/laptop.js +44 -0
- package/dist/icons/load-balancer.d.ts +2 -0
- package/dist/icons/load-balancer.js +50 -0
- package/dist/icons/lock-screen.d.ts +2 -0
- package/dist/icons/lock-screen.js +44 -0
- package/dist/icons/long-tail-boat.d.ts +2 -0
- package/dist/icons/long-tail-boat.js +66 -0
- package/dist/icons/lottery.d.ts +2 -0
- package/dist/icons/lottery.js +51 -0
- package/dist/icons/lotus.d.ts +2 -0
- package/dist/icons/lotus.js +70 -0
- package/dist/icons/mac-mini.d.ts +2 -0
- package/dist/icons/mac-mini.js +31 -0
- package/dist/icons/macbook-air.d.ts +2 -0
- package/dist/icons/macbook-air.js +41 -0
- package/dist/icons/mailbox-thai.d.ts +2 -0
- package/dist/icons/mailbox-thai.js +66 -0
- package/dist/icons/mango-sticky-rice.d.ts +2 -0
- package/dist/icons/mango-sticky-rice.js +41 -0
- package/dist/icons/marigold.d.ts +2 -0
- package/dist/icons/marigold.js +69 -0
- package/dist/icons/market-basket.d.ts +2 -0
- package/dist/icons/market-basket.js +69 -0
- package/dist/icons/media-player.d.ts +2 -0
- package/dist/icons/media-player.js +71 -0
- package/dist/icons/metrics.d.ts +2 -0
- package/dist/icons/metrics.js +58 -0
- package/dist/icons/mini-pc.d.ts +2 -0
- package/dist/icons/mini-pc.js +26 -0
- package/dist/icons/modem.d.ts +2 -0
- package/dist/icons/modem.js +37 -0
- package/dist/icons/monitor.d.ts +2 -0
- package/dist/icons/monitor.js +40 -0
- package/dist/icons/monstera.d.ts +2 -0
- package/dist/icons/monstera.js +47 -0
- package/dist/icons/moon.d.ts +2 -0
- package/dist/icons/moon.js +55 -0
- package/dist/icons/motorbike-taxi.d.ts +2 -0
- package/dist/icons/motorbike-taxi.js +42 -0
- package/dist/icons/music-note.d.ts +2 -0
- package/dist/icons/music-note.js +63 -0
- package/dist/icons/nas-2bay.d.ts +2 -0
- package/dist/icons/nas-2bay.js +49 -0
- package/dist/icons/nas.d.ts +2 -0
- package/dist/icons/nas.js +41 -0
- package/dist/icons/nature-iso.d.ts +29 -0
- package/dist/icons/nature-iso.js +74 -0
- package/dist/icons/noodle-soup.d.ts +2 -0
- package/dist/icons/noodle-soup.js +52 -0
- package/dist/icons/notebook.d.ts +2 -0
- package/dist/icons/notebook.js +44 -0
- package/dist/icons/object-drum.d.ts +18 -0
- package/dist/icons/object-drum.js +63 -0
- package/dist/icons/otp.d.ts +2 -0
- package/dist/icons/otp.js +46 -0
- package/dist/icons/over-budget.d.ts +2 -0
- package/dist/icons/over-budget.js +48 -0
- package/dist/icons/pad-see-ew.d.ts +2 -0
- package/dist/icons/pad-see-ew.js +56 -0
- package/dist/icons/palm-tree.d.ts +2 -0
- package/dist/icons/palm-tree.js +52 -0
- package/dist/icons/paper-boat.d.ts +2 -0
- package/dist/icons/paper-boat.js +67 -0
- package/dist/icons/paper.d.ts +3 -0
- package/dist/icons/paper.js +45 -0
- package/dist/icons/password.d.ts +2 -0
- package/dist/icons/password.js +45 -0
- package/dist/icons/patch-panel.d.ts +2 -0
- package/dist/icons/patch-panel.js +41 -0
- package/dist/icons/pdu.d.ts +2 -0
- package/dist/icons/pdu.js +40 -0
- package/dist/icons/phone-topup.d.ts +2 -0
- package/dist/icons/phone-topup.js +55 -0
- package/dist/icons/photo.d.ts +2 -0
- package/dist/icons/photo.js +48 -0
- package/dist/icons/phuang-malai.d.ts +2 -0
- package/dist/icons/phuang-malai.js +59 -0
- package/dist/icons/pie-chart.d.ts +2 -0
- package/dist/icons/pie-chart.js +36 -0
- package/dist/icons/piggy-bank.d.ts +2 -0
- package/dist/icons/piggy-bank.js +64 -0
- package/dist/icons/plant-kit.d.ts +23 -0
- package/dist/icons/plant-kit.js +112 -0
- package/dist/icons/plastic-stool.d.ts +2 -0
- package/dist/icons/plastic-stool.js +67 -0
- package/dist/icons/pointer.d.ts +1 -0
- package/dist/icons/pointer.js +12 -0
- package/dist/icons/pos.d.ts +2 -0
- package/dist/icons/pos.js +59 -0
- package/dist/icons/potted-plant.d.ts +2 -0
- package/dist/icons/potted-plant.js +31 -0
- package/dist/icons/power-pole.d.ts +2 -0
- package/dist/icons/power-pole.js +60 -0
- package/dist/icons/power-station.d.ts +2 -0
- package/dist/icons/power-station.js +56 -0
- package/dist/icons/printer.d.ts +2 -0
- package/dist/icons/printer.js +46 -0
- package/dist/icons/qr-code.d.ts +2 -0
- package/dist/icons/qr-code.js +45 -0
- package/dist/icons/rack.d.ts +2 -0
- package/dist/icons/rack.js +39 -0
- package/dist/icons/rain-cloud.d.ts +2 -0
- package/dist/icons/rain-cloud.js +31 -0
- package/dist/icons/rainbow.d.ts +2 -0
- package/dist/icons/rainbow.js +46 -0
- package/dist/icons/receipt.d.ts +2 -0
- package/dist/icons/receipt.js +56 -0
- package/dist/icons/redmi-note-9s-pro.d.ts +2 -0
- package/dist/icons/redmi-note-9s-pro.js +37 -0
- package/dist/icons/register.d.ts +2 -0
- package/dist/icons/register.js +40 -0
- package/dist/icons/remote-desktop.d.ts +2 -0
- package/dist/icons/remote-desktop.js +62 -0
- package/dist/icons/remote-folder.d.ts +2 -0
- package/dist/icons/remote-folder.js +55 -0
- package/dist/icons/rent.d.ts +2 -0
- package/dist/icons/rent.js +50 -0
- package/dist/icons/rock.d.ts +2 -0
- package/dist/icons/rock.js +80 -0
- package/dist/icons/router.d.ts +2 -0
- package/dist/icons/router.js +59 -0
- package/dist/icons/salary.d.ts +2 -0
- package/dist/icons/salary.js +54 -0
- package/dist/icons/saving-streak.d.ts +2 -0
- package/dist/icons/saving-streak.js +66 -0
- package/dist/icons/scan-slip.d.ts +2 -0
- package/dist/icons/scan-slip.js +53 -0
- package/dist/icons/scissors.d.ts +2 -0
- package/dist/icons/scissors.js +52 -0
- package/dist/icons/server-cabinet.d.ts +2 -0
- package/dist/icons/server-cabinet.js +49 -0
- package/dist/icons/server.d.ts +2 -0
- package/dist/icons/server.js +41 -0
- package/dist/icons/shared.d.ts +8 -0
- package/dist/icons/shared.js +18 -0
- package/dist/icons/shield.d.ts +3 -0
- package/dist/icons/shield.js +28 -0
- package/dist/icons/shooting-star.d.ts +2 -0
- package/dist/icons/shooting-star.js +37 -0
- package/dist/icons/shopping-box.d.ts +2 -0
- package/dist/icons/shopping-box.js +46 -0
- package/dist/icons/sky-kit.d.ts +19 -0
- package/dist/icons/sky-kit.js +72 -0
- package/dist/icons/smart-tv.d.ts +2 -0
- package/dist/icons/smart-tv.js +39 -0
- package/dist/icons/smartphone.d.ts +2 -0
- package/dist/icons/smartphone.js +30 -0
- package/dist/icons/sms.d.ts +2 -0
- package/dist/icons/sms.js +45 -0
- package/dist/icons/snapshots.d.ts +2 -0
- package/dist/icons/snapshots.js +45 -0
- package/dist/icons/snip.d.ts +2 -0
- package/dist/icons/snip.js +63 -0
- package/dist/icons/spirit-house.d.ts +2 -0
- package/dist/icons/spirit-house.js +73 -0
- package/dist/icons/ssl-certificate.d.ts +2 -0
- package/dist/icons/ssl-certificate.js +56 -0
- package/dist/icons/star.d.ts +2 -0
- package/dist/icons/star.js +16 -0
- package/dist/icons/stock.d.ts +2 -0
- package/dist/icons/stock.js +62 -0
- package/dist/icons/storage-array.d.ts +2 -0
- package/dist/icons/storage-array.js +40 -0
- package/dist/icons/storm.d.ts +2 -0
- package/dist/icons/storm.js +43 -0
- package/dist/icons/street-food-cart.d.ts +2 -0
- package/dist/icons/street-food-cart.js +66 -0
- package/dist/icons/street-kit.d.ts +19 -0
- package/dist/icons/street-kit.js +67 -0
- package/dist/icons/street-sign.d.ts +2 -0
- package/dist/icons/street-sign.js +42 -0
- package/dist/icons/studio-monitors.d.ts +2 -0
- package/dist/icons/studio-monitors.js +67 -0
- package/dist/icons/sun.d.ts +2 -0
- package/dist/icons/sun.js +40 -0
- package/dist/icons/support.d.ts +2 -0
- package/dist/icons/support.js +48 -0
- package/dist/icons/switch.d.ts +2 -0
- package/dist/icons/switch.js +34 -0
- package/dist/icons/tablet.d.ts +2 -0
- package/dist/icons/tablet.js +44 -0
- package/dist/icons/tape-library.d.ts +2 -0
- package/dist/icons/tape-library.js +48 -0
- package/dist/icons/temple-donation.d.ts +2 -0
- package/dist/icons/temple-donation.js +60 -0
- package/dist/icons/tent.d.ts +2 -0
- package/dist/icons/tent.js +66 -0
- package/dist/icons/terminal.d.ts +2 -0
- package/dist/icons/terminal.js +56 -0
- package/dist/icons/thai-house.d.ts +2 -0
- package/dist/icons/thai-house.js +85 -0
- package/dist/icons/thai-lantern.d.ts +2 -0
- package/dist/icons/thai-lantern.js +61 -0
- package/dist/icons/thinkpad-l380.d.ts +2 -0
- package/dist/icons/thinkpad-l380.js +54 -0
- package/dist/icons/timer.d.ts +2 -0
- package/dist/icons/timer.js +59 -0
- package/dist/icons/train-ticket.d.ts +2 -0
- package/dist/icons/train-ticket.js +57 -0
- package/dist/icons/trash.d.ts +2 -0
- package/dist/icons/trash.js +62 -0
- package/dist/icons/tree.d.ts +2 -0
- package/dist/icons/tree.js +40 -0
- package/dist/icons/tuk-tuk.d.ts +2 -0
- package/dist/icons/tuk-tuk.js +45 -0
- package/dist/icons/tulip.d.ts +2 -0
- package/dist/icons/tulip.js +56 -0
- package/dist/icons/tunnel.d.ts +2 -0
- package/dist/icons/tunnel.js +50 -0
- package/dist/icons/two-factor.d.ts +2 -0
- package/dist/icons/two-factor.js +81 -0
- package/dist/icons/ups.d.ts +2 -0
- package/dist/icons/ups.js +37 -0
- package/dist/icons/usb-drive.d.ts +2 -0
- package/dist/icons/usb-drive.js +35 -0
- package/dist/icons/verified.d.ts +2 -0
- package/dist/icons/verified.js +32 -0
- package/dist/icons/virtual-machine.d.ts +2 -0
- package/dist/icons/virtual-machine.js +66 -0
- package/dist/icons/volume.d.ts +6 -0
- package/dist/icons/volume.js +35 -0
- package/dist/icons/vpn-gateway.d.ts +2 -0
- package/dist/icons/vpn-gateway.js +51 -0
- package/dist/icons/wake-on-lan.d.ts +2 -0
- package/dist/icons/wake-on-lan.js +40 -0
- package/dist/icons/wallet.d.ts +3 -0
- package/dist/icons/wallet.js +55 -0
- package/dist/icons/water-jar.d.ts +2 -0
- package/dist/icons/water-jar.js +72 -0
- package/dist/icons/wooden-window.d.ts +2 -0
- package/dist/icons/wooden-window.js +65 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/iso.d.ts +32 -0
- package/dist/iso.js +64 -0
- package/dist/load.d.ts +197 -0
- package/dist/load.js +197 -0
- package/dist/motions.d.ts +68 -0
- package/dist/motions.js +446 -0
- package/dist/sticker.d.ts +269 -0
- package/dist/sticker.js +1009 -0
- package/package.json +101 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nattapong Promthong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The sticker runtime, motion presets and worked icons are derived from fun-isometric
|
|
26
|
+
(https://github.com/kelvinkn17/skills), used under this licence:
|
|
27
|
+
|
|
28
|
+
MIT License
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2026 kelvinkn17
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,174 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @20baht/stickers
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Animated isometric slab stickers for [bahtui](https://github.com/bank20baht/20baht): flat fills, a thick ink
|
|
4
|
+
outline and an extruded side, moving on After Effects keyframe presets that are replayed the way lottie-web plays
|
|
5
|
+
them. A `<baht-sticker>` Lit element plays them on canvas and takes its colours from the page's `--baht-*` tokens,
|
|
6
|
+
so a sticker follows the banknote theme and dark mode. The set grows release by release.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @20baht/stickers
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import '@20baht/stickers/all'; // defines <baht-sticker> and registers every sticker by name
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<baht-sticker name="piggy-bank" enter="0.2" style="width: 160px"></baht-sticker>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Lean bundles take one sticker:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import '@20baht/stickers/element';
|
|
26
|
+
import { registerSticker } from '@20baht/stickers';
|
|
27
|
+
import { piggyBank } from '@20baht/stickers/icons/piggy-bank';
|
|
28
|
+
|
|
29
|
+
registerSticker(piggyBank); // then <baht-sticker name="piggy-bank">, or set el.icon = piggyBank
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
React 19 passes props to custom elements as properties: `<baht-sticker name="piggy-bank" once />`.
|
|
33
|
+
|
|
34
|
+
Angular: `@20baht/angular/stickers` has typed directives for both elements (`imports: [BAHT_STICKERS]`,
|
|
35
|
+
`<baht-sticker name="piggy-bank" [playOnce]="!loop()" />`), so no `CUSTOM_ELEMENTS_SCHEMA`.
|
|
36
|
+
|
|
37
|
+
### Names
|
|
38
|
+
|
|
39
|
+
A sticker's name is its file under `icons/`, its `icon.name` and its `<baht-sticker name>`, all kebab-case. Its
|
|
40
|
+
export is the camelCase of that name: `piggy-bank` → `piggyBank`, `home-router` → `homeRouter`, `nas-2bay` →
|
|
41
|
+
`nas2bay`, `redmi-note-9s-pro` → `redmiNote9sPro`. The exceptions:
|
|
42
|
+
|
|
43
|
+
| File | Export | Why |
|
|
44
|
+
| -------- | ----------- | --------------------------- |
|
|
45
|
+
| `switch` | `switchBox` | `switch` is a reserved word |
|
|
46
|
+
|
|
47
|
+
`StickerName` (from `@20baht/stickers` or `/load`) is the union of every name, and `STICKER_NAMES` lists them.
|
|
48
|
+
These modules under `icons/` are drawing helpers, not stickers, and have no `icon.name`: `finance-b-coins`,
|
|
49
|
+
`finance-tray`, `food`, `iso` (a deprecated alias of `@20baht/stickers/iso`), `nature-iso`, `object-drum`,
|
|
50
|
+
`paper`, `plant-kit`, `pointer`, `shared`, `sky-kit`, `street-kit`, `volume`.
|
|
51
|
+
|
|
52
|
+
### Picking a sticker at run time
|
|
53
|
+
|
|
54
|
+
When the name comes from data (a preset's `icon`, a URL), `loadSticker` imports that one sticker on demand instead
|
|
55
|
+
of the whole set behind `/all`; a bundler makes each sticker its own chunk:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { isStickerName, loadSticker } from '@20baht/stickers/load';
|
|
59
|
+
|
|
60
|
+
const icon = await loadSticker(isStickerName(preset.icon) ? preset.icon : 'cloud');
|
|
61
|
+
el.icon = icon; // or registerSticker(icon), then <baht-sticker name="…">
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`loadSticker(name: StickerName): Promise<Icon>` rejects for a name that is not a sticker; `isStickerName(name)`
|
|
65
|
+
narrows a plain string first.
|
|
66
|
+
|
|
67
|
+
## `<baht-sticker>`
|
|
68
|
+
|
|
69
|
+
Light DOM, display block; the canvas fills the element's width at 1:1, so size the element with CSS.
|
|
70
|
+
|
|
71
|
+
| Property / attribute | Type | What it does |
|
|
72
|
+
| ------------------------ | ------------------ | --------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `name` | `string` | A registered sticker. |
|
|
74
|
+
| `icon` (property) | `Icon` | An icon object; wins over `name`. |
|
|
75
|
+
| `palette` (property) | `Partial<Palette>` | Fixed colours. Unset, the element reads the `--baht-*` tokens. |
|
|
76
|
+
| `once` | `boolean` | Play once when first shown, then rest on the still frame. |
|
|
77
|
+
| `play-once` / `playOnce` | `boolean` | The same as `once`, for Angular, which cannot bind a name starting with `on`. |
|
|
78
|
+
| `offset` | `number` | Frames ahead of the page clock, to put neighbours out of phase. |
|
|
79
|
+
| `enter` | `number` | Seconds after first shown to pop in on the bounce entrance. |
|
|
80
|
+
| `replay-on-hover` | `boolean` | Replay from frame 0 when the pointer enters. |
|
|
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. |
|
|
83
|
+
|
|
84
|
+
`replay()` restarts the motion. Register stickers before the element renders.
|
|
85
|
+
|
|
86
|
+
### Colours
|
|
87
|
+
|
|
88
|
+
Icons use palette slots, never hex. Without `palette`, each slot reads a token where the element sits, and is read
|
|
89
|
+
again when `<html>`'s `data-note`, `data-theme`, `data-baht-theme`, `class` or `style` changes, or the colour scheme does.
|
|
90
|
+
Every sticker on the page shares one observer for that, and a sticker reads its tokens when it is on screen: one out of
|
|
91
|
+
view waits until it scrolls in.
|
|
92
|
+
|
|
93
|
+
| Slot | Token | Used for |
|
|
94
|
+
| ------ | --------------------------- | ---------------------- |
|
|
95
|
+
| `main` | `--baht-primary` | bodies |
|
|
96
|
+
| `deep` | `--baht-neutral` | the dark second colour |
|
|
97
|
+
| `tint` | `--baht-color-primary-tint` | pale fills |
|
|
98
|
+
| `gold` | `--baht-gold-400` | coins, stars, bells |
|
|
99
|
+
| `ok` | `--baht-success` | checks, success |
|
|
100
|
+
| `hot` | `--baht-error` | hearts, alerts |
|
|
101
|
+
|
|
102
|
+
Fixed palettes: `BAHT` (฿20) and `PALETTES.note50 | note100 | note500 | note1000`; helpers `brand(a, b)`,
|
|
103
|
+
`mono(hex)`, `hue(deg)`. `paletteFromTokens(el)` reads the tokens yourself.
|
|
104
|
+
|
|
105
|
+
## `<baht-sticker-graph>`
|
|
106
|
+
|
|
107
|
+
A diagram of how machines talk, drawn with stickers: nodes on grid cells of the floor the stickers lean on, dashed
|
|
108
|
+
links, and packets sent along them one step at a time. Set `graph` as a property:
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
el.graph = {
|
|
112
|
+
nodes: [
|
|
113
|
+
{ id: 'client', sticker: 'laptop', label: 'Client', sub: '192.168.1.10', x: 0, y: 2 },
|
|
114
|
+
{ id: 'router', sticker: 'router', label: 'Router', x: 1, y: 1 },
|
|
115
|
+
{ id: 'web', sticker: 'server', label: 'Web Server', x: 4, y: 0 },
|
|
116
|
+
],
|
|
117
|
+
links: [{ from: 'client', to: 'router', dir: 'both' }, { from: 'router', to: 'web', dir: 'both' }],
|
|
118
|
+
flow: [{ from: 'client', to: 'web', tone: 'gold', label: 'GET /' }, { from: 'web', to: 'client', tone: 'ok' }],
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`x` runs along the floor to the right, `y` towards the viewer. `dir` is `none`, `forward` or `both`; `tone` is a
|
|
123
|
+
sticker accent (`main`, `ok`, `gold`, `hot`, `deep`). Attributes: `step-ms` (900), `paused`, `hide-grid`, `label`,
|
|
124
|
+
`interactive`. Each step fires `baht-step` with `{ index, step }`; its two nodes carry `data-active`. The flow waits
|
|
125
|
+
while the diagram is scrolled out of view (no packet moves, no `baht-step` fires) and carries on when it is back.
|
|
126
|
+
`gridAt(clientX, clientY)` returns the cell under a pointer, for builders. Register the stickers it names first, or
|
|
127
|
+
give a node the icon object itself: `{ id, icon: server, x, y }` (`icon` wins over `sticker`; one of the two is
|
|
128
|
+
needed). With `interactive` the diagram is a group of buttons: each node takes focus, and a click, Enter or Space
|
|
129
|
+
fires `baht-node` with `{ id, node }` (bubbles, composed), for opening the machine it stands for. The docs site has a builder
|
|
130
|
+
that writes this JSON: https://bahtui-docs.pages.dev/guides/sticker-graph/
|
|
131
|
+
|
|
132
|
+
## Entry points
|
|
133
|
+
|
|
134
|
+
| Import | Contents |
|
|
135
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
136
|
+
| `@20baht/stickers` | Runtime (`play`, `paint`, `draw`, `clock`), palettes, shape kit, registry, types. No side effects. |
|
|
137
|
+
| `@20baht/stickers/element` | Defines `<baht-sticker>`. |
|
|
138
|
+
| `@20baht/stickers/graph` | Defines `<baht-sticker-graph>`; `layoutGraph`, `toScreen`, `toGrid` and the graph types. |
|
|
139
|
+
| `@20baht/stickers/all` | Both elements plus every sticker registered by name. |
|
|
140
|
+
| `@20baht/stickers/icons` | Every sticker and `ICONS`. |
|
|
141
|
+
| `@20baht/stickers/icons/<name>` | One sticker. |
|
|
142
|
+
| `@20baht/stickers/motions` | The keyframe presets, for drawing your own stickers. |
|
|
143
|
+
| `@20baht/stickers/load` | `loadSticker(name)`, `isStickerName`, `STICKER_NAMES`: a sticker by name through a dynamic import of its own module. |
|
|
144
|
+
| `@20baht/stickers/iso` | True-3d geometry for drawing boxy stickers (`ISO`, `block`, `solid`, `faceOf`, `quad`, `stroke`, `dot`). Not a sticker; `@20baht/stickers/icons/iso` is a deprecated alias of it. |
|
|
145
|
+
|
|
146
|
+
Without the element, `play(canvas, icon, { palette, loop, offset, enter })` returns `{ stop, replay, set, retheme }`
|
|
147
|
+
(`palette` may be a function, read when the sticker is next painted; `retheme()` has it read again), and
|
|
148
|
+
`draw(ctx, icon, frame, palette)` paints one frame. One animation-frame loop drives every sticker on the page;
|
|
149
|
+
off-screen stickers skip their paints, a still hold costs nothing, and reduced motion shows the still frame. The loop
|
|
150
|
+
(and `clock` with it) rests while no sticker on screen is moving: all of them off-screen, at rest under reduced
|
|
151
|
+
motion, or a finished play-once.
|
|
152
|
+
|
|
153
|
+
## Module and Native Federation
|
|
154
|
+
|
|
155
|
+
Do not share `@20baht/stickers`; skip it, so each remote bundles the parts it imports:
|
|
156
|
+
|
|
157
|
+
```js
|
|
158
|
+
// federation.config.mjs
|
|
159
|
+
skip: [/^@20baht/stickers/],
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Federation shares a package by its import specifiers and cannot map the `./icons/*` wildcard subpaths: the build
|
|
163
|
+
passes, then the page fails at run time with "Unable to resolve specifier '@20baht/stickers/icons/padlock'". A
|
|
164
|
+
copy per remote is harmless: icons are plain data, the runtime is canvas code with no shared state a page relies
|
|
165
|
+
on, and `loadSticker` works inside each copy. Two things to know if remotes use the elements from their own copy:
|
|
166
|
+
the second `<baht-sticker>` definition logs a warning and keeps the first (same element, so nothing breaks), and
|
|
167
|
+
every copy shares one name registry (on `globalThis`, under `Symbol.for('@20baht/stickers.registry')`), so a
|
|
168
|
+
sticker one copy registers is found by `name` in another. Setting the `icon` property
|
|
169
|
+
(`el.icon = await loadSticker(name)`, or a graph node's `icon`) still needs no registry at all.
|
|
170
|
+
|
|
171
|
+
## Licence
|
|
172
|
+
|
|
173
|
+
MIT. The runtime and motion presets are derived from
|
|
174
|
+
[fun-isometric](https://github.com/kelvinkn17/skills) by Kelvin Adithya, also MIT; both notices are in `LICENSE`.
|
package/dist/all.d.ts
ADDED
package/dist/all.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Everything in one import: defines <baht-sticker> and <baht-sticker-graph>, and registers every worked icon by name.
|
|
2
|
+
import './element.js';
|
|
3
|
+
import './graph.js';
|
|
4
|
+
import { ICONS } from './icons/index.js';
|
|
5
|
+
import { registerSticker } from './sticker.js';
|
|
6
|
+
registerSticker(...ICONS);
|
|
7
|
+
export { ICONS };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { PropertyValues } from 'lit';
|
|
3
|
+
import type { Icon, Palette } from './sticker.js';
|
|
4
|
+
/**
|
|
5
|
+
* An animated slab sticker. Light DOM, like every `<baht-*>` element.
|
|
6
|
+
*
|
|
7
|
+
* Give it a registered `name` (`<baht-sticker name="piggy-bank">` after `import '@20baht/stickers/all'` or
|
|
8
|
+
* `registerSticker(piggyBank)`), or an `icon` object as a property, which wins over `name`.
|
|
9
|
+
*
|
|
10
|
+
* Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber) where it sits and
|
|
11
|
+
* re-reads them when the root's `data-note`, `data-theme`, `data-baht-theme`, `class` or `style`, or the colour scheme, changes,
|
|
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
|
+
* until it scrolls in, and one whose colours come back the same does not repaint.
|
|
14
|
+
*
|
|
15
|
+
* @attr name - Name of a registered sticker.
|
|
16
|
+
* @attr once - Play once when first shown (or on replay), then rest on the icon's still frame.
|
|
17
|
+
* @attr play-once - The same as `once`, under a name Angular can bind (it reads any name starting with "on" as an
|
|
18
|
+
* event handler). Either one set plays once.
|
|
19
|
+
* @attr offset - Frames ahead of the page clock, to put neighbours out of phase.
|
|
20
|
+
* @attr enter - Seconds after first shown to pop in on the bounce entrance; unset skips the entrance.
|
|
21
|
+
* @attr replay-on-hover - Replay from frame 0 when the pointer enters.
|
|
22
|
+
* @attr label - Accessible name; the sticker's name by default.
|
|
23
|
+
* @attr line - Outline weight as a multiple of the sticker's own: `0.6` thinner, `1.5` bolder; 1 by default.
|
|
24
|
+
*/
|
|
25
|
+
export declare class BahtSticker extends LitElement {
|
|
26
|
+
static properties: {
|
|
27
|
+
name: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
};
|
|
30
|
+
icon: {
|
|
31
|
+
attribute: boolean;
|
|
32
|
+
};
|
|
33
|
+
palette: {
|
|
34
|
+
attribute: boolean;
|
|
35
|
+
};
|
|
36
|
+
once: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
};
|
|
39
|
+
playOnce: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
attribute: string;
|
|
42
|
+
};
|
|
43
|
+
offset: {
|
|
44
|
+
type: NumberConstructor;
|
|
45
|
+
};
|
|
46
|
+
enter: {
|
|
47
|
+
type: NumberConstructor;
|
|
48
|
+
};
|
|
49
|
+
replayOnHover: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
attribute: string;
|
|
52
|
+
};
|
|
53
|
+
label: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
};
|
|
56
|
+
line: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** Name of a registered sticker; ignored while `icon` is set. */
|
|
61
|
+
name: string | undefined;
|
|
62
|
+
/** The icon to play, as an object. Wins over `name`. */
|
|
63
|
+
icon: Icon | undefined;
|
|
64
|
+
/** Slots to swap; unset follows the --baht-* tokens. */
|
|
65
|
+
palette: Partial<Palette> | undefined;
|
|
66
|
+
/** Play once when first shown (or on replay), then rest on the icon's still frame. */
|
|
67
|
+
once: boolean;
|
|
68
|
+
/** The same as `once`, for Angular, which cannot bind a name starting with "on"; either one set plays once. */
|
|
69
|
+
playOnce: boolean;
|
|
70
|
+
offset: number | undefined;
|
|
71
|
+
enter: number | undefined;
|
|
72
|
+
replayOnHover: boolean;
|
|
73
|
+
label: string | undefined;
|
|
74
|
+
/** Outline weight as a multiple of the sticker's own; unset is 1. */
|
|
75
|
+
line: number | undefined;
|
|
76
|
+
private canvas;
|
|
77
|
+
private player;
|
|
78
|
+
private playing;
|
|
79
|
+
private tokens;
|
|
80
|
+
constructor();
|
|
81
|
+
/** The icon this element plays: `icon`, else the sticker registered as `name`. */
|
|
82
|
+
get resolvedIcon(): Icon | undefined;
|
|
83
|
+
/** Replays the motion from frame 0 on the next tick. */
|
|
84
|
+
replay(): void;
|
|
85
|
+
protected createRenderRoot(): HTMLElement;
|
|
86
|
+
connectedCallback(): void;
|
|
87
|
+
disconnectedCallback(): void;
|
|
88
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
89
|
+
private readonly onPointerEnter;
|
|
90
|
+
/** The theme may have changed: the tokens are read again when the sticker is next painted, not here. */
|
|
91
|
+
private readonly onTheme;
|
|
92
|
+
/** The tokens where the element sits, kept until the theme changes or it leaves the page; the player asks when it paints. */
|
|
93
|
+
private readonly readTokens;
|
|
94
|
+
private options;
|
|
95
|
+
private stop;
|
|
96
|
+
/** A new icon starts a new player; options reach a running one through set(), so the entrance never replays. */
|
|
97
|
+
private start;
|
|
98
|
+
}
|
|
99
|
+
declare global {
|
|
100
|
+
interface HTMLElementTagNameMap {
|
|
101
|
+
'baht-sticker': BahtSticker;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/dist/element.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// <baht-sticker>: plays a sticker on canvas, coloured from the page's --baht-* tokens unless given a palette.
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { getSticker, paletteFromTokens, play } from './sticker.js';
|
|
4
|
+
const TAG = 'baht-sticker';
|
|
5
|
+
const STYLE_ID = 'baht-sticker-style';
|
|
6
|
+
/** One sheet for every sticker: block by default, the canvas fills its width at 1:1. Size the element with css. */
|
|
7
|
+
function injectStyle() {
|
|
8
|
+
if (document.getElementById(STYLE_ID))
|
|
9
|
+
return;
|
|
10
|
+
const style = document.createElement('style');
|
|
11
|
+
style.id = STYLE_ID;
|
|
12
|
+
style.textContent = `:where(${TAG}){display:block}:where(${TAG})>canvas{display:block;width:100%;aspect-ratio:1}`;
|
|
13
|
+
document.head.append(style);
|
|
14
|
+
}
|
|
15
|
+
const themed = new Set();
|
|
16
|
+
let themeWatch;
|
|
17
|
+
let schemeWatch;
|
|
18
|
+
function onTheme() {
|
|
19
|
+
for (const stale of themed)
|
|
20
|
+
stale();
|
|
21
|
+
}
|
|
22
|
+
/** One observer on the root and one colour scheme listener for every connected sticker, made for the first. */
|
|
23
|
+
function watchTheme(stale) {
|
|
24
|
+
themed.add(stale);
|
|
25
|
+
if (themeWatch)
|
|
26
|
+
return;
|
|
27
|
+
themeWatch = new MutationObserver(onTheme);
|
|
28
|
+
themeWatch.observe(document.documentElement, {
|
|
29
|
+
attributes: true,
|
|
30
|
+
attributeFilter: ['data-note', 'data-theme', 'data-baht-theme', 'class', 'style'],
|
|
31
|
+
});
|
|
32
|
+
schemeWatch = matchMedia('(prefers-color-scheme: dark)');
|
|
33
|
+
schemeWatch.addEventListener('change', onTheme);
|
|
34
|
+
}
|
|
35
|
+
/** Taken down again when the last sticker leaves the page. */
|
|
36
|
+
function unwatchTheme(stale) {
|
|
37
|
+
themed.delete(stale);
|
|
38
|
+
if (themed.size)
|
|
39
|
+
return;
|
|
40
|
+
themeWatch?.disconnect();
|
|
41
|
+
themeWatch = undefined;
|
|
42
|
+
schemeWatch?.removeEventListener('change', onTheme);
|
|
43
|
+
schemeWatch = undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An animated slab sticker. Light DOM, like every `<baht-*>` element.
|
|
47
|
+
*
|
|
48
|
+
* Give it a registered `name` (`<baht-sticker name="piggy-bank">` after `import '@20baht/stickers/all'` or
|
|
49
|
+
* `registerSticker(piggyBank)`), or an `icon` object as a property, which wins over `name`.
|
|
50
|
+
*
|
|
51
|
+
* Without `palette` it reads the --baht-* tokens (primary, neutral, success, error, amber) where it sits and
|
|
52
|
+
* re-reads them when the root's `data-note`, `data-theme`, `data-baht-theme`, `class` or `style`, or the colour scheme, changes,
|
|
53
|
+
* so it follows the banknote theme and dark mode. It reads them when it is on screen: a sticker out of view waits
|
|
54
|
+
* until it scrolls in, and one whose colours come back the same does not repaint.
|
|
55
|
+
*
|
|
56
|
+
* @attr name - Name of a registered sticker.
|
|
57
|
+
* @attr once - Play once when first shown (or on replay), then rest on the icon's still frame.
|
|
58
|
+
* @attr play-once - The same as `once`, under a name Angular can bind (it reads any name starting with "on" as an
|
|
59
|
+
* event handler). Either one set plays once.
|
|
60
|
+
* @attr offset - Frames ahead of the page clock, to put neighbours out of phase.
|
|
61
|
+
* @attr enter - Seconds after first shown to pop in on the bounce entrance; unset skips the entrance.
|
|
62
|
+
* @attr replay-on-hover - Replay from frame 0 when the pointer enters.
|
|
63
|
+
* @attr label - Accessible name; the sticker's name by default.
|
|
64
|
+
* @attr line - Outline weight as a multiple of the sticker's own: `0.6` thinner, `1.5` bolder; 1 by default.
|
|
65
|
+
*/
|
|
66
|
+
export class BahtSticker extends LitElement {
|
|
67
|
+
static { this.properties = {
|
|
68
|
+
name: { type: String },
|
|
69
|
+
icon: { attribute: false },
|
|
70
|
+
palette: { attribute: false },
|
|
71
|
+
once: { type: Boolean },
|
|
72
|
+
playOnce: { type: Boolean, attribute: 'play-once' },
|
|
73
|
+
offset: { type: Number },
|
|
74
|
+
enter: { type: Number },
|
|
75
|
+
replayOnHover: { type: Boolean, attribute: 'replay-on-hover' },
|
|
76
|
+
label: { type: String },
|
|
77
|
+
line: { type: Number },
|
|
78
|
+
}; }
|
|
79
|
+
constructor() {
|
|
80
|
+
super();
|
|
81
|
+
this.onPointerEnter = () => {
|
|
82
|
+
if (this.replayOnHover)
|
|
83
|
+
this.replay();
|
|
84
|
+
};
|
|
85
|
+
/** The theme may have changed: the tokens are read again when the sticker is next painted, not here. */
|
|
86
|
+
this.onTheme = () => {
|
|
87
|
+
if (this.palette)
|
|
88
|
+
return;
|
|
89
|
+
this.tokens = undefined;
|
|
90
|
+
this.player?.retheme();
|
|
91
|
+
};
|
|
92
|
+
/** The tokens where the element sits, kept until the theme changes or it leaves the page; the player asks when it paints. */
|
|
93
|
+
this.readTokens = () => {
|
|
94
|
+
if (this.isConnected)
|
|
95
|
+
this.tokens ??= paletteFromTokens(this);
|
|
96
|
+
return this.tokens;
|
|
97
|
+
};
|
|
98
|
+
this.name = undefined;
|
|
99
|
+
this.icon = undefined;
|
|
100
|
+
this.palette = undefined;
|
|
101
|
+
this.once = false;
|
|
102
|
+
this.playOnce = false;
|
|
103
|
+
this.offset = undefined;
|
|
104
|
+
this.enter = undefined;
|
|
105
|
+
this.replayOnHover = false;
|
|
106
|
+
this.label = undefined;
|
|
107
|
+
this.line = undefined;
|
|
108
|
+
}
|
|
109
|
+
/** The icon this element plays: `icon`, else the sticker registered as `name`. */
|
|
110
|
+
get resolvedIcon() {
|
|
111
|
+
return this.icon ?? (this.name ? getSticker(this.name) : undefined);
|
|
112
|
+
}
|
|
113
|
+
/** Replays the motion from frame 0 on the next tick. */
|
|
114
|
+
replay() {
|
|
115
|
+
this.player?.replay();
|
|
116
|
+
}
|
|
117
|
+
createRenderRoot() {
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
connectedCallback() {
|
|
121
|
+
super.connectedCallback();
|
|
122
|
+
injectStyle();
|
|
123
|
+
this.canvas ??= document.createElement('canvas');
|
|
124
|
+
if (!this.canvas.isConnected)
|
|
125
|
+
this.append(this.canvas);
|
|
126
|
+
this.canvas.setAttribute('role', 'img');
|
|
127
|
+
this.addEventListener('pointerenter', this.onPointerEnter);
|
|
128
|
+
watchTheme(this.onTheme);
|
|
129
|
+
// the first connect starts from updated(); a reconnect has no property change to start it
|
|
130
|
+
if (this.hasUpdated)
|
|
131
|
+
this.start();
|
|
132
|
+
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
super.disconnectedCallback();
|
|
135
|
+
this.removeEventListener('pointerenter', this.onPointerEnter);
|
|
136
|
+
unwatchTheme(this.onTheme);
|
|
137
|
+
this.stop();
|
|
138
|
+
// wherever it is connected next may be themed differently
|
|
139
|
+
this.tokens = undefined;
|
|
140
|
+
}
|
|
141
|
+
updated(changed) {
|
|
142
|
+
const icon = this.resolvedIcon;
|
|
143
|
+
this.canvas?.setAttribute('aria-label', this.label ?? icon?.name ?? this.name ?? 'sticker');
|
|
144
|
+
if (icon !== this.playing || !this.player)
|
|
145
|
+
this.start();
|
|
146
|
+
else if (changed.size)
|
|
147
|
+
this.player.set(this.options());
|
|
148
|
+
}
|
|
149
|
+
options() {
|
|
150
|
+
return {
|
|
151
|
+
palette: this.palette ?? this.readTokens,
|
|
152
|
+
loop: !(this.once || this.playOnce),
|
|
153
|
+
offset: this.offset,
|
|
154
|
+
enter: this.enter,
|
|
155
|
+
line: this.line,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
stop() {
|
|
159
|
+
this.player?.stop();
|
|
160
|
+
this.player = undefined;
|
|
161
|
+
this.playing = undefined;
|
|
162
|
+
}
|
|
163
|
+
/** A new icon starts a new player; options reach a running one through set(), so the entrance never replays. */
|
|
164
|
+
start() {
|
|
165
|
+
this.stop();
|
|
166
|
+
const icon = this.resolvedIcon;
|
|
167
|
+
if (!icon || !this.canvas || !this.isConnected)
|
|
168
|
+
return;
|
|
169
|
+
this.playing = icon;
|
|
170
|
+
this.player = play(this.canvas, icon, this.options());
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Like @20baht/ui's define.ts: a second copy of the package keeps the first definition and warns.
|
|
174
|
+
if (typeof customElements !== 'undefined') {
|
|
175
|
+
const existing = customElements.get(TAG);
|
|
176
|
+
if (!existing)
|
|
177
|
+
customElements.define(TAG, BahtSticker);
|
|
178
|
+
else if (existing !== BahtSticker) {
|
|
179
|
+
console.warn(`[bahtui] <${TAG}> is already defined; skipping the copy from @20baht/stickers`);
|
|
180
|
+
}
|
|
181
|
+
}
|