@johnmorrisdotca/fuda-cards 0.10.1 → 0.11.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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +14 -0
  3. package/README.md +89 -7
  4. package/dist/binder.d.ts +4 -6
  5. package/dist/binder.js +32 -23
  6. package/dist/card-markup.d.ts +2 -0
  7. package/dist/card-markup.js +59 -0
  8. package/dist/card-options.d.ts +131 -0
  9. package/dist/card-options.js +48 -0
  10. package/dist/card-styles.d.ts +2 -0
  11. package/dist/card-styles.js +314 -0
  12. package/dist/choice.d.ts +1 -1
  13. package/dist/choice.js +27 -23
  14. package/dist/collection-address.d.ts +8 -0
  15. package/dist/collection-address.js +52 -0
  16. package/dist/collection-binder-view.d.ts +9 -0
  17. package/dist/collection-binder-view.js +123 -0
  18. package/dist/collection-controls.d.ts +2 -0
  19. package/dist/collection-controls.js +143 -0
  20. package/dist/collection-deck.d.ts +11 -0
  21. package/dist/collection-deck.js +165 -0
  22. package/dist/collection-dialog.d.ts +2 -0
  23. package/dist/collection-dialog.js +28 -0
  24. package/dist/collection-element.d.ts +30 -65
  25. package/dist/collection-element.js +283 -484
  26. package/dist/collection-host.d.ts +5 -0
  27. package/dist/collection-host.js +1 -0
  28. package/dist/collection-icons.d.ts +3 -0
  29. package/dist/collection-icons.js +19 -0
  30. package/dist/collection-motion.d.ts +11 -0
  31. package/dist/collection-motion.js +72 -0
  32. package/dist/collection-styles.d.ts +4 -0
  33. package/dist/collection-styles.js +336 -0
  34. package/dist/collection-views.d.ts +8 -0
  35. package/dist/collection-views.js +8 -0
  36. package/dist/collection.d.ts +140 -11
  37. package/dist/collection.js +139 -33
  38. package/dist/element-define.d.ts +2 -0
  39. package/dist/element-define.js +3 -0
  40. package/dist/element.d.ts +20 -1
  41. package/dist/element.js +289 -98
  42. package/dist/index.d.ts +9 -52
  43. package/dist/index.js +5 -5
  44. package/dist/live-3d.d.ts +87 -4
  45. package/dist/live-3d.js +120 -52
  46. package/dist/materials.d.ts +117 -6
  47. package/dist/materials.js +191 -28
  48. package/dist/motion.d.ts +2 -0
  49. package/dist/motion.js +4 -0
  50. package/dist/pile-card.js +138 -91
  51. package/dist/pile.d.ts +61 -8
  52. package/dist/pile.js +89 -29
  53. package/dist/stack.d.ts +42 -6
  54. package/dist/stack.js +28 -3
  55. package/dist/version.d.ts +11 -0
  56. package/dist/version.js +11 -0
  57. package/dist/wear.d.ts +147 -9
  58. package/dist/wear.js +273 -89
  59. package/dist/zoom.d.ts +1 -1
  60. package/dist/zoom.js +73 -42
  61. package/docs/API.md +121 -131
  62. package/docs/guides/bundlers.md +60 -0
  63. package/docs/guides/card-element.md +2 -2
  64. package/docs/guides/embed-in-an-iframe.md +39 -0
  65. package/docs/guides/frameworks.md +93 -66
  66. package/docs/guides/getting-started.md +3 -1
  67. package/docs/guides/html-and-cdn.md +69 -0
  68. package/docs/guides/ja/bundlers.md +60 -0
  69. package/docs/guides/ja/card-element.md +2 -2
  70. package/docs/guides/ja/embed-in-an-iframe.md +39 -0
  71. package/docs/guides/ja/frameworks.md +93 -66
  72. package/docs/guides/ja/getting-started.md +3 -1
  73. package/docs/guides/ja/html-and-cdn.md +69 -0
  74. package/docs/guides/ja/materials-and-stacks.md +3 -3
  75. package/docs/guides/ja/troubleshooting.md +2 -2
  76. package/docs/guides/ja/typescript-and-node.md +45 -0
  77. package/docs/guides/ja/upgrading.md +1 -1
  78. package/docs/guides/materials-and-stacks.md +3 -3
  79. package/docs/guides/troubleshooting.md +2 -2
  80. package/docs/guides/typescript-and-node.md +45 -0
  81. package/docs/guides/upgrading.md +1 -1
  82. package/package.json +57 -10
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 John Morris
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.
package/NOTICE.md ADDED
@@ -0,0 +1,14 @@
1
+ # Third-party material
2
+
3
+ The code of Fuda Cards is MIT licensed (see [LICENSE](LICENSE)). Nothing below is part of the published npm package except where it says so; it is the pictures and data the repository and its demo pages use, each with its source and licence as read on 2026-11-03.
4
+
5
+ | What | Where | Source and licence |
6
+ |---|---|---|
7
+ | Starship Block 3 picture (`assets/starship-v3-preview.jpg`, `assets/uchusen-main-painted.jpg`) | The repository and the demo pages; not in the npm package | A screenshot of John Morris's uchusen-rockets, which draws a modified model by Clarence365: <https://sketchfab.com/3d-models/spacex-starship-block-3-6f6c6f88a3eb4b4d822fdca66733fbb2>, licensed **CC BY 4.0**. The model was reduced, rescaled, separated into parts, and had logos and serial numbers removed. The credit is also in [assets/README.md](assets/README.md), which is in the npm package. |
8
+ | Rockets of the live 3D demo | `demo/live-3d.html`, loaded from `@johnmorrisdotca/uchusen-rockets` (a development dependency) | MIT, John Morris. Their models carry their own credits in that package. |
9
+ | Vintage baseball cards | `demo/vintage-baseball.js` keeps only addresses and credits; the pictures load from The Metropolitan Museum of Art when the demo opens | The Met's Open Access collection (the Jefferson R. Burdick Collection), each object marked public domain by the Met (checked 2026-11-02). |
10
+ | Vintage hockey cards | `demo/vintage-hockey.js` keeps only addresses and credits; the pictures load from Wikimedia Commons | 1910-11 Imperial Tobacco Canada cards, each file marked public domain on its Commons page (checked 2026-11-02). |
11
+ | Pokémon Base Set card pictures and data | `demo/tcgdex.html` loads them from TCGdex when the demo opens; none is stored here | Supplied by [TCGdex](https://tcgdex.dev/). The card artwork and the Pokémon names are the property of their owners (Nintendo, Creatures, GAME FREAK, The Pokémon Company) and are shown in the demo only as an example of a collection; they are not licensed by this project and are not in the package. |
12
+ | Card thicknesses and deck sizes | `src/materials.ts`, `docs/materials.md` | Facts read from the makers' and standards' own pages, each cited with its address. No text or table was copied. |
13
+
14
+ The card designs, the wear marks, the binder and every other picture drawn by the package are drawn in code from public facts and are MIT licensed with the rest.
package/README.md CHANGED
@@ -110,7 +110,7 @@ card.setAttribute('thickness', String(options.thickness));
110
110
  document.body.append(card);
111
111
  ```
112
112
 
113
- The main entry, `@johnmorrisdotca/fuda-cards`, exports only the options types and the tables (variants, finishes, materials, stack presets, wear presets and their maths) and registers nothing, so it is safe on a server. Frameworks may need a custom-element setting (Angular's `CUSTOM_ELEMENTS_SCHEMA`, Vue's `isCustomElement`): see [Frameworks and bundlers](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md).
113
+ The main entry, `@johnmorrisdotca/fuda-cards`, exports only the options types and the tables (variants, finishes, materials, stack presets, wear presets and their maths) and registers nothing, so it is safe on a server. Frameworks may need a custom-element setting (Angular's `CUSTOM_ELEMENTS_SCHEMA`, Vue's `isCustomElement`): see [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md).
114
114
 
115
115
  ## Use it anywhere
116
116
 
@@ -124,7 +124,7 @@ With no bundler, serve the package's `dist` folder and point a module script at
124
124
  <fuda-card title="Anywhere"></fuda-card>
125
125
  ```
126
126
 
127
- `<fuda-collection>` imports kazoku-ui's zoom bar, so it also needs `@johnmorrisdotca/kazoku-ui/view-controls/define` in the import map; the [framework guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) has the whole map.
127
+ `<fuda-collection>` imports kazoku-ui's zoom bar, so it also needs `@johnmorrisdotca/kazoku-ui/view-controls/define` in the import map; the [HTML and CDN guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/html-and-cdn.md) has the whole map.
128
128
 
129
129
  ## Examples
130
130
 
@@ -174,7 +174,7 @@ It keeps `<fuda-card>` (300 px wide, 2.5:3.5, or whatever width your own rule gi
174
174
 
175
175
  A card turned past 90° shows its back (the navy FUDA face), never the mirrored front, and the front's Animate button cannot be seen or clicked from behind. The back is the card's own face and is shown for `flipped` too.
176
176
 
177
- The card has thickness, drawn to scale at the 63 mm wide card size: set `thickness` in millimetres (default `0.3`, about 12 pt stock; `0` for a flat card; or pick a `material`, below). The edge is drawn from thin planes between the two faces, so it shows edge-on and at any angle, and it scales with the element's width (a 300px card is about 1.4px thick at the default). It is gold foil for the classic gold frame and card-stock cream for the sport and cosmic variants; override it with the `--fuda-edge` CSS custom property (any CSS background). The drop shadow is on the element itself, so a `filter` must not be added to anything between the card and its faces.
177
+ The card has thickness, drawn to scale at the 63 mm wide card size: set `thickness` in millimetres (default `0.325`, a playing card's black-core stock, 13 pt, `DEFAULT_CARD_THICKNESS_MM`; `0` for a flat card; or pick a `material`, below). The edge is drawn from thin planes between the two faces, so it shows edge-on and at any angle, and it scales with the element's width (a 300px card is about 1.4px thick at the default). It is gold foil for the classic gold frame and card-stock cream for the sport and cosmic variants; override it with the `--fuda-edge` CSS custom property (any CSS background). The drop shadow is on the element itself, so a `filter` must not be added to anything between the card and its faces.
178
178
 
179
179
  ```html
180
180
  <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
@@ -187,7 +187,7 @@ The card has thickness, drawn to scale at the 63 mm wide card size: set `thickne
187
187
 
188
188
  `material="<id>"` gives a card the thickness and edge colour of a material, each thickness read from a maker or a standard and cited: card stock at 11, 13 and 16 pt, a plastic bank-size card (0.76 mm), thick trading cards from 35 to 180 pt, a 175 pt booklet card, anodised aluminium (0.8 mm) and stainless steel (0.5 mm). `thickness` still overrides it. [docs/materials.md](docs/materials.md) lists every material, its thickness, its source and what the source says, and what was left out because it could not be sourced (a patch or relic card, for one).
189
189
 
190
- `stack="52"` draws that many cards as a stack whose height is the count times a card's thickness (52 cards of the black-core playing-card stock are 16.9 mm; 60 thick 130 pt cards are 198 mm). The count is free, 1 to 1000; the Card Studio has presets with a source (52 playing cards, 52 and two jokers, a 60-card Pokémon deck, a booster pack of 10). Turn the card to see the stack's edge, with a line for each card in the material's colour.
190
+ `stack="52"` draws that many cards as a stack whose height is the count times a card's thickness (52 cards of the black-core playing-card stock are 16.9 mm). The count is free, 1 to 1000; the Card Studio has presets with a source (52 playing cards, 52 and two jokers, a 60-card Pokémon deck, a booster pack of 10). Turn the card to see the stack's edge, with a line for each card in the material's colour.
191
191
 
192
192
  ```html
193
193
  <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
@@ -372,7 +372,7 @@ export function Cards({ cards }) {
372
372
  }
373
373
  ```
374
374
 
375
- Vue 3 (`:cards.prop`), Svelte, Angular (`CUSTOM_ELEMENTS_SCHEMA`) and server rendering are in [Frameworks and bundlers](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md). The integrations were bundled and exercised in Chromium with React 19, Angular 19, Vue 3 and Svelte 4; there are no framework wrappers yet.
375
+ Vue 3 (`:cards.prop`), Svelte and Angular (`CUSTOM_ELEMENTS_SCHEMA`) are in [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md), and server rendering in [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md). The integrations were bundled and exercised in Chromium with React 19, Angular 19, Vue 3 and Svelte 4; there are no framework wrappers yet.
376
376
 
377
377
  ## Demos
378
378
 
@@ -455,7 +455,11 @@ Open work, in order of what a user would notice: framework wrappers; JSON, API a
455
455
  | [Collections](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/collections.md) | The element, the input, kinds, ten displays |
456
456
  | [Binders and piles](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/binder-and-piles.md) | Binder pages, fan, take a card off, animate |
457
457
  | [Live 3D in a card](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/live-3d.md) | One card live on one context |
458
- | [Frameworks and bundlers](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) | Import maps, React, Vue, Svelte, Angular, servers |
458
+ | [HTML and CDN](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/html-and-cdn.md) | A script tag from jsDelivr or unpkg, an import map |
459
+ | [Bundlers](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/bundlers.md) | Vite and webpack |
460
+ | [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) | React, Vue, Svelte, Angular |
461
+ | [Embed in an iframe](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/embed-in-an-iframe.md) | The embed page and its address |
462
+ | [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md) | The types, and the tables on a server |
459
463
  | [Accessibility and theming](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/accessibility-and-theming.md) | What is built in, every custom property |
460
464
  | [Architecture](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md) | The modules and why |
461
465
  | [Troubleshooting and FAQ](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/troubleshooting.md) | A blank card, a flash, a missing bar |
@@ -484,6 +488,84 @@ Read [AGENTS.md](AGENTS.md) for how work is done here: a board ticket for each c
484
488
 
485
489
  Every release, dated, is in [CHANGELOG.md](CHANGELOG.md).
486
490
 
491
+ ## The family
492
+
493
+ <!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
494
+ Fuda Cards is one of forty-one packages, each made for the same site, each at
495
+ [github.com/johnmorrisdotca](https://github.com/johnmorrisdotca) or [github.com/spxis](https://github.com/spxis). The code of every one is MIT.
496
+
497
+ **Games — board**
498
+
499
+ - [Domino](https://github.com/johnmorrisdotca/domino) (ドミノ): dominoes and Mexican Train. [Demo](https://johnmorrisdotca.github.io/domino/).
500
+ - [Gunjin](https://github.com/johnmorrisdotca/gunjin) (軍人): five hidden-rank strategy games with pass-the-device play. [Demo](https://johnmorrisdotca.github.io/gunjin/).
501
+ - [Narabe](https://github.com/johnmorrisdotca/narabe) (並べ): one rules engine for abstract board games, from gomoku and Reversi to Go and checkers. [Demo](https://johnmorrisdotca.github.io/narabe/).
502
+ - [Sugoroku](https://github.com/johnmorrisdotca/sugoroku) (双六): backgammon and its variants, with the doubling cube and match play. [Demo](https://johnmorrisdotca.github.io/sugoroku/).
503
+ - [Tenka](https://github.com/johnmorrisdotca/tenka) (天下): world conquest for two to six, on a map of the real world. [Demo](https://johnmorrisdotca.github.io/tenka/).
504
+
505
+ **Games — cards & tiles**
506
+
507
+ - [Fuda Cards](https://github.com/johnmorrisdotca/fuda-cards) (札): collectible card frames with a true thickness, foil, stacks, wear and a binder, as two web components. [Demo](https://johnmorrisdotca.github.io/fuda-cards/).
508
+ - [Hitotsu](https://github.com/johnmorrisdotca/hitotsu) (一つ): a colour-card shedding game for two to eight, with the house rules people play. [Demo](https://johnmorrisdotca.github.io/hitotsu/).
509
+ - [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
510
+ - [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
511
+ - [Toranpu](https://github.com/johnmorrisdotca/toranpu) (トランプ): a deck of playing cards, card games with computer players, and solitaires. [Demo](https://johnmorrisdotca.github.io/toranpu/).
512
+
513
+ **Games — puzzles**
514
+
515
+ - [Houseki](https://github.com/johnmorrisdotca/houseki) (宝石): gem and stone matching puzzles: falling triplets, stone collapse, colour chains and gem swap. [Demo](https://johnmorrisdotca.github.io/houseki/).
516
+ - [Jirai](https://github.com/johnmorrisdotca/jirai) (地雷): minesweeper on shaped grids with verified no-guess boards. [Demo](https://johnmorrisdotca.github.io/jirai/).
517
+ - [Karakuri](https://github.com/johnmorrisdotca/karakuri) (からくり): eight hyper-casual puzzle games, some of them physics: draw a shield, pull pins, cut ropes, slide blocks, pour tubes. [Demo](https://johnmorrisdotca.github.io/karakuri/).
518
+ - [Kazu](https://github.com/johnmorrisdotca/kazu) (数): grid number puzzles: Sudoku and its variants, Futoshiki and Skyscrapers. [Demo](https://johnmorrisdotca.github.io/kazu/).
519
+ - [Kyuubu](https://github.com/johnmorrisdotca/kyuubu) (キューブ): a turning cube for the browser, 2×2 to 7×7, with record solves to replay. [Demo](https://johnmorrisdotca.github.io/kyuubu/).
520
+ - [Meikyuu](https://github.com/johnmorrisdotca/meikyuu) (迷宮): mazes on squares, hexagons, triangles and circles, made from a seed and drawn through with a finger or the mouse. [Demo](https://johnmorrisdotca.github.io/meikyuu/).
521
+ - [Suido](https://github.com/johnmorrisdotca/suido) (水道): a pipe puzzle: turn the pieces until the water reaches every drain. [Demo](https://johnmorrisdotca.github.io/suido/).
522
+ - [Tobiishi](https://github.com/johnmorrisdotca/tobiishi) (飛び石): peg solitaire with nine boards and seeded solvable challenges. [Demo](https://johnmorrisdotca.github.io/tobiishi/).
523
+ - [Tsunagi](https://github.com/johnmorrisdotca/tsunagi) (繋ぎ): a line-joining logic puzzle whose every level has exactly one answer. [Demo](https://johnmorrisdotca.github.io/tsunagi/).
524
+
525
+ **Games — dice & random**
526
+
527
+ - [Korokoro](https://github.com/johnmorrisdotca/korokoro) (コロコロ): dice, with notation, exact odds, real sounds and the dice of many games. [Demo](https://johnmorrisdotca.github.io/korokoro/).
528
+ - [Tane](https://github.com/johnmorrisdotca/tane) (種): seeded random numbers and daily seeds, the same in every browser and on every server. [Demo](https://johnmorrisdotca.github.io/tane/).
529
+
530
+ **Language**
531
+
532
+ - [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
533
+ - [Hikidashi](https://github.com/johnmorrisdotca/hikidashi) (引き出し): a drawer of small Japanese text tools: era dates, kanji numerals, readings and sentence difficulty. [Demo](https://johnmorrisdotca.github.io/hikidashi/).
534
+ - [Jisho](https://github.com/johnmorrisdotca/jisho) (辞書): words of Japanese looked up by reading or written form, and the grades, JLPT levels, readings and look-alike pairs of 2,999 kanji. [Demo](https://johnmorrisdotca.github.io/jisho/).
535
+ - [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
536
+
537
+ **Space Program X**
538
+
539
+ - [Chikyu Earth](https://github.com/johnmorrisdotca/chikyu-earth) (地球): a line-drawn globe that turns at the Earth's own rate, with an optional realistic Earth from space and markers for any place. [Demo](https://johnmorrisdotca.github.io/chikyu-earth/).
540
+ - [Hoshi Stars](https://github.com/johnmorrisdotca/hoshi-stars) (星): the stars you can see without a telescope, with names, colours and distances, the constellations with their lines and boundaries, and the Messier objects, drawn on any of seven sky maps. [Demo](https://johnmorrisdotca.github.io/hoshi-stars/).
541
+ - [Uchusen Rockets](https://github.com/johnmorrisdotca/uchusen-rockets) (宇宙船): rockets drawn from sourced sizes, as line drawings and 3D views you can take apart and turn, with a check that a rocket really goes together. [Demo](https://johnmorrisdotca.github.io/uchusen-rockets/).
542
+ - [Wakusei Planets](https://github.com/johnmorrisdotca/wakusei-planets) (惑星): the Sun, the planets and their moons, as line drawings, shaded drawings and painted surface maps, with their real sizes, tilt and rotation. [Demo](https://johnmorrisdotca.github.io/wakusei-planets/).
543
+
544
+ **Geography & data**
545
+
546
+ - [address-plus](https://github.com/johnmorrisdotca/address-plus) (アドレスプラス): parse and format addresses in the United States, Canada, Japan, Australia, France, Germany and the United Kingdom. [Demo](https://johnmorrisdotca.github.io/address-plus/).
547
+ - [Chizu](https://github.com/johnmorrisdotca/chizu) (地図): maps of the world and of countries' regions, in English and Japanese, with a quiz and callouts. [Demo](https://johnmorrisdotca.github.io/chizu/).
548
+ - [Hako Devices](https://github.com/johnmorrisdotca/hako-devices) (箱): line drawings and 3D views of computers, phones, consoles and NAS boxes, from published sizes. [Demo](https://johnmorrisdotca.github.io/hako-devices/).
549
+ - [Hata](https://github.com/johnmorrisdotca/hata) (旗): country and regional flags as SVG, at their true proportions and keyed by ISO code. [Demo](https://johnmorrisdotca.github.io/hata/).
550
+ - [Koyomi Calendars](https://github.com/johnmorrisdotca/koyomi-calendars) (暦): calendar-page icons and whole months as SVG, in light and dark, with page-turning from one day to the next. [Demo](https://johnmorrisdotca.github.io/koyomi-calendars/).
551
+ - [Kuni](https://github.com/johnmorrisdotca/kuni) (国): countries and their regions, with ISO codes and names in English and Japanese. [Demo](https://johnmorrisdotca.github.io/kuni/).
552
+
553
+ **Sports**
554
+
555
+ - [Dougu Sports](https://github.com/johnmorrisdotca/dougu-sports) (道具): sports emblems as SVG: trophies, medals, crests, and the ball and gear of every sport, with optional 3D turning. [Demo](https://johnmorrisdotca.github.io/dougu-sports/).
556
+ - [Kyogijo Stadiums](https://github.com/johnmorrisdotca/kyogijo-stadiums) (競技場): sports fields, rinks, courts and ballparks drawn to scale as SVG, with each team and the score on them. [Demo](https://johnmorrisdotca.github.io/kyogijo-stadiums/).
557
+ - [Meigen Sports](https://github.com/johnmorrisdotca/meigen-sports) (名言): sports quotations and on-this-day history. [Demo](https://johnmorrisdotca.github.io/meigen-sports/).
558
+ - [Senshu Jerseys](https://github.com/johnmorrisdotca/senshu-jerseys) (選手): sports jerseys, sweaters, kits, caps, helmets and retired-number banners as SVG, front and back, with optional 2.5D turning. [Demo](https://johnmorrisdotca.github.io/senshu-jerseys/).
559
+ - [Taisen Brackets](https://github.com/johnmorrisdotca/taisen-brackets) (対戦): a sport-agnostic tournament bracket, drawn as SVG, from a list of ties. [Demo](https://johnmorrisdotca.github.io/taisen-brackets/).
560
+
561
+ **Developer tools**
562
+
563
+ - [REST in Pieces](https://github.com/spxis/rest-in-pieces) (レスト・イン・ピーシーズ): seeded test data and REST APIs for frontend development, with latency and error drills. [Demo](https://spxis.github.io/rest-in-pieces/).
564
+
565
+
566
+ **This package is Fuda Cards.** The demos of all forty-one share one header and footer, so each links the rest.
567
+ <!-- family:end -->
568
+
487
569
  ## Licence
488
570
 
489
- No licence file has been added to this repository yet, so nothing is granted beyond reading it and using the published package as npm describes. The card pictures in the demos belong to their owners: Pokémon card images and metadata are TCGdex's, the hockey and baseball pictures are public domain from Wikimedia Commons and The Met, and the Starship still carries the CC BY 4.0 credit in [assets/README.md](assets/README.md).
571
+ MIT, Copyright (c) 2026 John Morris: see [LICENSE](LICENSE). The pictures the demos show belong to their owners and are credited in [NOTICE.md](NOTICE.md): the Starship still is CC BY 4.0 (Clarence365's model, see [assets/README.md](assets/README.md)), the hockey and baseball pictures are public domain from Wikimedia Commons and The Met, and the Pokémon card images come from TCGdex when the demo opens and are not licensed by this project.
package/dist/binder.d.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  * A leaf has two sides, as a real one does: leaf k holds sides 2k (the right-hand page) and 2k+1 (the left-hand page of the next opening).
7
7
  * An opening (spread) j shows side 2j-1 on the left (none at the start) and side 2j on the right.
8
8
  */
9
- export type BinderStyle = 'ring' | 'zip';
10
- export type BinderSheet = 'clear' | 'black';
9
+ export type BinderStyle = "ring" | "zip";
10
+ export type BinderSheet = "clear" | "black";
11
11
  export declare const binderCovers: ReadonlyArray<{
12
12
  id: string;
13
13
  label: string;
@@ -36,11 +36,9 @@ export declare function spreadSides(spread: number, sides: number): [number, num
36
36
  export declare const BINDER_CSS = "\n.stage.binder{perspective:2400px;background:radial-gradient(ellipse,var(--fc-stage-1),var(--fc-stage-2) 68%)}\n.v.binder{--sw:300px;--sh:384px;--strip:34px;--cover:#1f7a4a;display:flex;align-items:center;justify-content:center;transform-style:preserve-3d}\n.book{position:relative;display:flex;padding:18px 16px;border-radius:16px;background:var(--cover);box-shadow:0 12px 28px #0008,inset 0 0 0 2px #fff2,inset 0 0 24px #0005;transform-style:preserve-3d}\n.book::before{content:'';position:absolute;inset:6px;border-radius:12px;box-shadow:inset 0 0 0 2px #0004;pointer-events:none}\n.book.b-zip::after{content:'';position:absolute;inset:5px;border-radius:13px;border:3px dotted #cfd2d8;opacity:.7;pointer-events:none}\n.book .tab{display:none}.book.b-zip .tab{display:block;position:absolute;right:30px;bottom:-4px;width:34px;height:14px;border-radius:5px;background:linear-gradient(#e4e6ea,#8d9098);box-shadow:0 2px 4px #0006}\n.inside{position:relative;display:flex;transform-style:preserve-3d;background:var(--lining,#f1eee6);border-radius:6px;box-shadow:inset 0 0 18px #0003}\n.half{position:relative;width:var(--sw);height:var(--sh);flex:none}\n.half:empty::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#0002,transparent 14%)}\n.spine{position:absolute;left:50%;top:0;bottom:0;width:0;transform-style:preserve-3d;pointer-events:none;z-index:3}\n.ring{position:absolute;left:-9px;width:18px;height:46px;margin-top:-23px;border-radius:9px;border:4px solid #c3c6cd;border-color:#f1f2f5 #8d9098 #8d9098 #f1f2f5;box-shadow:0 2px 3px #0005;transform:translateZ(2px)}\n.side{position:absolute;inset:0;display:grid;padding:12px 10px;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));grid-template-rows:repeat(var(--rows,3),minmax(0,1fr));gap:5px;background:var(--sheetbg);box-sizing:border-box;border:1px solid var(--sheetedge)}\n.side.clear{--sheetbg:#ffffff2e;--sheetedge:#ffffff55;--pocketbg:#ffffff26;--pocketedge:#ffffffa0}.side.black{--sheetbg:#17171b;--sheetedge:#000;--pocketbg:#ffffff12;--pocketedge:#ffffff55}\n.side.r{padding-left:calc(var(--strip) + 6px)}.side.l{padding-right:calc(var(--strip) + 6px)}\n.holes{position:absolute;top:0;bottom:0;width:var(--strip);display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;padding:14px 0}.side.r .holes{left:0}.side.l .holes{right:0}.holes i{width:9px;height:9px;border-radius:50%;background:var(--lining,#f1eee6);box-shadow:inset 0 1px 2px #0007,0 0 0 1px #0002}\n.pocket{position:relative;display:grid;place-items:center;border-radius:4px;background:var(--pocketbg);border:1px solid var(--pocketedge);box-shadow:inset 0 0 0 1px #0000000d,0 1px 2px #0003;overflow:hidden;min-width:0;min-height:0}\n.pocket::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(118deg,#ffffff55 0,#ffffff00 32%,#ffffff12 55%,#ffffff00 70%,#ffffff33 100%)}\n.pocket .card{position:relative;z-index:0;width:86%;height:92%;padding:0;border:0;background:transparent;line-height:0;display:grid;place-items:center}.pocket .card img{width:100%;height:100%;object-fit:contain;border-radius:3%;box-shadow:0 2px 5px #0007}\n.pocket.empty{opacity:.55}\n.leaf{position:absolute;left:50%;top:0;width:var(--sw);height:var(--sh);transform-origin:0 50%;transform-style:preserve-3d;pointer-events:none;z-index:2}\n.slice{position:absolute;top:0;height:100%;transform-origin:0 50%;transform-style:preserve-3d}\n.slice>.f,.slice>.b{position:absolute;inset:0 -1.5px;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}\n.slice .sf{position:absolute;top:0;height:100%}\n/* The slices overlap their neighbours by a pixel and a half, so no seam between them lets the page behind show; the outer edges of the leaf stay where they are. */\n.slice.first>.f,.slice.last>.b{left:0}.slice.first>.b,.slice.last>.f{right:0}\n";
37
37
  /** The cards a side holds, as indexes into the collection (or -1 for an empty pocket), in reading order. */
38
38
  export declare function sideCards(side: number, layout: BinderLayout, total: number): number[];
39
- export interface PocketMaker {
40
- (index: number, live: boolean): HTMLElement;
41
- }
39
+ export type PocketMaker = (index: number, live: boolean) => HTMLElement;
42
40
  /** One side as it lies in the book: `left` or `right` of the spine, with its hole strip against the spine. `live` pockets hold the page's real card buttons; the rest hold pictures only. */
43
- export declare function buildSide(side: number, where: 'l' | 'r', sheet: BinderSheet, layout: BinderLayout, total: number, pocket: PocketMaker, live?: boolean): HTMLElement;
41
+ export declare function buildSide(side: number, where: "l" | "r", sheet: BinderSheet, layout: BinderLayout, total: number, pocket: PocketMaker, live?: boolean): HTMLElement;
44
42
  /**
45
43
  * A leaf of the book, built to swing: a chain of slices hinged one on the next (the hole strip, then a slice for each column of
46
44
  * pockets), so that each can lean a little more than the one before it and the sheet bends. Each slice has the pockets of the front side on its
package/dist/binder.js CHANGED
@@ -1,10 +1,15 @@
1
1
  export const binderCovers = [
2
- { id: 'green', label: 'Green', color: '#1f7a4a' }, { id: 'black', label: 'Black', color: '#1d1d22' }, { id: 'teal', label: 'Teal', color: '#1a9d93' },
3
- { id: 'navy', label: 'Navy', color: '#1f3a70' }, { id: 'red', label: 'Red', color: '#b0262d' }
2
+ { id: "green", label: "Green", color: "#1f7a4a" },
3
+ { id: "black", label: "Black", color: "#1d1d22" },
4
+ { id: "teal", label: "Teal", color: "#1a9d93" },
5
+ { id: "navy", label: "Navy", color: "#1f3a70" },
6
+ { id: "red", label: "Red", color: "#b0262d" },
4
7
  ];
5
8
  /** The sheets a binder takes: how many pockets and how they lie (across by down). 9 is the usual page; 4 and 12 are the other common ones. */
6
9
  export const binderPockets = [
7
- { count: 4, cols: 2, rows: 2 }, { count: 9, cols: 3, rows: 3 }, { count: 12, cols: 4, rows: 3 }
10
+ { count: 4, cols: 2, rows: 2 },
11
+ { count: 9, cols: 3, rows: 3 },
12
+ { count: 12, cols: 4, rows: 3 },
8
13
  ];
9
14
  /** The pockets of a sheet: `pockets` (4, 9 or 12) if the page asks, else the older `columns` and `page-size`, else nine in three columns. */
10
15
  export function binderLayout(pockets, columns, pageSize) {
@@ -22,7 +27,8 @@ export const spreadCount = (sides) => Math.ceil((sides + 1) / 2);
22
27
  export const spreadOf = (index, per) => Math.ceil(Math.floor(index / per) / 2);
23
28
  /** The sides an opening shows (-1 where there is none), left then right, for `sides` sides in all. */
24
29
  export function spreadSides(spread, sides) {
25
- const left = 2 * spread - 1, right = 2 * spread;
30
+ const left = 2 * spread - 1;
31
+ const right = 2 * spread;
26
32
  return [left >= 0 && left < sides ? left : -1, right < sides ? right : -1];
27
33
  }
28
34
  export const BINDER_CSS = `
@@ -58,17 +64,17 @@ export function sideCards(side, layout, total) {
58
64
  }
59
65
  /** One side as it lies in the book: `left` or `right` of the spine, with its hole strip against the spine. `live` pockets hold the page's real card buttons; the rest hold pictures only. */
60
66
  export function buildSide(side, where, sheet, layout, total, pocket, live = true) {
61
- const el = document.createElement('div');
67
+ const el = document.createElement("div");
62
68
  el.className = `side ${where} ${sheet}`;
63
69
  el.dataset.side = String(side);
64
- el.style.setProperty('--cols', String(layout.cols));
65
- el.style.setProperty('--rows', String(layout.rows));
66
- const holes = document.createElement('div');
67
- holes.className = 'holes';
68
- holes.innerHTML = '<i></i>'.repeat(9);
70
+ el.style.setProperty("--cols", String(layout.cols));
71
+ el.style.setProperty("--rows", String(layout.rows));
72
+ const holes = document.createElement("div");
73
+ holes.className = "holes";
74
+ holes.innerHTML = "<i></i>".repeat(9);
69
75
  el.append(holes);
70
76
  for (const index of sideCards(side, layout, total))
71
- el.append(index < 0 ? Object.assign(document.createElement('div'), { className: 'pocket empty' }) : pocket(index, live));
77
+ el.append(index < 0 ? Object.assign(document.createElement("div"), { className: "pocket empty" }) : pocket(index, live));
72
78
  return el;
73
79
  }
74
80
  /**
@@ -77,32 +83,35 @@ export function buildSide(side, where, sheet, layout, total, pocket, live = true
77
83
  * front and the matching column of the back side on its back. Returns the leaf and its slices.
78
84
  */
79
85
  export function buildLeaf(front, back, sheet, layout, total, pocket, widthPx, strip) {
80
- const leaf = document.createElement('div');
81
- leaf.className = 'leaf';
86
+ const leaf = document.createElement("div");
87
+ leaf.className = "leaf";
82
88
  const faces = (side, where) => side < 0 ? null : buildSide(side, where, sheet, layout, total, pocket, false);
83
- const rightSide = faces(front, 'r'), leftSide = faces(back, 'l');
89
+ const rightSide = faces(front, "r");
90
+ const leftSide = faces(back, "l");
84
91
  const widths = [strip + 6, ...Array.from({ length: layout.cols }, () => (widthPx - strip - 6) / layout.cols)];
85
92
  const slices = [];
86
- let parent = leaf, offset = 0;
93
+ let parent = leaf;
94
+ let offset = 0;
87
95
  widths.forEach((w, k) => {
88
- const slice = document.createElement('div');
89
- slice.className = k === 0 ? 'slice first' : k === widths.length - 1 ? 'slice last' : 'slice';
96
+ const slice = document.createElement("div");
97
+ slice.className = k === 0 ? "slice first" : k === widths.length - 1 ? "slice last" : "slice";
90
98
  slice.style.width = `${w}px`;
91
- slice.style.left = k === 0 ? '0' : '100%';
92
- const f = document.createElement('div'), b = document.createElement('div');
93
- f.className = 'f';
94
- b.className = 'b';
99
+ slice.style.left = k === 0 ? "0" : "100%";
100
+ const f = document.createElement("div");
101
+ const b = document.createElement("div");
102
+ f.className = "f";
103
+ b.className = "b";
95
104
  // The whole side is placed inside each slice's face and shifted so that this slice shows its own part of it.
96
105
  if (rightSide) {
97
106
  const copy = rightSide.cloneNode(true);
98
- copy.classList.add('sf');
107
+ copy.classList.add("sf");
99
108
  copy.style.width = `${widthPx}px`;
100
109
  copy.style.left = `${-offset}px`;
101
110
  f.append(copy);
102
111
  }
103
112
  if (leftSide) {
104
113
  const copy = leftSide.cloneNode(true);
105
- copy.classList.add('sf');
114
+ copy.classList.add("sf");
106
115
  copy.style.width = `${widthPx}px`;
107
116
  copy.style.left = `${-(widthPx - offset - w)}px`;
108
117
  b.append(copy);
@@ -0,0 +1,2 @@
1
+ /** The card's shadow root: its stylesheet, the front, the back, the edge and the place for the cards under the top one. */
2
+ export declare function cardMarkup(): string;
@@ -0,0 +1,59 @@
1
+ import { CARD_CSS } from "./card-styles.js";
2
+ /** The corner radius of the card's face, in design pixels (a 300th of the card's width). */
3
+ const CORNER_RADIUS = 15;
4
+ /** The edge planes stop this far from the corner so that the rounded corner is not poked through (twice the corner radius). */
5
+ const EDGE_INSET = CORNER_RADIUS * 2;
6
+ /**
7
+ * Each rounded corner is edged by two short planes that follow its curve, as the straight edges are by one: where they sit from the corner, how long
8
+ * they are and how far they turn. They are tangents of the 15 pixel arc, one at 22.5 degrees and one at 67.5 degrees round it (length 2 r tan 22.5, at
9
+ * r (1 - cos 22.5) and r (1 - sin 22.5) from the corner), not chords. A plane of the edge reaches across the whole card when it is extended, and the browser
10
+ * cuts the faces it crosses along it, which left a thin diagonal line on the card (MODULES-142): a tangent of a convex card never crosses its face.
11
+ */
12
+ const CORNER_PLANE = { near: 1.14, far: 9.26, length: 12.43, steep: 67.5, shallow: 22.5 };
13
+ const design = (pixels) => `calc(${pixels} * var(--u))`;
14
+ const fromRight = (pixels) => `calc(100% - ${design(pixels)})`;
15
+ const plane = ({ left, top, width, height, transform, side }) => `<i class="edge${side ? " side" : ""}" style="left:${left};top:${top};width:${width};height:${height};transform:${transform}"></i>`;
16
+ const turned = (degrees) => `translate(-50%,-50%) rotate(${degrees}deg) rotateX(90deg)`;
17
+ /** The planes that make the card's edge: four straight ones and eight that follow the corners. */
18
+ function edgePlanes() {
19
+ const run = `calc(100% - ${design(EDGE_INSET)})`;
20
+ const { near, far, length, steep, shallow } = CORNER_PLANE;
21
+ const long = design(length);
22
+ const corner = (left, top, degrees) => plane({ left, top, width: long, height: "var(--t)", transform: turned(degrees) });
23
+ return [
24
+ plane({ left: "50%", top: "0", width: run, height: "var(--t)", transform: turned(0) }),
25
+ plane({ left: "50%", top: "100%", width: run, height: "var(--t)", transform: turned(0) }),
26
+ plane({
27
+ left: "0",
28
+ top: "50%",
29
+ width: "var(--t)",
30
+ height: run,
31
+ transform: "translate(-50%,-50%) rotateY(90deg)",
32
+ side: true,
33
+ }),
34
+ plane({
35
+ left: "100%",
36
+ top: "50%",
37
+ width: "var(--t)",
38
+ height: run,
39
+ transform: "translate(-50%,-50%) rotateY(90deg)",
40
+ side: true,
41
+ }),
42
+ corner(design(near), design(far), -steep),
43
+ corner(design(far), design(near), -shallow),
44
+ corner(design(near), fromRight(far), steep),
45
+ corner(design(far), fromRight(near), shallow),
46
+ corner(fromRight(near), design(far), steep),
47
+ corner(fromRight(far), design(near), shallow),
48
+ corner(fromRight(near), fromRight(far), -steep),
49
+ corner(fromRight(far), fromRight(near), -shallow),
50
+ ].join("");
51
+ }
52
+ /** The picture's slot and its Animate button. */
53
+ const ART = `<div class="art"><slot></slot><button class="motion-button" type="button" aria-pressed="false" aria-label="Animate the picture" title="Animate" hidden><span class="glyph"><svg viewBox="0 0 12 12" aria-hidden="true"><path class="play" d="M3 1.5v9l7.5-4.5z"/><path class="pause" d="M2.5 1.5h2.8v9H2.5zM6.7 1.5h2.8v9H6.7z"/></svg></span></button></div>`;
54
+ const FRONT = `<div class="face front"><div class="inner"><div class="heading"><span id="title"></span><span class="badge" id="category"></span></div>${ART}<div class="subtitle" id="subtitle"></div><div class="description" id="description"></div><div class="footer"><span id="number"></span><span>✦ FUDA COLLECTION</span><span id="rarity"></span></div></div><div class="shine"></div></div>`;
55
+ const BACK = `<div class="face back"><div class="emblem">FUDA</div><div class="shine"></div></div>`;
56
+ /** The card's shadow root: its stylesheet, the front, the back, the edge and the place for the cards under the top one. */
57
+ export function cardMarkup() {
58
+ return `<style>${CARD_CSS}</style><div class="rotation"><div class="card">${FRONT}${BACK}${edgePlanes()}<div class="stills"></div></div></div>`;
59
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * A card's finish: foil catches the light and shows a rainbow in its frame, matte does not.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { cardFinishes, type CardFinish } from "@johnmorrisdotca/fuda-cards";
7
+ *
8
+ * const finish: CardFinish = "matte";
9
+ * console.log(cardFinishes.includes(finish)); // true
10
+ * ```
11
+ */
12
+ export type CardFinish = "foil" | "matte";
13
+ /**
14
+ * A card's look: classic gold, silver sport or cosmic violet.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { cardVariants, type CardVariant } from "@johnmorrisdotca/fuda-cards";
19
+ *
20
+ * const look: CardVariant = "cosmic";
21
+ * console.log(cardVariants.indexOf(look)); // 2
22
+ * ```
23
+ */
24
+ export type CardVariant = "classic" | "sport" | "cosmic";
25
+ /**
26
+ * Every setting of `<fuda-card>` as an object. `cardAttributes(options)` turns it into the element's attributes, so the same object
27
+ * works in a framework, a script and a test.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { type CardOptions, cardAttributes } from "@johnmorrisdotca/fuda-cards";
32
+ *
33
+ * const options: CardOptions = { title: "Explorer One", variant: "sport", stack: 10, wear: "near-mint" };
34
+ * console.log(cardAttributes(options).variant); // sport
35
+ * ```
36
+ */
37
+ export interface CardOptions {
38
+ title?: string;
39
+ category?: string;
40
+ subtitle?: string;
41
+ description?: string;
42
+ number?: string;
43
+ rarity?: string;
44
+ variant?: CardVariant;
45
+ finish?: CardFinish;
46
+ /** Card thickness in millimetres at the 63 mm wide card size; overrides the material's. Default 0.325, 0 for a flat card. */
47
+ thickness?: number;
48
+ /** A material's id (see `cardMaterials`): its sourced thickness and edge colour. */
49
+ material?: string;
50
+ /** How many cards the stack holds (1 to 1000); the stack is that many times the card's thickness high. Default 1, one card. */
51
+ stack?: number;
52
+ /** From 0 (squared up) to 1 (very messy) for the cards under the top one. Default 0.3. */
53
+ stackMessiness?: number;
54
+ /** The stack's seed: the same seed lays the same stack the same way. Default 1. */
55
+ stackSeed?: number;
56
+ /** How many cards under the top one are laid out nudged and turned, at most 52. Default 10. */
57
+ stackDepth?: number;
58
+ /** A card that is not perfect: a preset's id (`mint`, `near-mint`, `lightly-played`, `moderately-played`, `heavily-played`, `damaged`) or a number from 0 to 1. Default: perfect, nothing drawn. */
59
+ wear?: string | number;
60
+ /** The wear's seed: the same seed draws the same marks the same way. Default 1. */
61
+ wearSeed?: number;
62
+ /** One level of the wear on its own, from 0 to 1, over the preset's. */
63
+ wearCorners?: number;
64
+ wearEdges?: number;
65
+ wearSurface?: number;
66
+ wearCreases?: number;
67
+ /** The card shows its back. */
68
+ flipped?: boolean;
69
+ motion?: "still" | "pan";
70
+ /** The picture is moving now (needs `motion: "pan"`). */
71
+ playing?: boolean;
72
+ /** `focus`: the card in focus animates its art (needs `motion: 'pan'`); never with reduced motion. */
73
+ autoplay?: "focus";
74
+ panDirection?: "down" | "up";
75
+ panLoop?: "alternate" | "restart";
76
+ cardSpin?: "center" | "corner";
77
+ cardSpinDirection?: "normal" | "reverse";
78
+ cardSpinPaused?: boolean;
79
+ /** The page turns the card with `--fuda-yaw` and `--fuda-tilt` instead of the built-in spin. */
80
+ cardView?: boolean;
81
+ /** `open`: a stack of more than one card fans open. */
82
+ fan?: "open";
83
+ /** How many cards are on the pile beside the stack. */
84
+ takenOff?: number;
85
+ /** How a card taken off lands: `face-up` or turned over (`face-down`). */
86
+ deckLand?: "face-up" | "face-down";
87
+ /** `off` ends every move at once. */
88
+ animate?: "on" | "off";
89
+ /** How long a move takes: `slow`, `normal` or `quick`. */
90
+ speed?: "slow" | "normal" | "quick";
91
+ /** The three buttons under a stack: Fan, Take a card off and Put it back. */
92
+ pileControls?: boolean;
93
+ }
94
+ /**
95
+ * The three looks, in the order the studio offers them.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * import { cardVariants } from "@johnmorrisdotca/fuda-cards";
100
+ *
101
+ * console.log(cardVariants.join(" ")); // classic sport cosmic
102
+ * ```
103
+ */
104
+ export declare const cardVariants: readonly CardVariant[];
105
+ /**
106
+ * The two finishes, foil and matte.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { cardFinishes } from "@johnmorrisdotca/fuda-cards";
111
+ *
112
+ * console.log(cardFinishes.join(" ")); // foil matte
113
+ * ```
114
+ */
115
+ export declare const cardFinishes: readonly CardFinish[];
116
+ /**
117
+ * The attributes of a `<fuda-card>` for these options, ready to set one by one (`element.setAttribute(name, value)`): names are the
118
+ * kebab-case of the option's, a `true` boolean is the empty string (the attribute is present) and a `false` one, like anything that
119
+ * is `undefined` or `null`, is left out. Numbers are written as plain text.
120
+ *
121
+ * @param options - The settings of the card, by their camel-case names.
122
+ * @returns The attributes by name; set each with `element.setAttribute(name, value)`. Nothing is shared with `options`.
123
+ * @example
124
+ * ```ts
125
+ * import { cardAttributes } from "@johnmorrisdotca/fuda-cards";
126
+ *
127
+ * console.log(cardAttributes({ title: "Explorer One", stackMessiness: 0.5, flipped: true, wear: undefined }));
128
+ * // { title: 'Explorer One', 'stack-messiness': '0.5', flipped: '' }
129
+ * ```
130
+ */
131
+ export declare function cardAttributes(options: CardOptions): Record<string, string>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The three looks, in the order the studio offers them.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { cardVariants } from "@johnmorrisdotca/fuda-cards";
7
+ *
8
+ * console.log(cardVariants.join(" ")); // classic sport cosmic
9
+ * ```
10
+ */
11
+ export const cardVariants = ["classic", "sport", "cosmic"];
12
+ /**
13
+ * The two finishes, foil and matte.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { cardFinishes } from "@johnmorrisdotca/fuda-cards";
18
+ *
19
+ * console.log(cardFinishes.join(" ")); // foil matte
20
+ * ```
21
+ */
22
+ export const cardFinishes = ["foil", "matte"];
23
+ /** A setting's name as the element's attribute: `stackMessiness` is `stack-messiness`. */
24
+ const attributeName = (name) => name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
25
+ /**
26
+ * The attributes of a `<fuda-card>` for these options, ready to set one by one (`element.setAttribute(name, value)`): names are the
27
+ * kebab-case of the option's, a `true` boolean is the empty string (the attribute is present) and a `false` one, like anything that
28
+ * is `undefined` or `null`, is left out. Numbers are written as plain text.
29
+ *
30
+ * @param options - The settings of the card, by their camel-case names.
31
+ * @returns The attributes by name; set each with `element.setAttribute(name, value)`. Nothing is shared with `options`.
32
+ * @example
33
+ * ```ts
34
+ * import { cardAttributes } from "@johnmorrisdotca/fuda-cards";
35
+ *
36
+ * console.log(cardAttributes({ title: "Explorer One", stackMessiness: 0.5, flipped: true, wear: undefined }));
37
+ * // { title: 'Explorer One', 'stack-messiness': '0.5', flipped: '' }
38
+ * ```
39
+ */
40
+ export function cardAttributes(options) {
41
+ const attributes = {};
42
+ for (const [name, value] of Object.entries(options)) {
43
+ if (value === undefined || value === null || value === false)
44
+ continue;
45
+ attributes[attributeName(name)] = value === true ? "" : String(value);
46
+ }
47
+ return attributes;
48
+ }
@@ -0,0 +1,2 @@
1
+ /** The stylesheet of the card's shadow root. */
2
+ export declare const CARD_CSS: string;