@johnmorrisdotca/fuda-cards 0.9.2 → 0.10.1

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 (35) hide show
  1. package/README.md +382 -58
  2. package/dist/collection-element.d.ts +13 -0
  3. package/dist/collection-element.js +18 -1
  4. package/dist/live-3d.d.ts +43 -0
  5. package/dist/live-3d.js +161 -0
  6. package/docs/API.md +793 -0
  7. package/docs/collection-displays.md +1 -1
  8. package/docs/guides/accessibility-and-theming.md +62 -0
  9. package/docs/guides/architecture.md +53 -0
  10. package/docs/guides/binder-and-piles.md +83 -0
  11. package/docs/guides/card-element.md +65 -0
  12. package/docs/guides/collections.md +86 -0
  13. package/docs/guides/frameworks.md +105 -0
  14. package/docs/guides/getting-started.md +94 -0
  15. package/docs/guides/ja/accessibility-and-theming.md +62 -0
  16. package/docs/guides/ja/architecture.md +53 -0
  17. package/docs/guides/ja/binder-and-piles.md +83 -0
  18. package/docs/guides/ja/card-element.md +65 -0
  19. package/docs/guides/ja/collections.md +86 -0
  20. package/docs/guides/ja/frameworks.md +105 -0
  21. package/docs/guides/ja/getting-started.md +94 -0
  22. package/docs/guides/ja/live-3d.md +75 -0
  23. package/docs/guides/ja/materials-and-stacks.md +73 -0
  24. package/docs/guides/ja/motion-and-spin.md +73 -0
  25. package/docs/guides/ja/troubleshooting.md +60 -0
  26. package/docs/guides/ja/upgrading.md +56 -0
  27. package/docs/guides/ja/wear.md +63 -0
  28. package/docs/guides/live-3d.md +75 -0
  29. package/docs/guides/materials-and-stacks.md +73 -0
  30. package/docs/guides/motion-and-spin.md +73 -0
  31. package/docs/guides/troubleshooting.md +60 -0
  32. package/docs/guides/upgrading.md +56 -0
  33. package/docs/guides/wear.md +63 -0
  34. package/docs/live-3d.md +59 -0
  35. package/package.json +29 -6
package/README.md CHANGED
@@ -1,165 +1,489 @@
1
- # Fuda Cards
1
+ <p align="center"><a href="https://johnmorrisdotca.github.io/fuda-cards/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/thumbnail-dark.png"><img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/thumbnail.png" alt="Fuda Cards: three collectible cards, classic gold, silver sport and cosmic violet, framing the same rocket picture." width="1200"></picture></a></p>
2
+
3
+ <h1 align="center">Fuda Cards <sub>札</sub> — collectible card frames for the web</h1>
4
+
5
+ <p align="center"><strong>Cards with a true thickness, a stack, a worn corner and a binder to put them in, as two web components.</strong><br>
6
+ `&lt;fuda-card&gt;` frames a picture or a live 3D viewer; `&lt;fuda-collection&gt;` shows a whole collection in ten displays. Plain HTML, React, Vue, Svelte and Angular. No framework and no 3D engine required.</p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/johnmorrisdotca/fuda-cards/actions/workflows/pages.yml"><img alt="Pages" src="https://github.com/johnmorrisdotca/fuda-cards/actions/workflows/pages.yml/badge.svg"></a>
10
+ <a href="https://www.npmjs.com/package/@johnmorrisdotca/fuda-cards"><img alt="npm" src="https://img.shields.io/npm/v/@johnmorrisdotca/fuda-cards?color=8a5a14"></a>
11
+ <img alt="TypeScript" src="https://img.shields.io/badge/types-TypeScript-3178c6">
12
+ <img alt="One dependency" src="https://img.shields.io/badge/dependencies-1-8a5a14">
13
+ </p>
14
+
15
+ <p align="center"><a href="https://johnmorrisdotca.github.io/fuda-cards/"><strong>Open the Card Studio →</strong></a> · <a href="https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/getting-started.md">Getting started</a> · <a href="https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/API.md">API reference</a> · <a href="https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides">All guides</a></p>
16
+
17
+ <table align="center">
18
+ <tr>
19
+ <td align="center" valign="top">
20
+ <picture>
21
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/studio-desk-dark.webp">
22
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/studio-desk-light.webp" alt="The Card Studio on a desk: a gold Starship Block 3 card in a stage with the view controls under it and the card options on the right.">
23
+ </picture>
24
+ <br><em>The Card Studio on a desk.</em>
25
+ </td>
26
+ <td align="center" valign="top">
27
+ <picture>
28
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/studio-phone-dark.webp">
29
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/studio-phone-light.webp" alt="The Card Studio on a phone: the card above its view controls.">
30
+ </picture>
31
+ <br><em>The same on a phone, in the device's light or dark.</em>
32
+ </td>
33
+ </tr>
34
+ </table>
35
+
36
+ Fuda Cards is for a page that wants to show things people collect: trading cards, vintage cards, consoles, rockets. A card is a frame around a picture you supply, or around a live 3D viewer, drawn with a thickness to scale, an edge, a back, and wear if you want it. A collection is a shelf of them in a binder, a fan, a deck, a wall. The picture is always yours: Fuda stores nothing, hosts nothing and asks for no account.
37
+
38
+ This is an early package: classic, sport and cosmic are exploratory CSS designs, not yet historically researched recreations or photorealistic materials. The demos use a still from Uchusen Rockets; [assets/README.md](assets/README.md) has its model credit.
39
+
40
+ ## In 30 seconds
41
+
42
+ ```sh
43
+ npm install @johnmorrisdotca/fuda-cards
44
+ ```
2
45
 
3
- Reusable collectible card frames for caller-provided images and interactive 3D viewers. The core is a standards-based web component, suitable for plain HTML, Angular, React, Vue, Svelte, and other frameworks that support custom elements. No framework or 3D engine is required by the component. `<fuda-card>` imports only its own small modules (the materials and the stack layout); `<fuda-collection>` uses [`@johnmorrisdotca/kazoku-ui`](https://github.com/johnmorrisdotca/kazoku-ui) for its zoom controls (see Collection viewer).
46
+ ```html
47
+ <script type="module">
48
+ import '@johnmorrisdotca/fuda-cards/element';
49
+ </script>
50
+ <fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" description="A new explorer.">
51
+ <img src="rocket.jpg" alt="Explorer One rocket">
52
+ </fuda-card>
53
+ ```
4
54
 
5
- This is an early prototype: classic, sport and cosmic are exploratory CSS designs, not yet historically researched recreations or photorealistic materials. The demo uses a still from Uchusen Rockets; see [assets/README.md](assets/README.md) for its model credit.
55
+ And the tables behind it, in script, with no page at all:
6
56
 
7
- ## Demos
57
+ ```ts
58
+ import { cardMaterial, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
8
59
 
9
- [Open the Fuda Cards demos](https://johnmorrisdotca.github.io/fuda-cards/). The Card Studio and the collection and Pokémon binder demos are built together for GitHub Pages. From the studio, follow the collection links to explore them. Run `pnpm site` to build the static site in `site/`; serve that directory to review it. The Pages workflow runs the checks and deploys the site on pushes to `main`.
60
+ const stock = cardMaterial('paper-310-black-core');
61
+ console.log(stock?.name, stock?.thicknessMm);
62
+ console.log(stackHeightMm(52, stock?.thicknessMm ?? 0.3));
63
+ console.log(wearPresets.map((preset) => preset.id).join(' '));
64
+ // Playing-card stock, black core, 310 gsm (13 pt) 0.325
65
+ // 16.9
66
+ // perfect mint near-mint lightly-played moderately-played heavily-played damaged
67
+ ```
10
68
 
11
- ## Development
69
+ ## Who it is for
12
70
 
13
- Requires Node 22+ and pnpm. Run `pnpm install`, `pnpm check`, then `pnpm dev` and open http://localhost:8100. `pnpm build` emits JavaScript and TypeScript declarations to `dist/`.
71
+ - A site that sells, catalogues or shows off cards, and wants a card that looks like one: thickness, edge, back, wear.
72
+ - A project with a 3D viewer (a rocket, a device) that wants it to sit in a card, turning only when the card is in focus.
73
+ - A collector who wants a binder, a deck on a table or a fan of cards for their own pictures.
74
+ - Anyone who needs it in a framework: it is a standard custom element, so React, Vue, Svelte, Angular and plain HTML all work.
75
+
76
+ ## Features
77
+
78
+ - **A true-scale card.** Thickness in millimetres at the 63 mm card size, a drawn edge, a back, a foil or matte finish, three frame variants.
79
+ - **Sourced materials.** Thirteen materials, each thickness read from a maker or a standard and cited.
80
+ - **Stacks.** One card to a thousand, as high as the count times the thickness, a seeded messiness.
81
+ - **Wear.** Six grading presets, a seed, and one dial for corners, edges, surface and creases.
82
+ - **Motion.** A pan over a tall picture, autoplay on the card in focus, a spin about the centre or a corner.
83
+ - **Piles.** Fan open, take a card off, land it face up or turned over.
84
+ - **Ten displays** for a collection, a ring or zip binder that turns real pages among them.
85
+ - **Live 3D on one WebGL context.** One card at a time turns; the rest are pictures.
86
+ - **Zoom, Fit and move** in every display, with the address kept in the link.
87
+ - **Light and dark,** keyboard, touch and reduced motion built in.
88
+
89
+ ## Install
90
+
91
+ ```sh
92
+ npm install @johnmorrisdotca/fuda-cards
93
+ ```
14
94
 
15
- ## Embed
95
+ Requires Node 22 or later for the tooling; the elements run in any current browser. `@johnmorrisdotca/kazoku-ui` comes with it (it draws the zoom bar). `three` is an optional peer dependency, needed only for live 3D. The package is ES modules with TypeScript declarations in `dist/`.
96
+
97
+ ## Use it in your project
98
+
99
+ In a bundler, import the element once before rendering it. Anywhere that runs in the browser will do.
100
+
101
+ ```ts no-run
102
+ import '@johnmorrisdotca/fuda-cards/element';
103
+ import '@johnmorrisdotca/fuda-cards/collection-element';
104
+ import type { CardOptions } from '@johnmorrisdotca/fuda-cards';
105
+
106
+ const options: CardOptions = { title: 'Relic', thickness: 1.5, wear: 'near-mint' };
107
+ const card = document.createElement('fuda-card');
108
+ card.setAttribute('title', options.title ?? '');
109
+ card.setAttribute('thickness', String(options.thickness));
110
+ document.body.append(card);
111
+ ```
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).
114
+
115
+ ## Use it anywhere
116
+
117
+ With no bundler, serve the package's `dist` folder and point a module script at it:
16
118
 
17
119
  ```html
18
- <!-- in the head, first: the one line from "No flash before the card is ready" below -->
19
- <script type="module" src="/path/to/fuda-cards/dist/element.js"></script>
20
- <fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" description="A new explorer.">
21
- <img src="rocket.jpg" alt="Explorer One rocket">
22
- </fuda-card>
120
+ <script type="importmap">
121
+ { "imports": { "@johnmorrisdotca/fuda-cards/element": "/node_modules/@johnmorrisdotca/fuda-cards/dist/element.js" } }
122
+ </script>
123
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
124
+ <fuda-card title="Anywhere"></fuda-card>
23
125
  ```
24
126
 
25
- In a bundler, import `@johnmorrisdotca/fuda-cards/element` once before rendering `<fuda-card>`. Frameworks may require custom-element configuration (for example, Angular's `CUSTOM_ELEMENTS_SCHEMA`). Framework-specific wrappers have not yet been implemented; see [framework integration examples](docs/framework-integration.md). For published releases, install with `npm install @johnmorrisdotca/fuda-cards`.
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.
26
128
 
27
- The default slot accepts HTML, including an existing interactive 3D viewer; its owner handles rotation, zoom and model loading. The card has no drag-to-flip handler, leaving pointer interaction to that viewer. Control the card's reverse independently by adding or removing the `flipped` attribute. The demo provides a flip button. Attributes: `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.3`), `material`, `stack`, `wear` and `flipped` (boolean). Set the element width to scale it. The main package entry exports the TypeScript options and available variants and finishes without registering the custom element.
129
+ ## Examples
28
130
 
29
- 3D integrations, framework-specific examples, polished front and back designs, accessibility validation, and photorealistic finishes remain future work.
131
+ A card with a back and a thick edge, a deck, a worn card, a collection. Each of these is run in a browser by `pnpm test:readme`.
30
132
 
31
- Collection presentation prototypes are available as a reusable `<fuda-collection>` component. See the [collection demo](demo/collections-component.html) and [collection display notes](docs/collection-displays.md).
133
+ ```html
134
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
135
+ <fuda-card title="Relic" thickness="1.5"></fuda-card>
136
+ <fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
137
+ <fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
138
+ ```
32
139
 
33
- ### No flash before the card is ready
140
+ ```html
141
+ <fuda-collection view="deck"></fuda-collection>
142
+ <script type="module">
143
+ import '@johnmorrisdotca/fuda-cards/collection-element';
144
+ document.querySelector('fuda-collection').cards = [
145
+ { id: 'one', name: 'My card', image: '/cards/front.jpg', backImage: '/cards/back.jpg' }
146
+ ];
147
+ </script>
148
+ ```
149
+
150
+ ## The card
151
+
152
+ `<fuda-card>` has the attributes `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.3`), `material`, `stack`, `wear` and `flipped` (boolean). Set the element's width to scale it; it keeps the 2.5 by 3.5 proportion of a real card. The default slot accepts HTML, including an existing interactive 3D viewer: its owner handles rotation, zoom and model loading, and the card has no drag-to-flip handler. Control the reverse by adding or removing `flipped`.
153
+
154
+ ```ts
155
+ import { cardFinishes, cardVariants } from '@johnmorrisdotca/fuda-cards';
156
+
157
+ console.log(cardVariants.join(' '), cardFinishes.join(' '));
158
+ // classic sport cosmic foil matte
159
+ ```
160
+
161
+ Every attribute, property and CSS variable is in [The card element](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/card-element.md).
162
+
163
+ ## No flash before the card is ready
34
164
 
35
165
  A card never shows the art it is about to frame. Until the script has defined `<fuda-card>`, a browser draws your `<img>` at its natural size, so the whole picture flashes before it moves into the frame. Put this one line in the `<head>`, before the script and your own styles, and the card stays invisible while its box is already reserved at the card's size (nothing moves when it appears):
36
166
 
37
- ```html
167
+ ```html no-check
38
168
  <style>fuda-card:where(:not(:defined)){display:inline-block;width:300px;aspect-ratio:2.5/3.5;overflow:hidden;visibility:hidden}fuda-collection:where(:not(:defined)){display:block;min-height:calc(var(--fuda-stage-height,clamp(300px,calc(100svh - 440px),620px)) + 380px)}</style>
39
169
  ```
40
170
 
41
171
  It keeps `<fuda-card>` (300 px wide, 2.5:3.5, or whatever width your own rule gives it) and `<fuda-collection>` (the height of its view, `--fuda-stage-height`) in place. Once defined, the card also keeps the art invisible until the card has a size on screen and every slotted image has loaded, then fades it in (no fade with `prefers-reduced-motion`). Without the line the card still reveals the art only inside its frame after it is defined, but the browser may show the raw picture until your script runs. If scripts never run, the card stays blank; add `<noscript><style>fuda-card:not(:defined){visibility:visible}</style></noscript>` if you want the plain picture then.
42
172
 
43
- ### Back face and thickness
173
+ ## Back face and thickness
44
174
 
45
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.
46
176
 
47
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.
48
178
 
49
179
  ```html
50
- <fuda-card title="Relic" thickness="1.5"></fuda-card>
180
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
181
+ <fuda-card title="Relic" thickness="1.5" flipped></fuda-card>
51
182
  ```
52
183
 
53
- ### Materials and stacks
184
+ ![A card 4.5 mm thick turned to show its edge, on a phone](https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/thick-phone-light.webp)
185
+
186
+ ## Materials and stacks
54
187
 
55
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).
56
189
 
57
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.
58
191
 
59
192
  ```html
193
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
60
194
  <fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
61
195
  ```
62
196
 
63
197
  The top card is the live card. The block under it is one piece, and with `stack-messiness` above 0 (0 neat to 1 very messy, default 0.3) the `stack-depth` cards under the top one (default 10, at most 52) are drawn as flat stills, nudged and turned from `stack-seed`: the same seed gives the same stack, and a card put on top moves none of those under it. A stack is one 3D scene whatever its count, and it draws nothing while it is at rest: a test checks that a 52-card stack requests no frames at rest. The idea of a pile from neat to messy and its parameters come from [toranpu](https://github.com/johnmorrisdotca/toranpu)'s `<toranpu-pile>`. In script, `card.stackCount` and `card.stackHeight` (mm) are read-only, and the package exports `cardMaterials`, `stackPresets`, `stackHeightMm` and `stackLayout`.
64
198
 
65
- ### Binder Pages
199
+ <picture>
200
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/stack-desk-dark.webp">
201
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/stack-desk-light.webp" alt="A stack of 52 cards seen at an angle with a fine line along the edge for each card.">
202
+ </picture>
203
+ <br><em>A stack of 52 cards, slightly messy.</em>
66
204
 
67
- `view="binder"` is a binder open on two facing sheets, as one is kept: each sheet is a page of clear plastic pockets (nine, three by three) with a slight sheen, one card sitting inside each pocket, on a clear or a black sheet, with a strip of punched holes down the edge that lies against the rings. Next and Previous turn the page: a leaf swings about the spine, bends as it goes and shows the pockets on its back, forwards and backwards (`animate="off"` changes the page at once, ending in exactly the same place; reduced motion likewise). Options, each a row of buttons under the view and in the address: `binder="ring|zip"` (a ring binder, or a zip binder with its zipper and pull), `cover="green|black|teal|navy|red"` (a plain cover), `sheet="clear|black"` and `pockets="4|9|12"` (two by two, three by three, four across by three down). The older `page-size` and `columns` still work and set the pockets of a sheet. Clicking a card opens it as before.
205
+ More in [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md).
68
206
 
69
- ### Fan a stack, take a card off it
207
+ ## Fan a stack, take a card off it
70
208
 
71
209
  A stack of more than one card is a pile like the collection's deck, with the same fan and the same landing. `fan="open"` spreads up to ten cards in an arc (every card drawn with its face and the picture) and closes back exactly where they began. `taken-off="3"` puts the top three cards on a pile at the stack's side, as thick as the cards in it: `card.takeOff()` flies the top card across and `card.putBack()` brings it back, and `deck-land="face-up"` (the default) or `"face-down"` (turned over sideways, showing the back) says how it lands. `pile-controls` draws three buttons (Fan, Take a card off, Put it back; each at least 48 px) under the card; leave about 70 px of room below it. `animate="off"` and `speed="slow|quick"` are the same as in the collection. The card turns with the pile (the angle, tilt and Auto-turn work as before) and an open fan or a pile at the side is part of what turns: `card.pileBounds` says how far they reach beyond the card, in card widths, and `fuda-pile` is sent when it changes, so a page can fit its view.
72
210
 
73
211
  ```html
212
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
74
213
  <fuda-card title="Deck" stack="52" pile-controls></fuda-card>
75
214
  ```
76
215
 
77
- The pile code is a separate module (`dist/pile-card.js`) that `<fuda-card>` loads only when a stack asks for `fan`, `taken-off` or `pile-controls`; a card without them is drawn exactly as before and never requests it.
216
+ The pile code is a separate module (`dist/pile-card.js`) that `<fuda-card>` loads only when a stack asks for `fan`, `taken-off` or `pile-controls`; a card without them is drawn exactly as before and never requests it. See [Binders and piles](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/binder-and-piles.md).
78
217
 
79
- ### Wear: cards that are not perfect
218
+ <picture>
219
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/fan-desk-dark.webp">
220
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/fan-desk-light.webp" alt="An open fan of ten cards.">
221
+ </picture>
222
+ <br><em>A stack fanned open.</em>
223
+
224
+ ## Wear: cards that are not perfect
80
225
 
81
226
  `wear="lightly-played"` draws the card after use: corners that are soft, rounded, chipped or folded (a dog-ear), whitening on the edges, creases, scratches, specks, staining, yellowing and a print that sits off centre. The presets are the plain grading terms: `mint`, `near-mint`, `lightly-played`, `moderately-played`, `heavily-played` and `damaged`; `perfect`, no attribute at all, or an unknown name draws nothing. `wear-seed` fixes where the marks lie, so a card looks the same every time it is drawn. `wear-corners`, `wear-edges`, `wear-surface` and `wear-creases` (0 to 1) change one kind on its own, and `wear="0.5"` sets them all at once.
82
227
 
83
228
  ```html
229
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
84
230
  <fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
85
231
  ```
86
232
 
87
- A perfect card is byte for byte what it was: the wear code is a separate module that `<fuda-card>` loads only when a card asks for wear. [docs/wear.md](docs/wear.md) has the sources for the grading words, the presets with their levels, how each mark is drawn and what is not drawn. The package exports `wearPresets`, `wearLayout`, `wearLevels`, `wearOutline` and `wearOverlaySvg` as plain data.
233
+ A perfect card is byte for byte what it was: the wear code is a separate module that `<fuda-card>` loads only when a card asks for wear. [docs/wear.md](docs/wear.md) has the sources for the grading words, the presets with their levels, how each mark is drawn and what is not drawn. The package exports `wearPresets`, `wearPreset`, `wearLayout`, `wearLevels`, `wearOutline` and `wearOverlaySvg` as plain data. See [Wear](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/wear.md).
234
+
235
+ <picture>
236
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/wear-desk-dark.webp">
237
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/wear-desk-light.webp" alt="A heavily played card with a folded corner, chipped edges, scratches and a crease.">
238
+ </picture>
239
+ <br><em>A heavily played card.</em>
88
240
 
89
- ### Whole-card rotation
241
+ ## Whole-card rotation
90
242
 
91
- Set `card-spin="center"` for a slow 3D turn around the card’s vertical center, or `card-spin="corner"` for a 3D spin like an ice skater: the card keeps its full size and turns a full 360° around the vertical axis through its bottom-left corner, which stays still at the middle of the element, and shows its back half way round. The card sweeps out to both sides of that point, so give it room (a stage about three times its width and twice its height). Both rotate the entire card, including either face and its content. The default is one turn every 180 seconds; set `--fuda-card-spin-duration` to a positive CSS duration such as `30s`. Set `card-spin-direction="reverse"` to reverse the rotation. Add `card-spin-paused` to pause at the current angle, and remove it to resume. Remove `card-spin` to stop and reset the rotation. These attributes are independent of the artwork `motion` and `playing` attributes and the card’s `flipped` state. Reduced-motion preferences disable the rotation and the flip transition.
243
+ Set `card-spin="center"` for a slow 3D turn around the card's vertical center, or `card-spin="corner"` for a 3D spin like an ice skater: the card keeps its full size and turns a full 360° around the vertical axis through its bottom-left corner, which stays still at the middle of the element, and shows its back half way round. The card sweeps out to both sides of that point, so give it room (a stage about three times its width and twice its height). The default is one turn every 180 seconds; set `--fuda-card-spin-duration` to a positive CSS duration such as `30s`. `card-spin-direction="reverse"` reverses the rotation, `card-spin-paused` pauses at the current angle, and removing `card-spin` stops and resets it. These attributes are independent of the artwork `motion` and `playing` attributes and the card's `flipped` state. Reduced-motion preferences disable the rotation and the flip transition.
92
244
 
93
- To drive the turn from your own controls instead of the built-in animation, add the boolean `card-view` attribute and set the CSS custom properties `--fuda-yaw` and `--fuda-tilt` (angles, for example `40deg`); the pivot is the one chosen by `card-spin`. The Card Studio does this with [`@johnmorrisdotca/kazoku-ui`](https://www.npmjs.com/package/@johnmorrisdotca/kazoku-ui) view controls (angle, tilt, Auto-turn, Front, zoom out, 2x, zoom in, Fit, pan, drag and pinch, kept in the address), which also zoom and move the whole stage so the full sweep can always be seen. That package is used by the demo only (a dev dependency); `<fuda-card>` itself has no dependencies. `--fuda-perspective` (default `1000px`) sets the card’s perspective.
245
+ To drive the turn from your own controls instead of the built-in animation, add the boolean `card-view` attribute and set the CSS custom properties `--fuda-yaw` and `--fuda-tilt` (angles, for example `40deg`); the pivot is the one chosen by `card-spin`. The Card Studio does this with [`@johnmorrisdotca/kazoku-ui`](https://www.npmjs.com/package/@johnmorrisdotca/kazoku-ui) view controls (angle, tilt, Auto-turn, Front, zoom out, 2x, zoom in, Fit, pan, drag and pinch, kept in the address). `--fuda-perspective` (default `1000px`) sets the card's perspective.
94
246
 
95
247
  ```html
248
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
96
249
  <fuda-card title="Explorer" card-spin="center" style="--fuda-card-spin-duration: 30s">
97
250
  <img src="rocket.jpg" alt="Explorer rocket">
98
251
  </fuda-card>
99
252
  ```
100
253
 
101
- To review, run `pnpm install` and `pnpm dev`, then open the Card Studio. Under **Card rotation**, choose **Rotate around center** or **Spin around bottom corner**. The view controls under the card turn and tip it (Angle, Tilt), start **Auto-turn**, and zoom with **−**, **2×**, **+** and **Fit** (Ctrl or Command with the wheel, or a pinch, also zoom; zoomed in, a drag or the arrows move the view). The Card Studio opens at full card size; **Fit** is one press away and shows the whole sweep, and the corner stays at the middle of the stage at every zoom. Choose **Fast** to see a full turn in eight seconds, and try the direction control and **Flip card**. Auto-turn does not start by itself when your operating system or browser asks for reduced motion. The spin is decorative; use the separate flip control to choose the face.
254
+ ## Moving artwork
102
255
 
103
- ### Moving artwork
104
-
105
- Set `motion="pan"` on a card containing a slotted `<img>` to enable the Animate button on a tall image. The button is a small play or pause mark in the corner of the art, drawn at half strength until you point at it or focus it; its hit target is 48 px square, its accessible name is "Animate the picture" and `aria-pressed` says whether the art is moving. By default the card starts on a still, cropped view; add the boolean `playing` attribute to start with motion. Tapping the button starts the pan, and tapping it again returns to the still. A host can add or remove `playing` to control the state. While the art moves the card also carries a `moving` attribute for styling (read-only: set `playing` or `autoplay` instead). Set `--fuda-focus-x` and `--fuda-focus-y` (for example `50%` and `20%`) to choose the focal point. Cards without the pan option show a still, fully visible image. `pan-direction="up"` starts at the bottom; the default is down. The image travels back and forth by default; set `pan-loop="restart"` to repeat in one direction. Set the CSS custom property `--fuda-pan-duration` (for example, `16s`) to control the duration of each pass. If the image is not taller than the window after filling its width, there may be no vertical distance to pan. Reduced-motion preferences disable the animation and preserve the focused still. This option applies to images; moving a 3D camera is a separate future integration owned by the viewer.
256
+ Set `motion="pan"` on a card containing a slotted `<img>` to enable the Animate button on a tall image. The button is a small play or pause mark in the corner of the art; its hit target is 48 px square, its accessible name is "Animate the picture" and `aria-pressed` says whether the art is moving. By default the card starts on a still, cropped view; add the boolean `playing` attribute to start with motion. A host can add or remove `playing` to control the state. Set `--fuda-focus-x` and `--fuda-focus-y` (for example `50%` and `20%`) to choose the focal point. `pan-direction="up"` starts at the bottom; the default is down. The image travels back and forth by default; set `pan-loop="restart"` to repeat in one direction. `--fuda-pan-duration` (for example, `16s`) sets each pass. If the image is not taller than the window after filling its width, there may be no vertical distance to pan.
106
257
 
107
258
  ```html
259
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
108
260
  <fuda-card title="Starship" motion="pan" pan-direction="down" style="--fuda-pan-duration: 16s">
109
261
  <img src="starship.jpg" alt="Starship">
110
262
  </fuda-card>
111
263
  ```
112
264
 
113
- **Autoplay when the card is in focus.** Add `autoplay="focus"` and the card moves its art by itself while it is the card in focus, with no tap on the button. One card is in focus at a time: the card under the mouse, the card that holds keyboard focus (Tab to its button), or, on a touch screen, the card you last tapped. When focus moves to another card, or the pointer leaves, or you tap or click somewhere else, the first card returns to its still, so in a row or a grid only one card ever moves. The button stays: press it to pause the focused card (it starts again the next time the card takes focus), and on a touch screen the first tap on it starts the card. `autoplay="focus"` never starts with `prefers-reduced-motion: reduce`. It does not set `playing`, so a host that sets `playing` still decides for itself. The Card Studio has an **Autoplay** choice.
265
+ **Autoplay when the card is in focus.** Add `autoplay="focus"` and the card moves its art by itself while it is the card in focus: the card under the mouse, the card that holds keyboard focus, or, on a touch screen, the card you last tapped. When focus moves, the first card returns to its still, so in a row or a grid only one card ever moves. It never starts with `prefers-reduced-motion: reduce`.
114
266
 
115
267
  ```html
268
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
116
269
  <fuda-card title="Starship" motion="pan" autoplay="focus">
117
270
  <img src="starship.jpg" alt="Starship">
118
271
  </fuda-card>
119
272
  ```
120
273
 
121
- Planned JSON, API, scanned-card and interactive-content inputs are outlined in [docs/collection-input.md](docs/collection-input.md).
274
+ All of it is in [Motion and rotation](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/motion-and-spin.md).
122
275
 
123
- ## Pokémon binder demo
276
+ ## Live 3D in a card
124
277
 
125
- Open `demo/tcgdex.html` through the local server to browse the Pokémon Base Set as full-card images supplied by [TCGdex](https://tcgdex.dev/). Search by name or number, change pages and select a card to enlarge it. The view controls under the binder page zoom in and out (−, 2×, +), **Fit** shows the whole page, and zoomed in you drag, use the arrows or the wheel to move. This standalone demo fetches public set data and remote images in the browser; it requires an internet connection. No API key, personal collection storage, or image hosting by Fuda is involved. A missing image or failed request is reported in the UI. Card images and metadata are provided by TCGdex; consult provider terms before deploying a public demo.
278
+ A card can hold a live 3D item (a rocket, a device) that turns while the card is in focus. **Only one card is ever live, on one WebGL context for the whole page; every other card is a picture, and a page of pictures loads no 3D code at all.** `three` is yours (an optional peer dependency) and loads at the first focus:
126
279
 
127
- ## Collection viewer
280
+ ```ts no-check
281
+ import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
128
282
 
129
- Run `pnpm dev` and open `/demo/collections-component.html`. Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage?, kind? }` (`kind` is `"card"`, the default, or `"object"`: a picture of a thing that is not a card, such as a games console, which has no back and no thickness and so never turns over; see `docs/collection-input.md`). Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique. Set `view` to `deck`, `rolodex`, `binder`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` (`jukebox` and `tower`, dropped in 0.8.0, still open the deck). Set `page-size` for the binder and case (1–100 cards) and `columns` (1–10) for their grid; small screens use at most two columns. In random view, filter card names to limit the draw; the draw button is disabled when no cards match.
283
+ const live = createLiveCards({ load: () => import('three') });
284
+ live.add(card, { key: 'cube', build({ three, assets, width, height }) { /* scene, camera, object */ } }, { still: card.querySelector('img') });
285
+ ```
130
286
 
131
- **Choosing a display.** The ten displays are a row of buttons across the top, each with a small picture of its layout and its name, at least 48 px high, one chosen, wrapping on a phone (4 to a row, 6 on a desk). It is a radio group: one tab stop, the arrow keys move the choice. There is no drop-down. The colours follow the reader's light or dark setting; set `theme="light"` or `theme="dark"` to choose for them.
287
+ On a `<fuda-collection>`: `collection.live = { cards: live, item: (card) => itemFor(card) }`. Budgets, the focus rules and what cannot be proved in a test are in [docs/live-3d.md](docs/live-3d.md) and the [live 3D guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/live-3d.md); try it in the [live demo](https://johnmorrisdotca.github.io/fuda-cards/demo/live-3d.html).
132
288
 
133
- **The deck, and the other piles.** Two displays draw a pile of cards, and each does everything a pile does: it turns in 3D, it fans open and closed, and a card comes off it onto a pile at its side. They are the Overlapping Deck (`view="deck"`) and Random Draw; the Fan of Cards is the same pile with only its fan. (Jukebox Carousel and Flip Tower drew the same pile of three cards, had no real counterpart for cards, and were dropped in 0.8.0.) Rolodex and Spotlight Carousel spread their cards out instead of piling them, so they are carousels and stay as they were. `view="deck"` draws a deck of up to ten cards (with a seeded, slightly messy lie: `deck-messiness` 0 to 1, default 0.3, and `deck-seed`) and, beside it, a pile. **Next** flips the top card off the deck: it lifts, flies across and lands on the pile at the deck's other side; **Previous** brings it back. Where it lands is a choice: `deck-land="face-up"` (still facing up, the default) or `face-down` ("Turned over": it turns over sideways about its vertical axis, like turning a page, so the pile shows the card's `backImage`, or the package's own navy back when it has none). A card never lands with its picture on its head. The 0.6.0 value `upside-down` is still accepted and means `face-down`. The same card element flies, so a card is never drawn twice; with reduced motion it moves without flying. **Rotate a pile**: a pile's view controls have the angle, tilt and Auto-turn (the other displays are flat), and the whole table, both piles, turns in 3D: seen from behind you see the backs of the deck and the faces of a face-down pile.
289
+ ## The collection viewer
134
290
 
135
- **The fan.** Every pile fans open and closes with the **Fan** buttons right under the view (or `fan="open"`): up to ten cards spread in an arc like a hand of playing cards so that most of each card shows, and closing puts each card back exactly where it started. The pile beside the deck moves out of the way and the view fits the open fan (a phone included). A card can still be taken off an open fan, and off a pile that was fanned and closed. `view="fan"` is the same pile with only its fan: `fan-size` (2 to 10) cards from the current one, Next moves the window on. The fan is in the address (`?fan=open`).
291
+ Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage?, kind? }` (`kind` is `"card"`, the default, or `"object"`: a picture of a thing that is not a card, such as a games console, which has no back and no thickness and so never turns over). Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique.
136
292
 
137
- **Animate.** Opening and closing the fan, taking a card off, moving to the next card (Rolodex, Spotlight, the fan), changing a binder page and switching display all move; the wall, story and atlas pan to the card you move to. `animate="off"` turns all of it off (every move then ends at once, in exactly the same place), and `speed="slow"` or `"quick"` makes every move longer or shorter. `animate` is **on** when the attribute is missing, as the flight of a card taken off already was in 0.6.0; set `animate="off"` for the jump you had before. The reader's reduced-motion setting always wins. Moves are CSS transforms and one-shot animations that end by themselves: nothing runs while the view is idle. The Animate and Speed buttons are under the view and in the address (`?animate=off&speed=quick`).
293
+ ```html
294
+ <fuda-collection view="deck"></fuda-collection>
295
+ <script type="module">
296
+ import '@johnmorrisdotca/fuda-cards/collection-element';
297
+ document.querySelector('fuda-collection').cards = [
298
+ { id: 'one', name: 'My card', image: '/cards/front.jpg', backImage: '/cards/back.jpg' }
299
+ ];
300
+ </script>
301
+ ```
138
302
 
139
- **Zoom, Fit and move in every view.** Under each view sit the `@johnmorrisdotca/kazoku-ui` view controls: **−**, **2×**, **+** and **Fit**, and, once zoomed in, four arrows to move the view. Ctrl or Command with the wheel (or a trackpad pinch) and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view, even when the drag starts on a card; the keys `+`, `−` and `0` work with the view focused. **Fit** shows every card the view draws (the whole binder or case page, every card of the wall, the story and the atlas). The wall, story and atlas open at half size or larger so a card can be read, and the others open at Fit. A tap or click on a card still opens it, and zooming, moving or paging never resets the other: turning to the next card or page keeps your zoom, and zooming keeps the card or page you are on. The piles (see above) also turn in 3D; the other displays use zoom and move only. Zoom itself is not animated. Add the boolean `address` attribute to keep the zoom, the display, the fan, the landing, Animate and Speed in the page address (`?view=fan&fan=open&land=face-down&zoom=2`); a link to it opens the same view. Set `--fuda-stage-height` on the element to change the height of the view (default: the window height less 440 px, between 300 and 620 px) so the controls stay on screen.
303
+ Check a list before handing it over: `parseCollection` is the same check the element runs.
140
304
 
141
- `@johnmorrisdotca/kazoku-ui` is a runtime dependency of the package (it was a development dependency until 0.2.0). Choice buttons, the light and dark colours and the address are written in the package, because kazoku-ui has no shared part for them yet. A bundler resolves it. On a plain HTML page without a bundler, add an import map next to the module script, with the package served from `node_modules` or a copy of its `dist`:
305
+ ```ts
306
+ import { parseCollection } from '@johnmorrisdotca/fuda-cards/collection';
142
307
 
143
- ```html
144
- <script type="importmap">{"imports":{"@johnmorrisdotca/kazoku-ui/view-controls/define":"/node_modules/@johnmorrisdotca/kazoku-ui/dist/view-controls/define.js"}}</script>
308
+ console.log(parseCollection([{ name: 'Alpha', image: '/a.jpg' }]).map((card) => card.id).join(' '));
309
+ // 0
145
310
  ```
146
311
 
312
+ Collections, kinds and metadata are in [Collections](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/collections.md); the planned input features are in [docs/collection-input.md](docs/collection-input.md).
313
+
314
+ ## Displays
315
+
316
+ Set `view` to `deck`, `rolodex`, `binder`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` (`jukebox` and `tower`, dropped in 0.8.0, still open the deck). Set `page-size` for the binder and case (1–100 cards) and `columns` (1–10) for their grid; small screens use at most two columns. In random view, filter card names to limit the draw; the draw button is disabled when no cards match.
317
+
318
+ **Choosing a display.** The ten displays are a row of buttons across the top, each with a small picture of its layout and its name, at least 48 px high, one chosen, wrapping on a phone (4 to a row, 6 on a desk). It is a radio group: one tab stop, the arrow keys move the choice. There is no drop-down. The colours follow the reader's light or dark setting; set `theme="light"` or `theme="dark"` to choose for them.
319
+
320
+ **The deck, and the other piles.** Two displays draw a pile of cards, and each does everything a pile does: it turns in 3D, it fans open and closed, and a card comes off it onto a pile at its side. They are the Overlapping Deck (`view="deck"`) and Random Draw; the Fan of Cards is the same pile with only its fan. Rolodex and Spotlight Carousel spread their cards out instead of piling them, so they are carousels. `view="deck"` draws a deck of up to ten cards (with a seeded, slightly messy lie: `deck-messiness` 0 to 1, default 0.3, and `deck-seed`) and, beside it, a pile. **Next** flips the top card off the deck: it lifts, flies across and lands on the pile at the deck's other side; **Previous** brings it back. Where it lands is a choice: `deck-land="face-up"` (the default) or `face-down` ("Turned over": it turns over sideways about its vertical axis, like turning a page, so the pile shows the card's `backImage`, or the package's own navy back when it has none). A card never lands with its picture on its head. The 0.6.0 value `upside-down` is still accepted and means `face-down`. With reduced motion a card moves without flying.
321
+
322
+ <picture>
323
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/deck-desk-dark.webp">
324
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/deck-desk-light.webp" alt="The deck display: a deck of cards with a pile beside it showing the backs of the cards taken off.">
325
+ </picture>
326
+ <br><em>The Overlapping Deck with a card turned over onto the pile.</em>
327
+
328
+ **The fan.** Every pile fans open and closes with the **Fan** buttons right under the view (or `fan="open"`): up to ten cards spread in an arc like a hand of playing cards so that most of each card shows, and closing puts each card back exactly where it started. The pile beside the deck moves out of the way and the view fits the open fan (a phone included). `view="fan"` is the same pile with only its fan: `fan-size` (2 to 10) cards from the current one, Next moves the window on. The fan is in the address (`?fan=open`).
329
+
330
+ **Animate.** Opening and closing the fan, taking a card off, moving to the next card (Rolodex, Spotlight, the fan), changing a binder page and switching display all move; the wall, story and atlas pan to the card you move to. `animate="off"` turns all of it off (every move then ends at once, in exactly the same place), and `speed="slow"` or `"quick"` makes every move longer or shorter. `animate` is **on** when the attribute is missing; set `animate="off"` for the jump you had in 0.6.0. The reader's reduced-motion setting always wins.
331
+
332
+ <picture>
333
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/wall-desk-dark.webp">
334
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/wall-desk-light.webp" alt="The sliding gallery wall display: cards hung in a row with the zoom bar under them.">
335
+ </picture>
336
+ <br><em>The Sliding Gallery Wall.</em>
337
+
338
+ ## Binder pages
339
+
340
+ `view="binder"` is a binder open on two facing sheets, as one is kept: each sheet is a page of clear plastic pockets (nine, three by three) with a slight sheen, one card sitting inside each pocket, on a clear or a black sheet, with a strip of punched holes down the edge that lies against the rings. Next and Previous turn the page: a leaf swings about the spine, bends as it goes and shows the pockets on its back, forwards and backwards. Options, each a row of buttons under the view and in the address: `binder="ring|zip"` (a ring binder, or a zip binder with its zipper and pull), `cover="green|black|teal|navy|red"` (a plain cover), `sheet="clear|black"` and `pockets="4|9|12"` (two by two, three by three, four across by three down). The older `page-size` and `columns` still work and set the pockets of a sheet. Clicking a card opens it.
341
+
147
342
  ```html
148
- <fuda-collection view="deck"></fuda-collection>
343
+ <fuda-collection view="binder" binder="zip" cover="navy" sheet="black" pockets="12"></fuda-collection>
149
344
  <script type="module">
150
345
  import '@johnmorrisdotca/fuda-cards/collection-element';
151
- document.querySelector('fuda-collection').cards = [
152
- { id: 'one', name: 'My card', image: '/cards/front.jpg', backImage: '/cards/back.jpg' }
153
- ];
346
+ document.querySelector('fuda-collection').cards = Array.from({ length: 30 }, (_, i) => ({ name: `Card ${i + 1}`, image: `/cards/${i + 1}.jpg` }));
154
347
  </script>
155
348
  ```
156
349
 
157
- These are early display prototypes: the case and rotating displays use CSS perspective rather than fully modeled 3D devices; the atlas is a zoomable, movable plane rather than an unbounded or virtualized canvas. The demo can save and load named collections in the current browser using localStorage; this is not account-based sync or a backup. Configurable case geometry, integrated 3D content, and full browser and accessibility testing remain to be completed. Zoom, Fit, move and pinch are tested in headless Chromium at a desk and a phone size (pinch with synthetic pointer events); a real phone, Safari and Firefox are not tested.
350
+ <picture>
351
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/binder-desk-dark.webp">
352
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/binder-desk-light.webp" alt="A ring binder open on two sheets of nine pockets each, with the binder, cover, sheet and pocket choices under it.">
353
+ </picture>
354
+ <br><em>The binder, with the choices under it.</em>
355
+
356
+ ## Zoom, Fit and move
357
+
358
+ Under each view sit the `@johnmorrisdotca/kazoku-ui` view controls: **−**, the zoom as a number (the one number on the bar, always the true one; a press goes back to Fit), **+** and **Fit**; **More** adds four arrows to move the view. Ctrl or Command with the wheel (or a trackpad pinch) and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view, even when the drag starts on a card; the keys `+`, `−` and `0` work with the view focused. **Fit** shows every card the view draws. The wall, story and atlas open at half size or larger so a card can be read, and the others open at Fit. A tap or click on a card still opens it, and zooming, moving or paging never resets the other. Add the boolean `address` attribute to keep the zoom, the display, the fan, the landing, Animate and Speed in the page address (`?view=fan&fan=open&land=face-down&zoom=2`); a link to it opens the same view. Set `--fuda-stage-height` on the element to change the height of the view (default: the window height less 440 px, between 300 and 620 px) so the controls stay on screen.
359
+
360
+ ## Frameworks
361
+
362
+ Set `cards` as a property in every framework, import the registration module only in the browser, and give your compiler the tag. React:
363
+
364
+ ```jsx
365
+ import { useEffect, useRef } from 'react';
366
+ import '@johnmorrisdotca/fuda-cards/collection-element';
367
+
368
+ export function Cards({ cards }) {
369
+ const ref = useRef(null);
370
+ useEffect(() => { if (ref.current) ref.current.cards = cards; }, [cards]);
371
+ return <fuda-collection ref={ref} view="binder" />;
372
+ }
373
+ ```
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.
376
+
377
+ ## Demos
378
+
379
+ [Open the Fuda Cards demos](https://johnmorrisdotca.github.io/fuda-cards/). The Card Studio, the collection views, the Pokémon binder, the vintage cards and the live 3D page are built together for GitHub Pages. Run `pnpm site` to build the static site in `site/`; serve that directory to review it. The Pages workflow runs the checks and deploys the site on pushes to `main`.
380
+
381
+ **Builder.** [`demo/builder.html`](https://johnmorrisdotca.github.io/fuda-cards/demo/builder.html) is a page to choose a card or a collection, see it live and copy the HTML, React or Vue code for it. Every choice is a row of buttons, and the setup is kept in the link.
382
+
383
+ **Pokémon binder.** `demo/tcgdex.html` browses the Pokémon Base Set as full-card images supplied by [TCGdex](https://tcgdex.dev/). Search by name or number, change pages and select a card to enlarge it. This standalone demo fetches public set data and remote images in the browser, so it needs an internet connection. No API key, personal collection storage, or image hosting by Fuda is involved. Card images and metadata are provided by TCGdex; consult provider terms before deploying a public demo.
384
+
385
+ **Vintage cards.** `demo/vintage.html` shows real 1909 to 1911 hockey and baseball cards whose pictures are in the public domain (Wikimedia Commons and The Met's Open Access, each card's rights checked one by one), loaded from their sources and never shipped; [docs/card-images.md](docs/card-images.md) says what card-picture sources exist, their terms and what was not used.
386
+
387
+ **Demo collectors.** The collection demo has three fictional users, Alex, Sam and Riley, with different collections: Alex has 25 Base Set cards (a 5 by 5 page), Sam a pack of 10 and Riley 5 consoles. They are local demo profiles, not accounts. The demo can save, load and export named collections in the current browser's localStorage, scoped to the selected profile; this is not account-based sync or a backup.
388
+
389
+ <picture>
390
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/vintage-desk-dark.webp">
391
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/vintage-desk-light.webp" alt="The vintage cards demo showing real 1910 hockey cards in the display case.">
392
+ </picture>
393
+ <br><em>The vintage cards demo.</em>
394
+
395
+ ## Theming
396
+
397
+ A collection follows the reader's light or dark setting; `theme="light"` or `theme="dark"` chooses for them. The card is sized by its width and styled through custom properties (`--fuda-edge`, `--fuda-perspective`, `--fuda-pan-duration`, `--fuda-card-spin-duration`, `--fuda-yaw`, `--fuda-tilt`, `--fuda-focus-x`, `--fuda-focus-y`) and a collection's view height by `--fuda-stage-height`. The frame's look is `variant` and `finish`.
398
+
399
+ ```html
400
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
401
+ <style>fuda-card.brass { width: 220px; --fuda-edge: linear-gradient(90deg, #d9b45a, #8a6a22 50%, #d9b45a); --fuda-perspective: 1600px; }</style>
402
+ <fuda-card class="brass" title="Brass edge" thickness="2"></fuda-card>
403
+ ```
404
+
405
+ The list, with the default of each, is in [Accessibility and theming](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/accessibility-and-theming.md).
406
+
407
+ ## Accessibility
408
+
409
+ The display choices are a radio group with arrow keys; a card in a display is a button named "Inspect" and its name, opened with Enter or Space; every control is at least 48 px; the zoom keys are `+`, `-` and `0`; and with reduced motion the rotation, flip transition, pan, autoplay and live 3D are off while every move still ends in the same place. You supply the `alt` of your pictures. Tested in headless Chromium at a desk and a phone size; see the limits below.
410
+
411
+ ## Limits
412
+
413
+ - **Early prototype.** Classic, sport and cosmic are exploratory CSS designs, not historically researched recreations or photorealistic materials. The case and rotating displays use CSS perspective rather than fully modelled 3D devices; the atlas is a zoomable, movable plane rather than an unbounded or virtualised canvas.
414
+ - **Tested in headless Chromium only,** drawing in software, at a desk and a phone size. A real phone, Safari and Firefox are not tested, and nothing measures a real GPU.
415
+ - **Wear** is not drawn on the images of a collection or on the cards under a stack's top card.
416
+ - **Images are yours.** Fuda hosts none; a missing image or failed request is reported in the demo's page.
417
+ - **Not built yet:** framework wrappers, scanned-card and JSON importers, search and filters, editing, large-collection virtualisation and accessibility validation by assistive-technology testing. [docs/feature-roadmap.md](docs/feature-roadmap.md) says what is partial and what is not started.
418
+
419
+ ## Browser and runtime support
420
+
421
+ Current Chromium-based browsers are what is tested. The elements use custom elements, shadow DOM, CSS 3D transforms, container queries (`cqw`) and `:where`, which every current browser supports; Firefox and Safari are expected to work and are not tested. Node 22 or later is needed only to build and test, never to use the package. WebGL is needed only for live 3D, and the cards stay pictures without it. To load the elements only where custom elements exist:
422
+
423
+ ```ts no-run
424
+ if ('customElements' in window) {
425
+ await import('@johnmorrisdotca/fuda-cards/element');
426
+ }
427
+ ```
428
+
429
+ ## Languages
430
+
431
+ The elements' own words (button names, labels) are English today. The documentation is in English and Japanese: every guide in [docs/guides](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides) has a Japanese twin in [docs/guides/ja](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/ja). Text on a card (title, subtitle, description) is whatever you give it in any language, and the page's language does not change it.
432
+
433
+ ```html
434
+ <script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
435
+ <fuda-card title="エクスプローラー・ワン" category="ロケット" subtitle="新しい探査機" description="高さ124.4 m、直径9 m。"></fuda-card>
436
+ ```
437
+
438
+ ## Roadmap
439
+
440
+ Open work, in order of what a user would notice: framework wrappers; JSON, API and scanned-card importers and filters; the Hako Devices and Uchusen Rockets viewers inside card artwork; researched card designs for the recognisable families of the past century; configurable case geometry; large-collection virtualisation; and testing on a real phone, Safari and Firefox. The detail, with each item's status, is [docs/feature-roadmap.md](docs/feature-roadmap.md).
441
+
442
+ ## Architecture
443
+
444
+ `element.js` is the card and loads the wear, pile and stack code only when a card asks for them; `collection-element.js` draws the ten displays; `live-3d.js` is the focus policy for one WebGL context. A page pays only for what it uses. The files and their sizes are in the [architecture guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md).
445
+
446
+ ## Documentation
447
+
448
+ | Guide | What it covers |
449
+ |---|---|
450
+ | [Getting started](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/getting-started.md) | A first card, a stack, a worn card and a collection |
451
+ | [The card element](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/card-element.md) | Every attribute, property and CSS variable |
452
+ | [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md) | Thickness, thirteen sourced materials, stacks |
453
+ | [Wear](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/wear.md) | Presets, the seed, wear as data |
454
+ | [Motion and rotation](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/motion-and-spin.md) | Pan, autoplay, spin, driving the turn |
455
+ | [Collections](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/collections.md) | The element, the input, kinds, ten displays |
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
+ | [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 |
459
+ | [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
+ | [Architecture](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md) | The modules and why |
461
+ | [Troubleshooting and FAQ](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/troubleshooting.md) | A blank card, a flash, a missing bar |
462
+ | [Upgrading](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/upgrading.md) | What each version asks of you |
463
+
464
+ Every guide has a Japanese twin (日本語) in [docs/guides/ja](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/ja). The reference for every export is [docs/API.md](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/API.md), written from the built declarations. Design notes: [feature roadmap](docs/feature-roadmap.md) · [work log](docs/work-log.md).
465
+
466
+ ## Development
467
+
468
+ Requires Node 22+ and pnpm. Run `pnpm install`, `pnpm check`, then `pnpm dev` and open http://localhost:8100. `pnpm build` emits JavaScript and TypeScript declarations to `dist/`.
469
+
470
+ ```sh
471
+ pnpm check # typecheck, build, unit tests
472
+ pnpm test:e2e # the browser tests (headless Chromium, in software)
473
+ pnpm test:readme # every README and guide example, run (Node and a browser)
474
+ pnpm docs:api # rewrite docs/API.md from the built declarations
475
+ pnpm docs:check # the reference is current, the Japanese twins and links hold
476
+ pnpm screenshots:readme # retake docs/images, the thumbnail, dark thumbnail and icon too
477
+ ```
478
+
479
+ ## Contributing
480
+
481
+ Read [AGENTS.md](AGENTS.md) for how work is done here: a board ticket for each change, a worktree, Conventional Commits, and the checks above before every push. Browsers in the tests are started only through `launch()` in `test/e2e/support.mjs`, headless and in software. Documentation changes go with the code that makes them true: a changed attribute changes its guide, its Japanese twin and the changelog in the same change.
158
482
 
159
- Saved demo collections are scoped to the selected profile. Use “Import older saved collections” to copy pre-profile saves without overwriting same-named collections; the originals remain intact. The demo supports JSON export and deletion, and storage stays local to this browser.
483
+ ## Changes
160
484
 
161
- `demo/vintage.html` shows real 1909 to 1911 hockey and baseball cards whose pictures are in the public domain (Wikimedia Commons and The Met's Open Access, each card's rights checked one by one), loaded from their sources and never shipped; [docs/card-images.md](docs/card-images.md) says what card-picture sources exist, their terms and what was not used (no free hockey or baseball card API with pictures was found).
485
+ Every release, dated, is in [CHANGELOG.md](CHANGELOG.md).
162
486
 
163
- The collection component demo includes three fictional demo users—Alex, Sam, and Riley—with different example collections: Alex has 25 Base Set cards (a 5 by 5 page), Sam a pack of 10 and Riley 5 consoles. Select a user to switch the displayed cards. These are local demo profiles, not accounts; the existing named-collection save/load remains local to the browser and separate from the demo profiles.
487
+ ## Licence
164
488
 
165
- Development priorities and handoff notes: [feature roadmap](docs/feature-roadmap.md) · [work log](docs/work-log.md).
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).