@johnmorrisdotca/fuda-cards 0.10.1 → 0.12.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 +16 -0
- package/README.md +106 -33
- 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 +36 -67
- package/dist/collection-element.js +283 -484
- 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 +154 -11
- package/dist/collection.js +140 -34
- 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 +87 -4
- package/dist/live-3d.js +120 -52
- package/dist/materials.d.ts +117 -6
- package/dist/materials.js +246 -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 +138 -134
- package/docs/collection-displays.md +4 -4
- package/docs/collection-input.md +5 -5
- package/docs/framework-integration.md +1 -1
- package/docs/guides/architecture.md +8 -8
- package/docs/guides/bundlers.md +60 -0
- package/docs/guides/card-element.md +26 -2
- package/docs/guides/collections.md +2 -2
- package/docs/guides/embed-in-an-iframe.md +39 -0
- package/docs/guides/frameworks.md +93 -66
- package/docs/guides/getting-started.md +4 -2
- package/docs/guides/html-and-cdn.md +86 -0
- package/docs/guides/ja/architecture.md +4 -4
- package/docs/guides/ja/bundlers.md +60 -0
- package/docs/guides/ja/card-element.md +26 -2
- package/docs/guides/ja/collections.md +2 -2
- package/docs/guides/ja/embed-in-an-iframe.md +39 -0
- package/docs/guides/ja/frameworks.md +93 -66
- package/docs/guides/ja/getting-started.md +4 -2
- package/docs/guides/ja/html-and-cdn.md +86 -0
- package/docs/guides/ja/live-3d.md +37 -24
- package/docs/guides/ja/materials-and-stacks.md +4 -4
- package/docs/guides/ja/troubleshooting.md +2 -2
- package/docs/guides/ja/typescript-and-node.md +45 -0
- package/docs/guides/ja/upgrading.md +7 -2
- package/docs/guides/ja/wear.md +1 -1
- package/docs/guides/live-3d.md +37 -24
- package/docs/guides/materials-and-stacks.md +4 -4
- package/docs/guides/troubleshooting.md +2 -2
- package/docs/guides/typescript-and-node.md +45 -0
- package/docs/guides/upgrading.md +7 -2
- package/docs/guides/wear.md +1 -1
- package/docs/live-3d.md +1 -18
- package/docs/materials.md +15 -11
- package/docs/wear.md +4 -12
- package/package.json +57 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John Morris
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Third-party material
|
|
2
|
+
|
|
3
|
+
The code of Fuda Cards is MIT licensed (see [LICENSE](LICENSE)). Nothing below is part of the published npm package except where it says so; it is the pictures and data the repository and its demo pages use, with sources and licences at the dates recorded in the notes.
|
|
4
|
+
|
|
5
|
+
| What | Where | Source and licence |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Starship Block 3 picture (`assets/starship-v3-preview.jpg`, `assets/uchusen-main-painted.jpg`) | The repository and the demo pages; not in the npm package | A screenshot of John Morris's uchusen-rockets, which draws a modified model by Clarence365: <https://sketchfab.com/3d-models/spacex-starship-block-3-6f6c6f88a3eb4b4d822fdca66733fbb2>, licensed **CC BY 4.0**. The model was reduced, rescaled, separated into parts, and had logos and serial numbers removed. The credit is also in [assets/README.md](assets/README.md), which is in the npm package. |
|
|
8
|
+
| Rockets of the live 3D demo | `demo/live-3d.html`, loaded from `@johnmorrisdotca/uchusen-rockets` (a development dependency) | MIT, John Morris. Their models carry their own credits in that package. |
|
|
9
|
+
| Vintage baseball cards | `demo/vintage-baseball.js` keeps only addresses and credits; the pictures load from The Metropolitan Museum of Art when the demo opens | The Met's Open Access collection (the Jefferson R. Burdick Collection), each object marked public domain by the Met (checked 2026-11-02). |
|
|
10
|
+
| Vintage hockey cards | `demo/vintage-hockey.js` keeps only addresses and credits; the pictures load from Wikimedia Commons | 1910-11 Imperial Tobacco Canada cards, each file marked public domain on its Commons page (checked 2026-11-02). |
|
|
11
|
+
| Pokémon Base Set card pictures and data | `demo/tcgdex.html` loads them from TCGdex when the demo opens; none is stored here | Supplied by [TCGdex](https://tcgdex.dev/). The card artwork and the Pokémon names are the property of their owners (Nintendo, Creatures, GAME FREAK, The Pokémon Company) and are shown in the demo only as an example of a collection; they are not licensed by this project and are not in the package. |
|
|
12
|
+
| Card thicknesses and deck sizes | `src/materials.ts`, `docs/materials.md` | Facts read from the makers' and standards' own pages, each cited with its address. No text or table was copied. |
|
|
13
|
+
| Historical card sizes | `docs/card-images.md` and the card element guides | Sheet sizes of two public-domain objects in the Met's Jefferson R. Burdick Collection, read from the Met's object API (checked 2026-12-06). The guide examples use original drawings. |
|
|
14
|
+
| Wear terminology and visual references | `docs/wear.md` | TCGplayer's Card Conditioning Overview and PSA's Grading Standards and Grader Notes, checked 2026-12-06. Fuda defines its own drawing presets. |
|
|
15
|
+
|
|
16
|
+
The card designs, the wear marks, the binder and every other picture drawn by the package are drawn in code from public facts and are MIT licensed with the rest.
|
package/README.md
CHANGED
|
@@ -55,11 +55,11 @@ npm install @johnmorrisdotca/fuda-cards
|
|
|
55
55
|
And the tables behind it, in script, with no page at all:
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
import { cardMaterial, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
|
|
58
|
+
import { cardMaterial, DEFAULT_CARD_THICKNESS_MM, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
|
|
59
59
|
|
|
60
60
|
const stock = cardMaterial('paper-310-black-core');
|
|
61
61
|
console.log(stock?.name, stock?.thicknessMm);
|
|
62
|
-
console.log(stackHeightMm(52, stock?.thicknessMm ??
|
|
62
|
+
console.log(stackHeightMm(52, stock?.thicknessMm ?? DEFAULT_CARD_THICKNESS_MM));
|
|
63
63
|
console.log(wearPresets.map((preset) => preset.id).join(' '));
|
|
64
64
|
// Playing-card stock, black core, 310 gsm (13 pt) 0.325
|
|
65
65
|
// 16.9
|
|
@@ -76,7 +76,7 @@ console.log(wearPresets.map((preset) => preset.id).join(' '));
|
|
|
76
76
|
## Features
|
|
77
77
|
|
|
78
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.**
|
|
79
|
+
- **Sourced materials.** Seventeen materials with cited thicknesses, including paper stocks, plastics and metals.
|
|
80
80
|
- **Stacks.** One card to a thousand, as high as the count times the thickness, a seeded messiness.
|
|
81
81
|
- **Wear.** Six grading presets, a seed, and one dial for corners, edges, surface and creases.
|
|
82
82
|
- **Motion.** A pan over a tall picture, autoplay on the card in focus, a spin about the centre or a corner.
|
|
@@ -103,14 +103,14 @@ import '@johnmorrisdotca/fuda-cards/element';
|
|
|
103
103
|
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
104
104
|
import type { CardOptions } from '@johnmorrisdotca/fuda-cards';
|
|
105
105
|
|
|
106
|
-
const options: CardOptions = { title: '
|
|
106
|
+
const options: CardOptions = { title: 'Thick card', thickness: 1.5, wear: 'near-mint' };
|
|
107
107
|
const card = document.createElement('fuda-card');
|
|
108
108
|
card.setAttribute('title', options.title ?? '');
|
|
109
109
|
card.setAttribute('thickness', String(options.thickness));
|
|
110
110
|
document.body.append(card);
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
The main entry, `@johnmorrisdotca/fuda-cards`, exports only the options types and the tables (variants, finishes, materials, stack presets, wear presets and their maths) and registers nothing, so it is safe on a server. Frameworks may need a custom-element setting (Angular's `CUSTOM_ELEMENTS_SCHEMA`, Vue's `isCustomElement`): see [Frameworks
|
|
113
|
+
The main entry, `@johnmorrisdotca/fuda-cards`, exports only the options types and the tables (variants, finishes, materials, stack presets, wear presets and their maths) and registers nothing, so it is safe on a server. Frameworks may need a custom-element setting (Angular's `CUSTOM_ELEMENTS_SCHEMA`, Vue's `isCustomElement`): see [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md).
|
|
114
114
|
|
|
115
115
|
## Use it anywhere
|
|
116
116
|
|
|
@@ -124,7 +124,7 @@ With no bundler, serve the package's `dist` folder and point a module script at
|
|
|
124
124
|
<fuda-card title="Anywhere"></fuda-card>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
`<fuda-collection>` imports kazoku-ui's zoom bar, so it also needs `@johnmorrisdotca/kazoku-ui/view-controls/define` in the import map; the [
|
|
127
|
+
`<fuda-collection>` imports kazoku-ui's zoom bar, so it also needs `@johnmorrisdotca/kazoku-ui/view-controls/define` in the import map; the [HTML and CDN guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/html-and-cdn.md) has the whole map.
|
|
128
128
|
|
|
129
129
|
## Examples
|
|
130
130
|
|
|
@@ -132,7 +132,7 @@ A card with a back and a thick edge, a deck, a worn card, a collection. Each of
|
|
|
132
132
|
|
|
133
133
|
```html
|
|
134
134
|
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
135
|
-
<fuda-card title="
|
|
135
|
+
<fuda-card title="Thick card" thickness="1.5"></fuda-card>
|
|
136
136
|
<fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
|
|
137
137
|
<fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
|
|
138
138
|
```
|
|
@@ -149,7 +149,7 @@ A card with a back and a thick edge, a deck, a worn card, a collection. Each of
|
|
|
149
149
|
|
|
150
150
|
## The card
|
|
151
151
|
|
|
152
|
-
`<fuda-card>` has the attributes `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.
|
|
152
|
+
`<fuda-card>` has the attributes `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.325`), `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
153
|
|
|
154
154
|
```ts
|
|
155
155
|
import { cardFinishes, cardVariants } from '@johnmorrisdotca/fuda-cards';
|
|
@@ -174,20 +174,20 @@ It keeps `<fuda-card>` (300 px wide, 2.5:3.5, or whatever width your own rule gi
|
|
|
174
174
|
|
|
175
175
|
A card turned past 90° shows its back (the navy FUDA face), never the mirrored front, and the front's Animate button cannot be seen or clicked from behind. The back is the card's own face and is shown for `flipped` too.
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
Set `thickness` in millimetres or pick a `material`. The default, `DEFAULT_CARD_THICKNESS_MM`, is 0.325 mm, based on 13 pt black-core playing-card stock. Use `thickness="0"` for a flat card. Thin planes between the two faces form the edge, which scales with the element’s width. At the default thickness, the edge of a 300 px card is about 1.5 px thick. Override the edge with the `--fuda-edge` CSS custom property, which accepts any CSS background. Apply any `filter` outside the card’s 3D scene to preserve the two faces.
|
|
178
178
|
|
|
179
179
|
```html
|
|
180
180
|
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
181
|
-
<fuda-card title="
|
|
181
|
+
<fuda-card title="Thick card" thickness="1.5" flipped></fuda-card>
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|

|
|
185
185
|
|
|
186
186
|
## Materials and stacks
|
|
187
187
|
|
|
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,
|
|
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, plastic bank-size and PVC playing cards, thick trading cards from 35 to 180 pt, a 175 pt booklet card, and aluminium, stainless steel, brass, copper and titanium. `thickness` still overrides it. [docs/materials.md](docs/materials.md) lists every material, its thickness, its source and what the source says, and what was left out because it could not be sourced (a patch or relic card, for one).
|
|
189
189
|
|
|
190
|
-
`stack="52"` draws that many cards as a stack whose height is the count times a card's thickness (52 cards of the black-core playing-card stock are 16.9 mm
|
|
190
|
+
`stack="52"` draws that many cards as a stack whose height is the count times a card's thickness (52 cards of the black-core playing-card stock are 16.9 mm). The count is free, 1 to 1000; the Card Studio has presets with a source (52 playing cards, 52 and two jokers, a 60-card Pokémon deck, a booster pack of 10). Turn the card to see the stack's edge, with a line for each card in the material's colour.
|
|
191
191
|
|
|
192
192
|
```html
|
|
193
193
|
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
@@ -275,20 +275,11 @@ All of it is in [Motion and rotation](https://github.com/johnmorrisdotca/fuda-ca
|
|
|
275
275
|
|
|
276
276
|
## Live 3D in a card
|
|
277
277
|
|
|
278
|
-
A card can hold a live 3D item (
|
|
279
|
-
|
|
280
|
-
```ts no-check
|
|
281
|
-
import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
|
|
282
|
-
|
|
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
|
-
```
|
|
286
|
-
|
|
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).
|
|
278
|
+
A card can hold a live 3D item that turns while it has focus. One `createLiveCards({ load: () => import('three') })` instance gives the page a shared WebGL context. With a still image supplied for each card, the 3D code waits for the first focus. Use `live.add(card, item, { still })` for a single card or assign `collection.live` for a collection. The guide has a complete scene and both integrations. [Live 3D guide](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/live-3d.md) · [Rocket demo](https://johnmorrisdotca.github.io/fuda-cards/demo/live-3d.html)
|
|
288
279
|
|
|
289
280
|
## The collection viewer
|
|
290
281
|
|
|
291
|
-
Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element
|
|
282
|
+
Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element. Set its `cards` property to an array or an object with a `cards` array. Each record needs a `name` and `image`. Optional fields include `backImage`, `metadata` and `kind`. Use `kind: 'object'` for a picture of a console or trophy that should stay face up. Ids must be unique, and the element uses the zero-based position when an id is omitted.
|
|
292
283
|
|
|
293
284
|
```html
|
|
294
285
|
<fuda-collection view="deck"></fuda-collection>
|
|
@@ -372,19 +363,19 @@ export function Cards({ cards }) {
|
|
|
372
363
|
}
|
|
373
364
|
```
|
|
374
365
|
|
|
375
|
-
Vue
|
|
366
|
+
The framework guide covers Vue's `:cards.prop`, Svelte and Angular's `CUSTOM_ELEMENTS_SCHEMA`. The TypeScript guide covers server rendering. [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) · [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md)
|
|
376
367
|
|
|
377
368
|
## Demos
|
|
378
369
|
|
|
379
370
|
[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
371
|
|
|
381
|
-
**Builder.**
|
|
372
|
+
**Builder.** Choose a card or collection, preview it and copy HTML, iframe, ES module, React, Vue, Angular or Svelte code. The link preserves the settings. [Open the Builder](https://johnmorrisdotca.github.io/fuda-cards/builder.html)
|
|
382
373
|
|
|
383
374
|
**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
375
|
|
|
385
376
|
**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
377
|
|
|
387
|
-
**Demo collectors.**
|
|
378
|
+
**Demo collectors.** Alex has 25 Base Set cards, Sam has 10 and Riley has 5 consoles. The demo can import and export JSON and save or load named collections in the current browser's localStorage for each fictional profile. [Open the collection demo](https://johnmorrisdotca.github.io/fuda-cards/demo/collections-component.html)
|
|
388
379
|
|
|
389
380
|
<picture>
|
|
390
381
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/fuda-cards/main/docs/images/vintage-desk-dark.webp">
|
|
@@ -414,7 +405,7 @@ The display choices are a radio group with arrow keys; a card in a display is a
|
|
|
414
405
|
- **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
406
|
- **Wear** is not drawn on the images of a collection or on the cards under a stack's top card.
|
|
416
407
|
- **Images are yours.** Fuda hosts none; a missing image or failed request is reported in the demo's page.
|
|
417
|
-
-
|
|
408
|
+
- Scanned-card import, collection-wide filters, editing, large-collection virtualisation and assistive-technology testing are on the roadmap. [Feature roadmap](docs/feature-roadmap.md)
|
|
418
409
|
|
|
419
410
|
## Browser and runtime support
|
|
420
411
|
|
|
@@ -437,25 +428,29 @@ The elements' own words (button names, labels) are English today. The documentat
|
|
|
437
428
|
|
|
438
429
|
## Roadmap
|
|
439
430
|
|
|
440
|
-
Open work
|
|
431
|
+
Open work includes API and scanned-card importers, collection filters, live Hako devices, researched period designs, configurable case geometry, large-collection virtualisation and testing in more browsers and on real phones. The live 3D demo already shows Uchusen Rockets in framed cards and in a binder. [Feature roadmap](docs/feature-roadmap.md)
|
|
441
432
|
|
|
442
433
|
## Architecture
|
|
443
434
|
|
|
444
|
-
`element.js` is the card and loads the wear
|
|
435
|
+
`element.js` is the card and loads the wear and pile code 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
436
|
|
|
446
437
|
## Documentation
|
|
447
438
|
|
|
448
439
|
| Guide | What it covers |
|
|
449
440
|
|---|---|
|
|
450
441
|
| [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) |
|
|
452
|
-
| [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md) | Thickness,
|
|
442
|
+
| [The card element](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/card-element.md) | Attributes, properties, CSS variables and narrow vintage formats |
|
|
443
|
+
| [Materials and stacks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/materials-and-stacks.md) | Thickness, seventeen sourced materials, stacks |
|
|
453
444
|
| [Wear](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/wear.md) | Presets, the seed, wear as data |
|
|
454
445
|
| [Motion and rotation](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/motion-and-spin.md) | Pan, autoplay, spin, driving the turn |
|
|
455
446
|
| [Collections](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/collections.md) | The element, the input, kinds, ten displays |
|
|
456
447
|
| [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
448
|
| [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
|
-
| [
|
|
449
|
+
| [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 |
|
|
450
|
+
| [Bundlers](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/bundlers.md) | Vite and webpack |
|
|
451
|
+
| [Frameworks](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/frameworks.md) | React, Vue, Svelte, Angular |
|
|
452
|
+
| [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 |
|
|
453
|
+
| [TypeScript and Node](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/typescript-and-node.md) | The types, and the tables on a server |
|
|
459
454
|
| [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
455
|
| [Architecture](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/architecture.md) | The modules and why |
|
|
461
456
|
| [Troubleshooting and FAQ](https://github.com/johnmorrisdotca/fuda-cards/blob/main/docs/guides/troubleshooting.md) | A blank card, a flash, a missing bar |
|
|
@@ -484,6 +479,84 @@ Read [AGENTS.md](AGENTS.md) for how work is done here: a board ticket for each c
|
|
|
484
479
|
|
|
485
480
|
Every release, dated, is in [CHANGELOG.md](CHANGELOG.md).
|
|
486
481
|
|
|
482
|
+
## The family
|
|
483
|
+
|
|
484
|
+
<!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
|
|
485
|
+
Fuda Cards is one of forty-one packages, each made for the same site, each at
|
|
486
|
+
[github.com/johnmorrisdotca](https://github.com/johnmorrisdotca) or [github.com/spxis](https://github.com/spxis). The code of every one is MIT.
|
|
487
|
+
|
|
488
|
+
**Games — board**
|
|
489
|
+
|
|
490
|
+
- [Domino](https://github.com/johnmorrisdotca/domino) (ドミノ): dominoes and Mexican Train. [Demo](https://johnmorrisdotca.github.io/domino/).
|
|
491
|
+
- [Gunjin](https://github.com/johnmorrisdotca/gunjin) (軍人): five hidden-rank strategy games with pass-the-device play. [Demo](https://johnmorrisdotca.github.io/gunjin/).
|
|
492
|
+
- [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/).
|
|
493
|
+
- [Sugoroku](https://github.com/johnmorrisdotca/sugoroku) (双六): backgammon and its variants, with the doubling cube and match play. [Demo](https://johnmorrisdotca.github.io/sugoroku/).
|
|
494
|
+
- [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/).
|
|
495
|
+
|
|
496
|
+
**Games — cards & tiles**
|
|
497
|
+
|
|
498
|
+
- [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/).
|
|
499
|
+
- [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/).
|
|
500
|
+
- [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
|
|
501
|
+
- [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
|
|
502
|
+
- [Toranpu](https://github.com/johnmorrisdotca/toranpu) (トランプ): a deck of playing cards, card games with computer players, and solitaires. [Demo](https://johnmorrisdotca.github.io/toranpu/).
|
|
503
|
+
|
|
504
|
+
**Games — puzzles**
|
|
505
|
+
|
|
506
|
+
- [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/).
|
|
507
|
+
- [Jirai](https://github.com/johnmorrisdotca/jirai) (地雷): minesweeper on shaped grids with verified no-guess boards. [Demo](https://johnmorrisdotca.github.io/jirai/).
|
|
508
|
+
- [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/).
|
|
509
|
+
- [Kazu](https://github.com/johnmorrisdotca/kazu) (数): grid number puzzles: Sudoku and its variants, Futoshiki and Skyscrapers. [Demo](https://johnmorrisdotca.github.io/kazu/).
|
|
510
|
+
- [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/).
|
|
511
|
+
- [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/).
|
|
512
|
+
- [Suido](https://github.com/johnmorrisdotca/suido) (水道): a pipe puzzle: turn the pieces until the water reaches every drain. [Demo](https://johnmorrisdotca.github.io/suido/).
|
|
513
|
+
- [Tobiishi](https://github.com/johnmorrisdotca/tobiishi) (飛び石): peg solitaire with nine boards and seeded solvable challenges. [Demo](https://johnmorrisdotca.github.io/tobiishi/).
|
|
514
|
+
- [Tsunagi](https://github.com/johnmorrisdotca/tsunagi) (繋ぎ): a line-joining logic puzzle whose every level has exactly one answer. [Demo](https://johnmorrisdotca.github.io/tsunagi/).
|
|
515
|
+
|
|
516
|
+
**Games — dice & random**
|
|
517
|
+
|
|
518
|
+
- [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/).
|
|
519
|
+
- [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/).
|
|
520
|
+
|
|
521
|
+
**Language**
|
|
522
|
+
|
|
523
|
+
- [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
|
|
524
|
+
- [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/).
|
|
525
|
+
- [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/).
|
|
526
|
+
- [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
|
|
527
|
+
|
|
528
|
+
**Space Program X**
|
|
529
|
+
|
|
530
|
+
- [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/).
|
|
531
|
+
- [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/).
|
|
532
|
+
- [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/).
|
|
533
|
+
- [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/).
|
|
534
|
+
|
|
535
|
+
**Geography & data**
|
|
536
|
+
|
|
537
|
+
- [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/).
|
|
538
|
+
- [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/).
|
|
539
|
+
- [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/).
|
|
540
|
+
- [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/).
|
|
541
|
+
- [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/).
|
|
542
|
+
- [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/).
|
|
543
|
+
|
|
544
|
+
**Sports**
|
|
545
|
+
|
|
546
|
+
- [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/).
|
|
547
|
+
- [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/).
|
|
548
|
+
- [Meigen Sports](https://github.com/johnmorrisdotca/meigen-sports) (名言): sports quotations and on-this-day history. [Demo](https://johnmorrisdotca.github.io/meigen-sports/).
|
|
549
|
+
- [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/).
|
|
550
|
+
- [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/).
|
|
551
|
+
|
|
552
|
+
**Developer tools**
|
|
553
|
+
|
|
554
|
+
- [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/).
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
**This package is Fuda Cards.** The demos of all forty-one share one header and footer, so each links the rest.
|
|
558
|
+
<!-- family:end -->
|
|
559
|
+
|
|
487
560
|
## Licence
|
|
488
561
|
|
|
489
|
-
|
|
562
|
+
MIT, Copyright (c) 2026 John Morris: see [LICENSE](LICENSE). The pictures the demos show belong to their owners and are credited in [NOTICE.md](NOTICE.md): the Starship still is CC BY 4.0 (Clarence365's model, see [assets/README.md](assets/README.md)), the hockey and baseball pictures are public domain from Wikimedia Commons and The Met, and the Pokémon card images come from TCGdex when the demo opens and are not licensed by this project.
|
package/dist/binder.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* A leaf has two sides, as a real one does: leaf k holds sides 2k (the right-hand page) and 2k+1 (the left-hand page of the next opening).
|
|
7
7
|
* An opening (spread) j shows side 2j-1 on the left (none at the start) and side 2j on the right.
|
|
8
8
|
*/
|
|
9
|
-
export type BinderStyle =
|
|
10
|
-
export type BinderSheet =
|
|
9
|
+
export type BinderStyle = "ring" | "zip";
|
|
10
|
+
export type BinderSheet = "clear" | "black";
|
|
11
11
|
export declare const binderCovers: ReadonlyArray<{
|
|
12
12
|
id: string;
|
|
13
13
|
label: string;
|
|
@@ -36,11 +36,9 @@ export declare function spreadSides(spread: number, sides: number): [number, num
|
|
|
36
36
|
export declare const BINDER_CSS = "\n.stage.binder{perspective:2400px;background:radial-gradient(ellipse,var(--fc-stage-1),var(--fc-stage-2) 68%)}\n.v.binder{--sw:300px;--sh:384px;--strip:34px;--cover:#1f7a4a;display:flex;align-items:center;justify-content:center;transform-style:preserve-3d}\n.book{position:relative;display:flex;padding:18px 16px;border-radius:16px;background:var(--cover);box-shadow:0 12px 28px #0008,inset 0 0 0 2px #fff2,inset 0 0 24px #0005;transform-style:preserve-3d}\n.book::before{content:'';position:absolute;inset:6px;border-radius:12px;box-shadow:inset 0 0 0 2px #0004;pointer-events:none}\n.book.b-zip::after{content:'';position:absolute;inset:5px;border-radius:13px;border:3px dotted #cfd2d8;opacity:.7;pointer-events:none}\n.book .tab{display:none}.book.b-zip .tab{display:block;position:absolute;right:30px;bottom:-4px;width:34px;height:14px;border-radius:5px;background:linear-gradient(#e4e6ea,#8d9098);box-shadow:0 2px 4px #0006}\n.inside{position:relative;display:flex;transform-style:preserve-3d;background:var(--lining,#f1eee6);border-radius:6px;box-shadow:inset 0 0 18px #0003}\n.half{position:relative;width:var(--sw);height:var(--sh);flex:none}\n.half:empty::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#0002,transparent 14%)}\n.spine{position:absolute;left:50%;top:0;bottom:0;width:0;transform-style:preserve-3d;pointer-events:none;z-index:3}\n.ring{position:absolute;left:-9px;width:18px;height:46px;margin-top:-23px;border-radius:9px;border:4px solid #c3c6cd;border-color:#f1f2f5 #8d9098 #8d9098 #f1f2f5;box-shadow:0 2px 3px #0005;transform:translateZ(2px)}\n.side{position:absolute;inset:0;display:grid;padding:12px 10px;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));grid-template-rows:repeat(var(--rows,3),minmax(0,1fr));gap:5px;background:var(--sheetbg);box-sizing:border-box;border:1px solid var(--sheetedge)}\n.side.clear{--sheetbg:#ffffff2e;--sheetedge:#ffffff55;--pocketbg:#ffffff26;--pocketedge:#ffffffa0}.side.black{--sheetbg:#17171b;--sheetedge:#000;--pocketbg:#ffffff12;--pocketedge:#ffffff55}\n.side.r{padding-left:calc(var(--strip) + 6px)}.side.l{padding-right:calc(var(--strip) + 6px)}\n.holes{position:absolute;top:0;bottom:0;width:var(--strip);display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;padding:14px 0}.side.r .holes{left:0}.side.l .holes{right:0}.holes i{width:9px;height:9px;border-radius:50%;background:var(--lining,#f1eee6);box-shadow:inset 0 1px 2px #0007,0 0 0 1px #0002}\n.pocket{position:relative;display:grid;place-items:center;border-radius:4px;background:var(--pocketbg);border:1px solid var(--pocketedge);box-shadow:inset 0 0 0 1px #0000000d,0 1px 2px #0003;overflow:hidden;min-width:0;min-height:0}\n.pocket::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(118deg,#ffffff55 0,#ffffff00 32%,#ffffff12 55%,#ffffff00 70%,#ffffff33 100%)}\n.pocket .card{position:relative;z-index:0;width:86%;height:92%;padding:0;border:0;background:transparent;line-height:0;display:grid;place-items:center}.pocket .card img{width:100%;height:100%;object-fit:contain;border-radius:3%;box-shadow:0 2px 5px #0007}\n.pocket.empty{opacity:.55}\n.leaf{position:absolute;left:50%;top:0;width:var(--sw);height:var(--sh);transform-origin:0 50%;transform-style:preserve-3d;pointer-events:none;z-index:2}\n.slice{position:absolute;top:0;height:100%;transform-origin:0 50%;transform-style:preserve-3d}\n.slice>.f,.slice>.b{position:absolute;inset:0 -1.5px;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}\n.slice .sf{position:absolute;top:0;height:100%}\n/* The slices overlap their neighbours by a pixel and a half, so no seam between them lets the page behind show; the outer edges of the leaf stay where they are. */\n.slice.first>.f,.slice.last>.b{left:0}.slice.first>.b,.slice.last>.f{right:0}\n";
|
|
37
37
|
/** The cards a side holds, as indexes into the collection (or -1 for an empty pocket), in reading order. */
|
|
38
38
|
export declare function sideCards(side: number, layout: BinderLayout, total: number): number[];
|
|
39
|
-
export
|
|
40
|
-
(index: number, live: boolean): HTMLElement;
|
|
41
|
-
}
|
|
39
|
+
export type PocketMaker = (index: number, live: boolean) => HTMLElement;
|
|
42
40
|
/** One side as it lies in the book: `left` or `right` of the spine, with its hole strip against the spine. `live` pockets hold the page's real card buttons; the rest hold pictures only. */
|
|
43
|
-
export declare function buildSide(side: number, where:
|
|
41
|
+
export declare function buildSide(side: number, where: "l" | "r", sheet: BinderSheet, layout: BinderLayout, total: number, pocket: PocketMaker, live?: boolean): HTMLElement;
|
|
44
42
|
/**
|
|
45
43
|
* A leaf of the book, built to swing: a chain of slices hinged one on the next (the hole strip, then a slice for each column of
|
|
46
44
|
* pockets), so that each can lean a little more than the one before it and the sheet bends. Each slice has the pockets of the front side on its
|
package/dist/binder.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export const binderCovers = [
|
|
2
|
-
{ id:
|
|
3
|
-
{ id:
|
|
2
|
+
{ id: "green", label: "Green", color: "#1f7a4a" },
|
|
3
|
+
{ id: "black", label: "Black", color: "#1d1d22" },
|
|
4
|
+
{ id: "teal", label: "Teal", color: "#1a9d93" },
|
|
5
|
+
{ id: "navy", label: "Navy", color: "#1f3a70" },
|
|
6
|
+
{ id: "red", label: "Red", color: "#b0262d" },
|
|
4
7
|
];
|
|
5
8
|
/** The sheets a binder takes: how many pockets and how they lie (across by down). 9 is the usual page; 4 and 12 are the other common ones. */
|
|
6
9
|
export const binderPockets = [
|
|
7
|
-
{ count: 4, cols: 2, rows: 2 },
|
|
10
|
+
{ count: 4, cols: 2, rows: 2 },
|
|
11
|
+
{ count: 9, cols: 3, rows: 3 },
|
|
12
|
+
{ count: 12, cols: 4, rows: 3 },
|
|
8
13
|
];
|
|
9
14
|
/** The pockets of a sheet: `pockets` (4, 9 or 12) if the page asks, else the older `columns` and `page-size`, else nine in three columns. */
|
|
10
15
|
export function binderLayout(pockets, columns, pageSize) {
|
|
@@ -22,7 +27,8 @@ export const spreadCount = (sides) => Math.ceil((sides + 1) / 2);
|
|
|
22
27
|
export const spreadOf = (index, per) => Math.ceil(Math.floor(index / per) / 2);
|
|
23
28
|
/** The sides an opening shows (-1 where there is none), left then right, for `sides` sides in all. */
|
|
24
29
|
export function spreadSides(spread, sides) {
|
|
25
|
-
const left = 2 * spread - 1
|
|
30
|
+
const left = 2 * spread - 1;
|
|
31
|
+
const right = 2 * spread;
|
|
26
32
|
return [left >= 0 && left < sides ? left : -1, right < sides ? right : -1];
|
|
27
33
|
}
|
|
28
34
|
export const BINDER_CSS = `
|
|
@@ -58,17 +64,17 @@ export function sideCards(side, layout, total) {
|
|
|
58
64
|
}
|
|
59
65
|
/** One side as it lies in the book: `left` or `right` of the spine, with its hole strip against the spine. `live` pockets hold the page's real card buttons; the rest hold pictures only. */
|
|
60
66
|
export function buildSide(side, where, sheet, layout, total, pocket, live = true) {
|
|
61
|
-
const el = document.createElement(
|
|
67
|
+
const el = document.createElement("div");
|
|
62
68
|
el.className = `side ${where} ${sheet}`;
|
|
63
69
|
el.dataset.side = String(side);
|
|
64
|
-
el.style.setProperty(
|
|
65
|
-
el.style.setProperty(
|
|
66
|
-
const holes = document.createElement(
|
|
67
|
-
holes.className =
|
|
68
|
-
holes.innerHTML =
|
|
70
|
+
el.style.setProperty("--cols", String(layout.cols));
|
|
71
|
+
el.style.setProperty("--rows", String(layout.rows));
|
|
72
|
+
const holes = document.createElement("div");
|
|
73
|
+
holes.className = "holes";
|
|
74
|
+
holes.innerHTML = "<i></i>".repeat(9);
|
|
69
75
|
el.append(holes);
|
|
70
76
|
for (const index of sideCards(side, layout, total))
|
|
71
|
-
el.append(index < 0 ? Object.assign(document.createElement(
|
|
77
|
+
el.append(index < 0 ? Object.assign(document.createElement("div"), { className: "pocket empty" }) : pocket(index, live));
|
|
72
78
|
return el;
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
@@ -77,32 +83,35 @@ export function buildSide(side, where, sheet, layout, total, pocket, live = true
|
|
|
77
83
|
* front and the matching column of the back side on its back. Returns the leaf and its slices.
|
|
78
84
|
*/
|
|
79
85
|
export function buildLeaf(front, back, sheet, layout, total, pocket, widthPx, strip) {
|
|
80
|
-
const leaf = document.createElement(
|
|
81
|
-
leaf.className =
|
|
86
|
+
const leaf = document.createElement("div");
|
|
87
|
+
leaf.className = "leaf";
|
|
82
88
|
const faces = (side, where) => side < 0 ? null : buildSide(side, where, sheet, layout, total, pocket, false);
|
|
83
|
-
const rightSide = faces(front,
|
|
89
|
+
const rightSide = faces(front, "r");
|
|
90
|
+
const leftSide = faces(back, "l");
|
|
84
91
|
const widths = [strip + 6, ...Array.from({ length: layout.cols }, () => (widthPx - strip - 6) / layout.cols)];
|
|
85
92
|
const slices = [];
|
|
86
|
-
let parent = leaf
|
|
93
|
+
let parent = leaf;
|
|
94
|
+
let offset = 0;
|
|
87
95
|
widths.forEach((w, k) => {
|
|
88
|
-
const slice = document.createElement(
|
|
89
|
-
slice.className = k === 0 ?
|
|
96
|
+
const slice = document.createElement("div");
|
|
97
|
+
slice.className = k === 0 ? "slice first" : k === widths.length - 1 ? "slice last" : "slice";
|
|
90
98
|
slice.style.width = `${w}px`;
|
|
91
|
-
slice.style.left = k === 0 ?
|
|
92
|
-
const f = document.createElement(
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
slice.style.left = k === 0 ? "0" : "100%";
|
|
100
|
+
const f = document.createElement("div");
|
|
101
|
+
const b = document.createElement("div");
|
|
102
|
+
f.className = "f";
|
|
103
|
+
b.className = "b";
|
|
95
104
|
// The whole side is placed inside each slice's face and shifted so that this slice shows its own part of it.
|
|
96
105
|
if (rightSide) {
|
|
97
106
|
const copy = rightSide.cloneNode(true);
|
|
98
|
-
copy.classList.add(
|
|
107
|
+
copy.classList.add("sf");
|
|
99
108
|
copy.style.width = `${widthPx}px`;
|
|
100
109
|
copy.style.left = `${-offset}px`;
|
|
101
110
|
f.append(copy);
|
|
102
111
|
}
|
|
103
112
|
if (leftSide) {
|
|
104
113
|
const copy = leftSide.cloneNode(true);
|
|
105
|
-
copy.classList.add(
|
|
114
|
+
copy.classList.add("sf");
|
|
106
115
|
copy.style.width = `${widthPx}px`;
|
|
107
116
|
copy.style.left = `${-(widthPx - offset - w)}px`;
|
|
108
117
|
b.append(copy);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CARD_CSS } from "./card-styles.js";
|
|
2
|
+
/** The corner radius of the card's face, in design pixels (a 300th of the card's width). */
|
|
3
|
+
const CORNER_RADIUS = 15;
|
|
4
|
+
/** The edge planes stop this far from the corner so that the rounded corner is not poked through (twice the corner radius). */
|
|
5
|
+
const EDGE_INSET = CORNER_RADIUS * 2;
|
|
6
|
+
/**
|
|
7
|
+
* Each rounded corner is edged by two short planes that follow its curve, as the straight edges are by one: where they sit from the corner, how long
|
|
8
|
+
* they are and how far they turn. They are tangents of the 15 pixel arc, one at 22.5 degrees and one at 67.5 degrees round it (length 2 r tan 22.5, at
|
|
9
|
+
* r (1 - cos 22.5) and r (1 - sin 22.5) from the corner), not chords. A plane of the edge reaches across the whole card when it is extended, and the browser
|
|
10
|
+
* cuts the faces it crosses along it, which left a thin diagonal line on the card (MODULES-142): a tangent of a convex card never crosses its face.
|
|
11
|
+
*/
|
|
12
|
+
const CORNER_PLANE = { near: 1.14, far: 9.26, length: 12.43, steep: 67.5, shallow: 22.5 };
|
|
13
|
+
const design = (pixels) => `calc(${pixels} * var(--u))`;
|
|
14
|
+
const fromRight = (pixels) => `calc(100% - ${design(pixels)})`;
|
|
15
|
+
const plane = ({ left, top, width, height, transform, side }) => `<i class="edge${side ? " side" : ""}" style="left:${left};top:${top};width:${width};height:${height};transform:${transform}"></i>`;
|
|
16
|
+
const turned = (degrees) => `translate(-50%,-50%) rotate(${degrees}deg) rotateX(90deg)`;
|
|
17
|
+
/** The planes that make the card's edge: four straight ones and eight that follow the corners. */
|
|
18
|
+
function edgePlanes() {
|
|
19
|
+
const run = `calc(100% - ${design(EDGE_INSET)})`;
|
|
20
|
+
const { near, far, length, steep, shallow } = CORNER_PLANE;
|
|
21
|
+
const long = design(length);
|
|
22
|
+
const corner = (left, top, degrees) => plane({ left, top, width: long, height: "var(--t)", transform: turned(degrees) });
|
|
23
|
+
return [
|
|
24
|
+
plane({ left: "50%", top: "0", width: run, height: "var(--t)", transform: turned(0) }),
|
|
25
|
+
plane({ left: "50%", top: "100%", width: run, height: "var(--t)", transform: turned(0) }),
|
|
26
|
+
plane({
|
|
27
|
+
left: "0",
|
|
28
|
+
top: "50%",
|
|
29
|
+
width: "var(--t)",
|
|
30
|
+
height: run,
|
|
31
|
+
transform: "translate(-50%,-50%) rotateY(90deg)",
|
|
32
|
+
side: true,
|
|
33
|
+
}),
|
|
34
|
+
plane({
|
|
35
|
+
left: "100%",
|
|
36
|
+
top: "50%",
|
|
37
|
+
width: "var(--t)",
|
|
38
|
+
height: run,
|
|
39
|
+
transform: "translate(-50%,-50%) rotateY(90deg)",
|
|
40
|
+
side: true,
|
|
41
|
+
}),
|
|
42
|
+
corner(design(near), design(far), -steep),
|
|
43
|
+
corner(design(far), design(near), -shallow),
|
|
44
|
+
corner(design(near), fromRight(far), steep),
|
|
45
|
+
corner(design(far), fromRight(near), shallow),
|
|
46
|
+
corner(fromRight(near), design(far), steep),
|
|
47
|
+
corner(fromRight(far), design(near), shallow),
|
|
48
|
+
corner(fromRight(near), fromRight(far), -steep),
|
|
49
|
+
corner(fromRight(far), fromRight(near), -shallow),
|
|
50
|
+
].join("");
|
|
51
|
+
}
|
|
52
|
+
/** The picture's slot and its Animate button. */
|
|
53
|
+
const ART = `<div class="art"><slot></slot><button class="motion-button" type="button" aria-pressed="false" aria-label="Animate the picture" title="Animate" hidden><span class="glyph"><svg viewBox="0 0 12 12" aria-hidden="true"><path class="play" d="M3 1.5v9l7.5-4.5z"/><path class="pause" d="M2.5 1.5h2.8v9H2.5zM6.7 1.5h2.8v9H6.7z"/></svg></span></button></div>`;
|
|
54
|
+
const FRONT = `<div class="face front"><div class="inner"><div class="heading"><span id="title"></span><span class="badge" id="category"></span></div>${ART}<div class="subtitle" id="subtitle"></div><div class="description" id="description"></div><div class="footer"><span id="number"></span><span>✦ FUDA COLLECTION</span><span id="rarity"></span></div></div><div class="shine"></div></div>`;
|
|
55
|
+
const BACK = `<div class="face back"><div class="emblem">FUDA</div><div class="shine"></div></div>`;
|
|
56
|
+
/** The card's shadow root: its stylesheet, the front, the back, the edge and the place for the cards under the top one. */
|
|
57
|
+
export function cardMarkup() {
|
|
58
|
+
return `<style>${CARD_CSS}</style><div class="rotation"><div class="card">${FRONT}${BACK}${edgePlanes()}<div class="stills"></div></div></div>`;
|
|
59
|
+
}
|