@johnmorrisdotca/fuda-cards 0.9.2 → 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.
- package/LICENSE +21 -0
- package/NOTICE.md +14 -0
- package/README.md +466 -60
- package/dist/binder.d.ts +4 -6
- package/dist/binder.js +32 -23
- package/dist/card-markup.d.ts +2 -0
- package/dist/card-markup.js +59 -0
- package/dist/card-options.d.ts +131 -0
- package/dist/card-options.js +48 -0
- package/dist/card-styles.d.ts +2 -0
- package/dist/card-styles.js +314 -0
- package/dist/choice.d.ts +1 -1
- package/dist/choice.js +27 -23
- package/dist/collection-address.d.ts +8 -0
- package/dist/collection-address.js +52 -0
- package/dist/collection-binder-view.d.ts +9 -0
- package/dist/collection-binder-view.js +123 -0
- package/dist/collection-controls.d.ts +2 -0
- package/dist/collection-controls.js +143 -0
- package/dist/collection-deck.d.ts +11 -0
- package/dist/collection-deck.js +165 -0
- package/dist/collection-dialog.d.ts +2 -0
- package/dist/collection-dialog.js +28 -0
- package/dist/collection-element.d.ts +41 -63
- package/dist/collection-element.js +288 -472
- package/dist/collection-host.d.ts +5 -0
- package/dist/collection-host.js +1 -0
- package/dist/collection-icons.d.ts +3 -0
- package/dist/collection-icons.js +19 -0
- package/dist/collection-motion.d.ts +11 -0
- package/dist/collection-motion.js +72 -0
- package/dist/collection-styles.d.ts +4 -0
- package/dist/collection-styles.js +336 -0
- package/dist/collection-views.d.ts +8 -0
- package/dist/collection-views.js +8 -0
- package/dist/collection.d.ts +140 -11
- package/dist/collection.js +139 -33
- package/dist/element-define.d.ts +2 -0
- package/dist/element-define.js +3 -0
- package/dist/element.d.ts +20 -1
- package/dist/element.js +289 -98
- package/dist/index.d.ts +9 -52
- package/dist/index.js +5 -5
- package/dist/live-3d.d.ts +126 -0
- package/dist/live-3d.js +229 -0
- package/dist/materials.d.ts +117 -6
- package/dist/materials.js +191 -28
- package/dist/motion.d.ts +2 -0
- package/dist/motion.js +4 -0
- package/dist/pile-card.js +138 -91
- package/dist/pile.d.ts +61 -8
- package/dist/pile.js +89 -29
- package/dist/stack.d.ts +42 -6
- package/dist/stack.js +28 -3
- package/dist/version.d.ts +11 -0
- package/dist/version.js +11 -0
- package/dist/wear.d.ts +147 -9
- package/dist/wear.js +273 -89
- package/dist/zoom.d.ts +1 -1
- package/dist/zoom.js +73 -42
- package/docs/API.md +783 -0
- package/docs/collection-displays.md +1 -1
- package/docs/guides/accessibility-and-theming.md +62 -0
- package/docs/guides/architecture.md +53 -0
- package/docs/guides/binder-and-piles.md +83 -0
- package/docs/guides/bundlers.md +60 -0
- package/docs/guides/card-element.md +65 -0
- package/docs/guides/collections.md +86 -0
- package/docs/guides/embed-in-an-iframe.md +39 -0
- package/docs/guides/frameworks.md +132 -0
- package/docs/guides/getting-started.md +96 -0
- package/docs/guides/html-and-cdn.md +69 -0
- package/docs/guides/ja/accessibility-and-theming.md +62 -0
- package/docs/guides/ja/architecture.md +53 -0
- package/docs/guides/ja/binder-and-piles.md +83 -0
- package/docs/guides/ja/bundlers.md +60 -0
- package/docs/guides/ja/card-element.md +65 -0
- package/docs/guides/ja/collections.md +86 -0
- package/docs/guides/ja/embed-in-an-iframe.md +39 -0
- package/docs/guides/ja/frameworks.md +132 -0
- package/docs/guides/ja/getting-started.md +96 -0
- package/docs/guides/ja/html-and-cdn.md +69 -0
- package/docs/guides/ja/live-3d.md +75 -0
- package/docs/guides/ja/materials-and-stacks.md +73 -0
- package/docs/guides/ja/motion-and-spin.md +73 -0
- package/docs/guides/ja/troubleshooting.md +60 -0
- package/docs/guides/ja/typescript-and-node.md +45 -0
- package/docs/guides/ja/upgrading.md +56 -0
- package/docs/guides/ja/wear.md +63 -0
- package/docs/guides/live-3d.md +75 -0
- package/docs/guides/materials-and-stacks.md +73 -0
- package/docs/guides/motion-and-spin.md +73 -0
- package/docs/guides/troubleshooting.md +60 -0
- package/docs/guides/typescript-and-node.md +45 -0
- package/docs/guides/upgrading.md +56 -0
- package/docs/guides/wear.md +63 -0
- package/docs/live-3d.md +59 -0
- package/package.json +81 -11
package/README.md
CHANGED
|
@@ -1,165 +1,571 @@
|
|
|
1
|
-
|
|
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
|
+
`<fuda-card>` frames a picture or a live 3D viewer; `<fuda-collection>` 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
|
+
```
|
|
45
|
+
|
|
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
|
+
```
|
|
2
54
|
|
|
3
|
-
|
|
55
|
+
And the tables behind it, in script, with no page at all:
|
|
4
56
|
|
|
5
|
-
|
|
57
|
+
```ts
|
|
58
|
+
import { cardMaterial, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
|
|
6
59
|
|
|
7
|
-
|
|
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
|
+
```
|
|
8
68
|
|
|
9
|
-
|
|
69
|
+
## Who it is for
|
|
10
70
|
|
|
11
|
-
|
|
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.
|
|
12
75
|
|
|
13
|
-
|
|
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
|
+
```
|
|
94
|
+
|
|
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.
|
|
14
100
|
|
|
15
|
-
|
|
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](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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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>
|
|
125
|
+
```
|
|
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 [HTML and CDN guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/html-and-cdn.md) has the whole map.
|
|
128
|
+
|
|
129
|
+
## Examples
|
|
130
|
+
|
|
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`.
|
|
132
|
+
|
|
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
|
+
```
|
|
139
|
+
|
|
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>
|
|
23
148
|
```
|
|
24
149
|
|
|
25
|
-
|
|
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`.
|
|
26
153
|
|
|
27
|
-
|
|
154
|
+
```ts
|
|
155
|
+
import { cardFinishes, cardVariants } from '@johnmorrisdotca/fuda-cards';
|
|
28
156
|
|
|
29
|
-
|
|
157
|
+
console.log(cardVariants.join(' '), cardFinishes.join(' '));
|
|
158
|
+
// classic sport cosmic foil matte
|
|
159
|
+
```
|
|
30
160
|
|
|
31
|
-
|
|
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).
|
|
32
162
|
|
|
33
|
-
|
|
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
|
-
|
|
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
|
-
The card has thickness, drawn to scale at the 63 mm wide card size: set `thickness` in millimetres (default `0.
|
|
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.
|
|
48
178
|
|
|
49
179
|
```html
|
|
50
|
-
<
|
|
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
|
-
|
|
184
|
+

|
|
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
|
-
`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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
205
|
+
More in [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md).
|
|
68
206
|
|
|
69
|
-
|
|
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).
|
|
217
|
+
|
|
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>
|
|
78
223
|
|
|
79
|
-
|
|
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).
|
|
88
234
|
|
|
89
|
-
|
|
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>
|
|
90
240
|
|
|
91
|
-
|
|
241
|
+
## Whole-card rotation
|
|
92
242
|
|
|
93
|
-
|
|
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.
|
|
244
|
+
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
### Moving artwork
|
|
254
|
+
## Moving artwork
|
|
104
255
|
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
##
|
|
276
|
+
## Live 3D in a card
|
|
124
277
|
|
|
125
|
-
|
|
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
|
-
|
|
280
|
+
```ts no-check
|
|
281
|
+
import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
|
|
128
282
|
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
289
|
+
## The collection viewer
|
|
134
290
|
|
|
135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
303
|
+
Check a list before handing it over: `parseCollection` is the same check the element runs.
|
|
140
304
|
|
|
141
|
-
|
|
305
|
+
```ts
|
|
306
|
+
import { parseCollection } from '@johnmorrisdotca/fuda-cards/collection';
|
|
142
307
|
|
|
143
|
-
|
|
144
|
-
|
|
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="
|
|
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
|
-
|
|
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 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
|
+
|
|
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
|
+
| [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 |
|
|
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 |
|
|
464
|
+
| [Architecture](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md) | The modules and why |
|
|
465
|
+
| [Troubleshooting and FAQ](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/troubleshooting.md) | A blank card, a flash, a missing bar |
|
|
466
|
+
| [Upgrading](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/upgrading.md) | What each version asks of you |
|
|
467
|
+
|
|
468
|
+
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).
|
|
469
|
+
|
|
470
|
+
## Development
|
|
471
|
+
|
|
472
|
+
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/`.
|
|
473
|
+
|
|
474
|
+
```sh
|
|
475
|
+
pnpm check # typecheck, build, unit tests
|
|
476
|
+
pnpm test:e2e # the browser tests (headless Chromium, in software)
|
|
477
|
+
pnpm test:readme # every README and guide example, run (Node and a browser)
|
|
478
|
+
pnpm docs:api # rewrite docs/API.md from the built declarations
|
|
479
|
+
pnpm docs:check # the reference is current, the Japanese twins and links hold
|
|
480
|
+
pnpm screenshots:readme # retake docs/images, the thumbnail, dark thumbnail and icon too
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## Contributing
|
|
484
|
+
|
|
485
|
+
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.
|
|
486
|
+
|
|
487
|
+
## Changes
|
|
488
|
+
|
|
489
|
+
Every release, dated, is in [CHANGELOG.md](CHANGELOG.md).
|
|
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/).
|
|
158
564
|
|
|
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.
|
|
160
565
|
|
|
161
|
-
|
|
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 -->
|
|
162
568
|
|
|
163
|
-
|
|
569
|
+
## Licence
|
|
164
570
|
|
|
165
|
-
|
|
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.
|