@johnmorrisdotca/fuda-cards 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +382 -58
- package/dist/collection-element.d.ts +13 -0
- package/dist/collection-element.js +20 -2
- package/dist/live-3d.d.ts +43 -0
- package/dist/live-3d.js +161 -0
- package/docs/API.md +793 -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/card-element.md +65 -0
- package/docs/guides/collections.md +86 -0
- package/docs/guides/frameworks.md +105 -0
- package/docs/guides/getting-started.md +94 -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/card-element.md +65 -0
- package/docs/guides/ja/collections.md +86 -0
- package/docs/guides/ja/frameworks.md +105 -0
- package/docs/guides/ja/getting-started.md +94 -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/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/upgrading.md +56 -0
- package/docs/guides/wear.md +63 -0
- package/docs/live-3d.md +59 -0
- package/package.json +29 -6
|
@@ -22,7 +22,7 @@ An item says what it is with `kind` (`"card"`, the default, or `"object"`; see `
|
|
|
22
22
|
|
|
23
23
|
## Zoom, Fit and move (every view)
|
|
24
24
|
|
|
25
|
-
Every view has the shared view controls (`@johnmorrisdotca/kazoku-ui`) on the view: zoom out,
|
|
25
|
+
Every view has the shared view controls (`@johnmorrisdotca/kazoku-ui`) on the view: zoom out, the zoom as a number, zoom in, **Fit**, and, under **More**, an arrow pad. A double press on the view goes to 2 times. Ctrl or Command with the wheel, a trackpad pinch and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view. The views are flat, so none turns in 3D and the angle, tilt and auto-turn controls are hidden.
|
|
26
26
|
|
|
27
27
|
- The controls take every press on the view, including one that starts on a card, so a drag or a pinch works over the cards. A tap that did not move is passed to the card as a click, and the keyboard still opens a focused card with Enter.
|
|
28
28
|
- **Fit** shows every card the view draws, at most at natural size. The wall, story and atlas open at half size or larger and start at their first card; the other views open at Fit. Zoom out goes to 0.4 of Fit.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Accessibility and theming
|
|
3
|
+
section: explanation
|
|
4
|
+
order: 10
|
|
5
|
+
description: What a Fuda card and collection do for keyboards, touch, screen readers and reduced motion, what they leave to you, and every colour and size you can set.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## What is built in
|
|
9
|
+
|
|
10
|
+
- **Keyboard.** The display buttons of a collection are a radio group: one tab stop, the arrow keys move the choice. A card in a display is a button with the accessible name "Inspect" and its name, and Enter or Space opens it. The view takes `+`, `-` and `0` for zoom and Fit while it is focused. The Animate button of a card is a real button with `aria-pressed`.
|
|
11
|
+
- **Touch.** Every control is at least 48 px square. A drag or a pinch on the view works even when it starts on a card; a tap that did not move is passed on to the card as a click.
|
|
12
|
+
- **Reduced motion.** With `prefers-reduced-motion: reduce`: the card's rotation, its flip transition, the art's pan, autoplay and a live 3D card are all off; flights and fans move without animating; every move still ends in the same place as with motion. This is not something you opt into.
|
|
13
|
+
- **No hidden surprises.** A card never autoplays by itself, and Auto-turn does not start when the reader asks for reduced motion.
|
|
14
|
+
- **A picture's description is yours.** The art in a card is whatever you slot into it. Give each `<img>` an `alt`; for items in a collection, `name` is what a screen reader hears.
|
|
15
|
+
|
|
16
|
+
## What is left to you
|
|
17
|
+
|
|
18
|
+
Contrast of the art you supply, descriptions for your images, and the page around the element. Browser, assistive technology and device coverage is limited (see the [limits](../../README.md#limits)): everything here has been tested in headless Chromium at a desk and a phone size, and not on a real phone, in Safari or in Firefox.
|
|
19
|
+
|
|
20
|
+
## Light and dark
|
|
21
|
+
|
|
22
|
+
A collection follows the reader's light or dark setting by default. `theme="light"` or `theme="dark"` on the element chooses for them. The Card Studio and the demos read `?theme=` from the address for the same reason.
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<fuda-collection view="deck" theme="dark"></fuda-collection>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
28
|
+
document.querySelector('fuda-collection').cards = [{ name: 'Alpha', image: '/a.jpg' }];
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Size and spacing
|
|
33
|
+
|
|
34
|
+
| Setting | What it changes |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `width` of `fuda-card` | The card's size; everything inside scales (container units). Default 300 px. |
|
|
37
|
+
| `--fuda-stage-height` on `fuda-collection` | The height of the view. Default: the window less 440 px, between 300 and 620 px. |
|
|
38
|
+
| `--fuda-perspective` on `fuda-card` | The depth of 3D turns. Default `1000px`. |
|
|
39
|
+
| `--fuda-edge` on `fuda-card` | The colour of the edge, any CSS background. |
|
|
40
|
+
| `--fuda-pan-duration` | Seconds for one pass of the art's pan. |
|
|
41
|
+
| `--fuda-card-spin-duration` | Seconds for one turn of `card-spin`. Default `180s`. |
|
|
42
|
+
| `--fuda-yaw`, `--fuda-tilt` | The angles with `card-view`. |
|
|
43
|
+
| `--fuda-focus-x`, `--fuda-focus-y` | The focal point of the art. |
|
|
44
|
+
|
|
45
|
+
The shadow root is closed to your stylesheet, so these custom properties are the interface. The frame's colours come from `variant` and `finish`.
|
|
46
|
+
|
|
47
|
+
## Keep the stage on screen
|
|
48
|
+
|
|
49
|
+
The zoom bar sits under the view. Keep what is above the viewer short so the controls are on the first screen; shrink `--fuda-stage-height` on a short window.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<style>fuda-collection { --fuda-stage-height: clamp(260px, calc(100svh - 620px), 620px); }</style>
|
|
53
|
+
<fuda-collection view="case"></fuda-collection>
|
|
54
|
+
<script type="module">
|
|
55
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
56
|
+
document.querySelector('fuda-collection').cards = [{ name: 'Alpha', image: '/a.jpg' }];
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Related
|
|
61
|
+
|
|
62
|
+
[Troubleshooting](troubleshooting.md) for a card that is blank or flashes, and [Motion and rotation](motion-and-spin.md) for everything that moves.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Architecture
|
|
3
|
+
section: explanation
|
|
4
|
+
order: 11
|
|
5
|
+
description: How the package is split into small modules, why a plain card loads almost nothing, and what each file in src does.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Fuda is plain TypeScript compiled to ES modules, with no framework and no 3D engine. Its design rule is that **a page pays only for what it uses**: a card with no wear never loads the wear code, a card with no stack never loads the pile code, and a page of pictures never loads three.js.
|
|
9
|
+
|
|
10
|
+
## The entry points
|
|
11
|
+
|
|
12
|
+
| Entry | File | What it is | Size (raw, gzip -9) |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| `@johnmorrisdotca/fuda-cards` | `dist/index.js` | Types and tables: variants, finishes, materials, stack presets, the stack and wear maths. No DOM. | 0.4 KB, plus its modules |
|
|
15
|
+
| `.../element` | `dist/element.js` | Registers `<fuda-card>`. | 21.4 KB, 6.5 KB |
|
|
16
|
+
| `.../collection` | `dist/collection.js` | The collection's data rules: `parseCollection`, views, kinds, the fan's layout. No DOM. | 4.7 KB, 1.6 KB |
|
|
17
|
+
| `.../collection-element` | `dist/collection-element.js` | Registers `<fuda-collection>`. | 45.1 KB, 13.4 KB |
|
|
18
|
+
| `.../live-3d` | `dist/live-3d.js` | The focus policy for live 3D cards. | 7.5 KB, 2.3 KB |
|
|
19
|
+
|
|
20
|
+
## The modules behind them
|
|
21
|
+
|
|
22
|
+
- **`element.ts`** draws the card: two faces, an edge made of thin planes, the art slot, the Animate button and the pan, the spin. It imports `materials.ts` and `stack.ts`, and loads the rest on demand. The class it registers, `FudaCard`, is exported too, for a subclass or a type.
|
|
23
|
+
- **`wear.ts`** (17 KB) is a module of its own, loaded with `import()` only when a card has a `wear` attribute. A perfect card is drawn exactly as before.
|
|
24
|
+
- **`pile-card.ts`** (13.7 KB) holds the fan, the take-off and the side pile for `<fuda-card stack>`, loaded only when a card asks for `fan`, `taken-off` or `pile-controls`.
|
|
25
|
+
- **`pile.ts`** is what every pile shares: the landing, the fan layout and the timing (`animate`, `speed`, reduced motion). Both the card and the collection use it, so a pile behaves the same everywhere.
|
|
26
|
+
- **`stack.ts`** lays the cards under the top one from a seed (a small seeded generator, mulberry32), the same way each time.
|
|
27
|
+
- **`materials.ts`** is the table of sourced thicknesses and the stack presets.
|
|
28
|
+
- **`binder.ts`** builds the sheets, the pockets and the turning leaf.
|
|
29
|
+
- **`zoom.ts`** and **`choice.ts`** wire the collection to the view controls of kazoku-ui and draw its rows of choice buttons.
|
|
30
|
+
- **`collection-element.ts`** draws the ten displays, in the class `FudaCollection`.
|
|
31
|
+
- **`live-3d.ts`** decides which card is live; the context itself, the shared assets, the stills and the pixel budget belong to kazoku-ui's shared renderer.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { cardMaterials, stackLayout, wearLayout, wearLevels } from '@johnmorrisdotca/fuda-cards';
|
|
35
|
+
|
|
36
|
+
const levels = wearLevels({ wear: 'damaged' });
|
|
37
|
+
console.log(cardMaterials.length, stackLayout(11).length, Boolean(levels && wearLayout(levels, 1)));
|
|
38
|
+
// 13 10 true
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Drawing
|
|
42
|
+
|
|
43
|
+
A card is a stack of CSS 3D planes, not WebGL. Thickness is `calc(var(--mm) * 100cqw / 63)`, so it follows the element's width, and the edge is a set of thin planes between the faces. A stack is one 3D scene whatever its count and draws nothing while at rest. Moves are CSS transforms and one-shot animations that end by themselves; nothing runs on a timer. The one place that uses WebGL is live 3D, and there only one context ever exists.
|
|
44
|
+
|
|
45
|
+
The art is kept hidden until the card has a size on screen and every slotted image has loaded, so the raw picture never shows outside the frame (see [Troubleshooting](troubleshooting.md#the-picture-flashes-before-the-card-appears)).
|
|
46
|
+
|
|
47
|
+
## Dependencies
|
|
48
|
+
|
|
49
|
+
`@johnmorrisdotca/kazoku-ui` is a runtime dependency (zoom bar, shared renderer). `three` is an optional peer, yours. A single `<fuda-card>` imports neither.
|
|
50
|
+
|
|
51
|
+
## Tests
|
|
52
|
+
|
|
53
|
+
`pnpm test` runs unit tests on the tables and the rules. `pnpm test:e2e` drives headless Chromium, in software, at a desk and a phone size, one file at a time. Both are part of `pnpm check` and the release. See [Development](../../README.md#development).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Binders and piles
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 7
|
|
5
|
+
description: Turn the pages of a ring or zip binder, fan a pile of cards open, take a card off it and tune every move with animate and speed.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Two kinds of display show most of what a collector does: a **binder** open on two facing sheets of pockets, and a **pile** of cards that fans open and gives up one card at a time. The same code draws a pile in `<fuda-collection>` (the Overlapping Deck, Random Draw and the Fan of Cards) and in `<fuda-card stack>`.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## The binder
|
|
13
|
+
|
|
14
|
+
`view="binder"` is a binder open on two facing sheets. Each sheet is a page of clear plastic pockets with a slight sheen, one card to a pocket, on a clear or black sheet, with a strip of punched holes 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.
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<fuda-collection view="binder" binder="zip" cover="navy" sheet="black" pockets="12"></fuda-collection>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
20
|
+
document.querySelector('fuda-collection').cards = Array.from({ length: 30 }, (_, i) => ({ name: `Card ${i + 1}`, image: `/cards/${i + 1}.jpg` }));
|
|
21
|
+
</script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| Attribute | Values | Default |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| `binder` | `ring`, `zip` (a zipper and its pull) | `ring` |
|
|
27
|
+
| `cover` | `green`, `black`, `teal`, `navy`, `red` | `green` |
|
|
28
|
+
| `sheet` | `clear`, `black` | `clear` |
|
|
29
|
+
| `pockets` | `4` (2 by 2), `9` (3 by 3), `12` (4 across by 3 down) | `9` |
|
|
30
|
+
|
|
31
|
+
The older `page-size` and `columns` still work and set the pockets of a sheet. Each option is also a row of buttons under the view and a value in the address. Clicking a card opens it. With `animate="off"` or reduced motion the page changes at once and ends in exactly the same place.
|
|
32
|
+
|
|
33
|
+
## The deck, and every other pile
|
|
34
|
+
|
|
35
|
+
The Overlapping Deck (`view="deck"`) draws 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. Random Draw is a pile too, and the Fan of Cards is the same pile with only its fan. Rolodex and Spotlight spread their cards out; they are carousels, not piles.
|
|
36
|
+
|
|
37
|
+
Where a card lands is `deck-land`: `face-up` (the default) keeps it facing up, `face-down` turns it over sideways about its vertical axis, like turning a page, so the pile shows the card's `backImage` or the package's own back. A card never lands with its picture on its head. The 0.6.0 value `upside-down` is still accepted and means `face-down`.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { deckLandings, fanLayout, normalizeLanding } from '@johnmorrisdotca/fuda-cards/collection';
|
|
41
|
+
|
|
42
|
+
console.log(deckLandings.map((landing) => landing.id).join(' '));
|
|
43
|
+
console.log(normalizeLanding('upside-down'), normalizeLanding('anything else'));
|
|
44
|
+
const fan = fanLayout(3);
|
|
45
|
+
console.log(fan.map((place) => place.angle).join(' '));
|
|
46
|
+
// face-up face-down
|
|
47
|
+
// face-down face-up
|
|
48
|
+
// -11 0 11
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
## Fan a pile, take a card off it
|
|
54
|
+
|
|
55
|
+
`fan="open"` spreads up to ten cards in an arc, like a hand of playing cards, with most of each card showing, and closes back exactly where they began. A card can be taken off an open fan and off a pile that was fanned and closed. In a collection the buttons are right under the view and the fan is in the address (`?fan=open`); `view="fan"` is the same pile with only its fan, `fan-size` (2 to 10) cards from the current one, and Next moves the window on.
|
|
56
|
+
|
|
57
|
+
On a card, a stack is a pile:
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
61
|
+
<fuda-card id="pile" title="Deck" stack="52" pile-controls></fuda-card>
|
|
62
|
+
<script type="module">
|
|
63
|
+
const pile = document.querySelector('#pile');
|
|
64
|
+
pile.addEventListener('fuda-pile', (event) => console.log('reach', event.detail));
|
|
65
|
+
pile.takeOff(3);
|
|
66
|
+
pile.putBack();
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- `taken-off="3"` puts the top three cards on a pile at the side, as thick as the cards in it. `card.takeOff(count)` and `card.putBack(count)` change it.
|
|
71
|
+
- `pile-controls` draws three buttons (Fan, Take a card off, Put it back), each at least 48 px; leave about 70 px of room below the card.
|
|
72
|
+
- `card.pileBounds` says how far an open fan or a side pile reaches beyond the card, in card widths; the event `fuda-pile` is sent when that changes, so your page can fit its view.
|
|
73
|
+
- The pile code is a separate module (`dist/pile-card.js`) that a card loads only when it asks for `fan`, `taken-off` or `pile-controls`. A plain card never requests it.
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
## Animate and speed
|
|
78
|
+
|
|
79
|
+
`animate="off"` turns every move off (each 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. The moves are CSS transforms and one-shot animations that end by themselves, so nothing runs while the view is idle, and the reader's reduced-motion setting always wins. Both are under the view and in the address (`?animate=off&speed=quick`).
|
|
80
|
+
|
|
81
|
+
## Rotate a pile
|
|
82
|
+
|
|
83
|
+
A pile's view controls have the angle, tilt and Auto-turn (the flat displays do not), and the whole table, both piles, turns in 3D: from behind you see the backs of the deck and the faces of a face-down pile. Objects in a collection stay square to the reader. See [Collections](collections.md) for kinds.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The card element
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 2
|
|
5
|
+
description: Every attribute, property and CSS variable of the fuda-card element, with the default of each and how to size and style a card.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`<fuda-card>` is a frame for a picture, or for anything else you slot into it. It registers itself when you import `@johnmorrisdotca/fuda-cards/element`, and that import is the only thing it needs. The main entry (`@johnmorrisdotca/fuda-cards`) exports the same options as TypeScript types and tables without touching the DOM, so it is safe to import on a server.
|
|
9
|
+
|
|
10
|
+
## The frame
|
|
11
|
+
|
|
12
|
+
| Attribute | Values | What it does |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `title` | text | The card's name at the top. |
|
|
15
|
+
| `category` | text | A word in the corner, such as `ROCKET`. |
|
|
16
|
+
| `subtitle` | text | A line under the picture. |
|
|
17
|
+
| `description` | text | The text block under the subtitle. |
|
|
18
|
+
| `number` | text | The card number at the foot. |
|
|
19
|
+
| `rarity` | text | The rarity mark at the foot. |
|
|
20
|
+
| `variant` | `classic`, `sport`, `cosmic` | The frame's look: gold, silver or violet. |
|
|
21
|
+
| `finish` | `foil`, `matte` | Whether the frame shines. |
|
|
22
|
+
| `flipped` | boolean | Shows the back, the navy Fuda face. |
|
|
23
|
+
|
|
24
|
+
The default slot holds the art: an `<img>`, or any HTML, including an existing interactive viewer. The card has no drag handler, so that viewer owns its own pointer.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { cardFinishes, cardVariants, type CardOptions } from '@johnmorrisdotca/fuda-cards';
|
|
28
|
+
|
|
29
|
+
const options: CardOptions = { title: 'Explorer One', variant: cardVariants[2], finish: cardFinishes[0], thickness: 0.3 };
|
|
30
|
+
console.log(options.variant, options.finish);
|
|
31
|
+
// cosmic foil
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Size
|
|
35
|
+
|
|
36
|
+
The element is 300 px wide by default, `aspect-ratio: 2.5 / 3.5`, and every measurement inside it is in container units, so one CSS rule sizes the whole card:
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
40
|
+
<style>fuda-card.small { width: 180px; }</style>
|
|
41
|
+
<fuda-card class="small" title="Small"></fuda-card>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The perspective for 3D turns is `--fuda-perspective` (default `1000px`). The edge colour is `--fuda-edge`, any CSS background; the default is gold for the classic frame and card-stock cream for the others. The drop shadow is on the element itself, so do not put a `filter` on anything between the card and its faces.
|
|
45
|
+
|
|
46
|
+
## Properties and methods
|
|
47
|
+
|
|
48
|
+
| Member | What it gives |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `card.wear` | The wear preset, as the attribute. Setting an empty string removes it. |
|
|
51
|
+
| `card.cardThicknessMm` | The thickness in use: `thickness`, else the material's, else 0.3. |
|
|
52
|
+
| `card.stackCount` | How many cards the stack holds, 1 to 1000. |
|
|
53
|
+
| `card.stackHeight` | The stack's height in millimetres. |
|
|
54
|
+
| `card.heldCount` | How many cards are still in the stack, after any taken off. |
|
|
55
|
+
| `card.fanOpen` | True while the stack is fanned open. |
|
|
56
|
+
| `card.isMoving` | True while the art pans. |
|
|
57
|
+
| `card.takeOff(count?)`, `card.putBack(count?)` | Move cards to the pile at the side and back. |
|
|
58
|
+
| `card.pileBounds` | How far an open fan or a side pile reaches beyond the card, in card widths. |
|
|
59
|
+
| `card.setFocused(on)` | Put this card in or out of focus for `autoplay="focus"`. |
|
|
60
|
+
|
|
61
|
+
The `fuda-pile` event is sent when `pileBounds` changes. The pile, wear and motion code are separate modules; see [Architecture](architecture.md).
|
|
62
|
+
|
|
63
|
+
## Related guides
|
|
64
|
+
|
|
65
|
+
Thickness and stacks: [Materials and stacks](materials-and-stacks.md). Used cards: [Wear](wear.md). Turning and panning: [Motion and rotation](motion-and-spin.md). Fanning and taking off: [Binders and piles](binder-and-piles.md).
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Collections
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 6
|
|
5
|
+
description: Show a whole collection with fuda-collection, in ten displays, from a list of items you supply, with the input rules, kinds, metadata and the address.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`<fuda-collection>` shows a list of items in one of ten displays and gives the reader a zoom bar, a choice of display and, where it makes sense, the options of that display. You supply the list; Fuda stores nothing, asks for no account and fetches nothing except the image addresses you give it.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Give it cards
|
|
13
|
+
|
|
14
|
+
Import `@johnmorrisdotca/fuda-cards/collection-element` once, then set the `cards` **property** (an array cannot be an attribute):
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<fuda-collection view="wall" theme="light"></fuda-collection>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
20
|
+
document.querySelector('fuda-collection').cards = [
|
|
21
|
+
{ id: 'a', name: 'Alpha', image: '/cards/alpha.jpg', backImage: '/cards/alpha-back.jpg' },
|
|
22
|
+
{ id: 'b', name: 'Bravo', image: '/cards/bravo.jpg', metadata: { set: 'Base', year: 1999, number: '2' } },
|
|
23
|
+
{ id: 'c', name: 'Console', image: '/cards/console.jpg', kind: 'object' },
|
|
24
|
+
];
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The input may be an array or an object with a `cards` array. Each item needs a `name` and an `image` URL. `id` is optional (the position is used), and must be unique. `backImage` is optional; without one the package draws its own navy back.
|
|
29
|
+
|
|
30
|
+
## Check a list first
|
|
31
|
+
|
|
32
|
+
`parseCollection` is the check the element runs, exported so you can run it on a file before you hand it over. It returns the normalised list or throws an `Error` that names the item.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { collectionKinds, collectionViews, isCard, parseCollection, randomDrawIndex } from '@johnmorrisdotca/fuda-cards/collection';
|
|
36
|
+
|
|
37
|
+
const cards = parseCollection({ cards: [
|
|
38
|
+
{ name: 'Alpha', image: '/a.jpg' },
|
|
39
|
+
{ id: 'console', name: 'Console', image: '/c.jpg', kind: 'object' },
|
|
40
|
+
] });
|
|
41
|
+
console.log(cards.map((card) => `${card.id}:${isCard(card)}`).join(' '));
|
|
42
|
+
console.log(collectionKinds.join(' '), collectionViews.length);
|
|
43
|
+
console.log(randomDrawIndex(cards, 0, 'cons', () => 0));
|
|
44
|
+
try { parseCollection([{ name: 'No picture' }]); } catch (error) { console.log((error as Error).message); }
|
|
45
|
+
// 0:true console:false
|
|
46
|
+
// card object 10
|
|
47
|
+
// 1
|
|
48
|
+
// Card 1 needs a name and image URL.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`randomDrawIndex(cards, current, filter, random?)` picks a card whose name contains the filter, avoiding the current one when another matches, and gives `null` when none matches. `movePage(index, length, pageSize, delta)` returns the first index of the page `delta` pages away, wrapping round.
|
|
52
|
+
|
|
53
|
+
## Kinds
|
|
54
|
+
|
|
55
|
+
`kind` says what an item is: `"card"` (the default, so every collection written before the field existed is still cards) or `"object"`. A card is flat and thin with a back, so it turns in 3D, can be seen from behind and lands turned over when taken off a pile. An object is a picture of a thing that is not a card, such as a games console: it has no back and no thickness, so it never turns over and always lands facing up. A collection with no card in it offers no Angle, Tilt or Auto-turn, and drops an angle from the address. In a mixed collection the controls are there for the cards and each object stays square to the reader. Objects can still be fanned open and taken off a pile.
|
|
56
|
+
|
|
57
|
+
## Metadata
|
|
58
|
+
|
|
59
|
+
`metadata` is optional and has `set`, `number`, `edition`, `condition`, `grade` and `notes` (strings), and `year` and `quantity` (whole numbers, `quantity` at least 1). Nothing assumes a price or a grade.
|
|
60
|
+
|
|
61
|
+
## The ten displays
|
|
62
|
+
|
|
63
|
+
| `view` | Display | Kind of display |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `deck` | Overlapping Deck | a pile, with a pile beside it |
|
|
66
|
+
| `rolodex` | Rolodex | a carousel |
|
|
67
|
+
| `binder` | Binder Pages | sheets of pockets |
|
|
68
|
+
| `case` | Convention Display Case | cards on a ledge |
|
|
69
|
+
| `random` | Random Draw | a pile; the draw button takes a name filter |
|
|
70
|
+
| `story` | Vertical Story Scroll | a column |
|
|
71
|
+
| `wall` | Sliding Gallery Wall | a row on a wall |
|
|
72
|
+
| `spotlight` | Spotlight Carousel | one card lit, its neighbours around it |
|
|
73
|
+
| `atlas` | Card Table | all the cards on a plane |
|
|
74
|
+
| `fan` | Fan of Cards | a hand |
|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
`jukebox` and `tower` were dropped in 0.8.0; they still open the deck (`collectionViewAliases`). The binder and case take `page-size` (1 to 100 cards) and `columns` (1 to 10; at most two on a small screen). The reader chooses the display with a row of buttons across the top: a radio group with one tab stop and the arrow keys.
|
|
79
|
+
|
|
80
|
+
## The address and theme
|
|
81
|
+
|
|
82
|
+
Add the boolean `address` attribute and the zoom, the display, the fan, the landing, Animate and Speed are kept in the page address (`?view=fan&fan=open&land=face-down&zoom=2`), so a link opens the same view. `theme="light"` or `theme="dark"` fixes the colours; without it they follow the reader. `--fuda-stage-height` sets the height of the view (default: the window less 440 px, between 300 and 620 px) so the controls stay on the first screen.
|
|
83
|
+
|
|
84
|
+
## Live 3D in a collection
|
|
85
|
+
|
|
86
|
+
`collection.live = { cards: live, item: (card) => itemFor(card) }` makes the card in focus turn in 3D on every display: see [Live 3D in a card](live-3d.md). For the piles and the binder in detail, see [Binders and piles](binder-and-piles.md).
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Frameworks and bundlers
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 9
|
|
5
|
+
description: Use Fuda in plain HTML with an import map, in a bundler, and in React, Vue, Svelte and Angular, including server rendering and the cards property.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Both elements are standard custom elements, so any framework that can render a custom tag can show them. The two rules that matter are the same everywhere: **import the registration module once, in the browser**, and **set `cards` as a property**, never as an attribute.
|
|
9
|
+
|
|
10
|
+
## Plain HTML with an import map
|
|
11
|
+
|
|
12
|
+
Without a bundler the browser has to find three things by name: the package, kazoku-ui's zoom bar (the collection needs it) and, for live 3D, `three`. An import map says where each lives. Serve `dist` and `node_modules/@johnmorrisdotca/kazoku-ui/dist` (or copies of them):
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<script type="importmap">
|
|
16
|
+
{ "imports": {
|
|
17
|
+
"@johnmorrisdotca/fuda-cards/collection-element": "/node_modules/@johnmorrisdotca/fuda-cards/dist/collection-element.js",
|
|
18
|
+
"@johnmorrisdotca/kazoku-ui/view-controls/define": "/node_modules/@johnmorrisdotca/kazoku-ui/dist/view-controls/define.js"
|
|
19
|
+
} }
|
|
20
|
+
</script>
|
|
21
|
+
<fuda-collection view="binder"></fuda-collection>
|
|
22
|
+
<script type="module">
|
|
23
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
24
|
+
document.querySelector('fuda-collection').cards = [{ id: 'one', name: 'Example', image: '/cards/one.jpg' }];
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The single card, `@johnmorrisdotca/fuda-cards/element`, imports only its own small modules and needs no import map for kazoku-ui.
|
|
29
|
+
|
|
30
|
+
## A bundler
|
|
31
|
+
|
|
32
|
+
A bundler resolves everything from `node_modules`. Import `@johnmorrisdotca/fuda-cards/element` or `/collection-element` once, anywhere that runs in the browser. The package marks these two files in `sideEffects`, so a bundler keeps the import even though nothing is used from it.
|
|
33
|
+
|
|
34
|
+
## React
|
|
35
|
+
|
|
36
|
+
Set the property with a ref. In TypeScript, declare the tags in JSX's intrinsic elements for your React version, or create the element with DOM calls in a wrapper.
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import { useEffect, useRef } from 'react';
|
|
40
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
41
|
+
|
|
42
|
+
export function Cards({ cards }) {
|
|
43
|
+
const ref = useRef(null);
|
|
44
|
+
useEffect(() => { if (ref.current) ref.current.cards = cards; }, [cards]);
|
|
45
|
+
return <fuda-collection ref={ref} view="binder" />;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Vue 3
|
|
50
|
+
|
|
51
|
+
Tell the compiler the tag is a custom element (`isCustomElement`, in the Vue plugin's `template.compilerOptions` for Vite) and bind the array as a DOM property with `.prop`:
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<script setup>
|
|
55
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
56
|
+
defineProps({ cards: { type: Array, required: true } });
|
|
57
|
+
</script>
|
|
58
|
+
<template><fuda-collection view="binder" :cards.prop="cards" /></template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Svelte
|
|
62
|
+
|
|
63
|
+
```svelte
|
|
64
|
+
<script>
|
|
65
|
+
import { onMount } from 'svelte';
|
|
66
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
67
|
+
export let cards = [];
|
|
68
|
+
let viewer;
|
|
69
|
+
onMount(() => { viewer.cards = cards; });
|
|
70
|
+
$: if (viewer) viewer.cards = cards;
|
|
71
|
+
</script>
|
|
72
|
+
<fuda-collection bind:this={viewer} view="binder"></fuda-collection>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Angular
|
|
76
|
+
|
|
77
|
+
Add `CUSTOM_ELEMENTS_SCHEMA` to the component's schemas and load the registration module in browser code. Property binding sets the array property.
|
|
78
|
+
|
|
79
|
+
```ts no-check
|
|
80
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
81
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
82
|
+
|
|
83
|
+
@Component({
|
|
84
|
+
selector: 'app-cards',
|
|
85
|
+
standalone: true,
|
|
86
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
87
|
+
template: '<fuda-collection view="binder" [cards]="cards"></fuda-collection>',
|
|
88
|
+
})
|
|
89
|
+
export class CardsComponent {
|
|
90
|
+
cards = [{ id: 'one', name: 'Example', image: '/cards/one.jpg' }];
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Server rendering
|
|
95
|
+
|
|
96
|
+
The elements extend `HTMLElement` when their module is evaluated, so importing one on a server fails with "HTMLElement is not defined". Import the registration module only on the client, after the DOM exists (in React, inside `useEffect` or a dynamic import with server rendering off), and render a placeholder on the server. The main entry, `@johnmorrisdotca/fuda-cards`, is safe on a server: it holds only the tables and the wear and stack maths.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { cardMaterials, stackHeightMm } from '@johnmorrisdotca/fuda-cards';
|
|
100
|
+
|
|
101
|
+
console.log(typeof document, cardMaterials.length, stackHeightMm(10, 0.3));
|
|
102
|
+
// undefined 13 3
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The integrations were bundled and exercised in Chromium with React 19, Angular 19, Vue 3 and Svelte 4; check your own framework version. There are no framework wrappers yet.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting started
|
|
3
|
+
section: tutorial
|
|
4
|
+
order: 1
|
|
5
|
+
description: Put your first Fuda card on a page, then a stack, a worn card and a collection, in a few minutes and with no build step.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Fuda Cards draws collectible cards as web components. A card is a frame around a picture you give it; a collection is a whole shelf of them. Nothing needs a framework or a 3D engine. This guide takes you from an empty page to a card, a stack of cards and a binder.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @johnmorrisdotca/fuda-cards
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The package is plain ES modules in `dist/`. It has one runtime dependency, [`@johnmorrisdotca/kazoku-ui`](https://github.com/johnmorrisdotca/kazoku-ui), which draws the zoom bar of the collection viewer. A single card needs nothing else.
|
|
19
|
+
|
|
20
|
+
## Your first card
|
|
21
|
+
|
|
22
|
+
Import the element once, then write the tag. The picture goes inside it, as a child.
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script type="module">
|
|
26
|
+
import '@johnmorrisdotca/fuda-cards/element';
|
|
27
|
+
</script>
|
|
28
|
+
<fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" description="A new explorer.">
|
|
29
|
+
<img src="rocket.jpg" alt="Explorer One rocket">
|
|
30
|
+
</fuda-card>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`variant` is `classic`, `sport` or `cosmic`; `finish` is `foil` or `matte`. The card is 300 px wide by default and keeps the 2.5 by 3.5 proportion of a real card: set the element's `width` in CSS to scale it, and everything inside scales with it.
|
|
34
|
+
|
|
35
|
+
On a page with no bundler, replace the bare name with the path of `dist/element.js` and serve the whole `dist` folder, or add an import map (see [Frameworks and bundlers](frameworks.md)).
|
|
36
|
+
|
|
37
|
+
## Turn it over and give it thickness
|
|
38
|
+
|
|
39
|
+
A card has two faces and an edge. `flipped` shows the back; `thickness` is in millimetres and drawn to scale.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
43
|
+
<fuda-card title="Relic" thickness="1.5" flipped></fuda-card>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## A stack, and a card that has been used
|
|
47
|
+
|
|
48
|
+
`stack` draws that many cards, as high as the count times the card's thickness. `material` takes the thickness of a real card stock. `wear` marks a card as played.
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
52
|
+
<fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
|
|
53
|
+
<fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
The numbers in `stack` and the words in `material` and `wear` come from tables the package exports as data, so you can build your own menu from them:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { cardMaterial, stackHeightMm, wearPresets } from '@johnmorrisdotca/fuda-cards';
|
|
62
|
+
|
|
63
|
+
const material = cardMaterial('paper-310-black-core');
|
|
64
|
+
console.log(material?.thicknessMm, stackHeightMm(52, material?.thicknessMm ?? 0.3));
|
|
65
|
+
console.log(wearPresets.map((preset) => preset.id).join(' '));
|
|
66
|
+
// 0.325 16.9
|
|
67
|
+
// perfect mint near-mint lightly-played moderately-played heavily-played damaged
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## A collection
|
|
71
|
+
|
|
72
|
+
`<fuda-collection>` takes a list of items in its `cards` property (a property, not an attribute) and shows them in one of ten displays.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<fuda-collection view="binder"></fuda-collection>
|
|
76
|
+
<script type="module">
|
|
77
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
78
|
+
document.querySelector('fuda-collection').cards = [
|
|
79
|
+
{ id: 'one', name: 'First card', image: '/cards/one.jpg', backImage: '/cards/one-back.jpg' },
|
|
80
|
+
{ id: 'two', name: 'Second card', image: '/cards/two.jpg' },
|
|
81
|
+
];
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
Change `view` to `deck`, `rolodex`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` to see the others; [Collections](collections.md) lists them all.
|
|
88
|
+
|
|
89
|
+
## Where to go next
|
|
90
|
+
|
|
91
|
+
- Every attribute of the card: [The card element](card-element.md).
|
|
92
|
+
- Why the page must not flash a raw picture before the card appears: [Troubleshooting](troubleshooting.md#the-picture-flashes-before-the-card-appears).
|
|
93
|
+
- How the package is built and why: [Architecture](architecture.md).
|
|
94
|
+
- The demos, to try each option with your eyes: the [Card Studio](https://johnmorrisdotca.github.io/fuda-cards/).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: アクセシビリティとテーマ
|
|
3
|
+
section: explanation
|
|
4
|
+
order: 10
|
|
5
|
+
description: Fudaのカードとコレクションが、キーボード、タッチ、スクリーンリーダー、動きの軽減のために行うこと、任せていること、設定できるすべての色と大きさです。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 組み込まれているもの
|
|
9
|
+
|
|
10
|
+
- **キーボード。** コレクションの表示ボタンはラジオグループで、タブ停止は1つ、矢印キーで選択が動きます。表示の中のカードは、アクセシブルな名前が「Inspect」とカード名のボタンで、EnterかSpaceで開きます。表示にフォーカスがあるとき、`+`、`-`、`0`でズームとFitができます。カードのAnimateボタンは`aria-pressed`を持つ本物のボタンです。
|
|
11
|
+
- **タッチ。** すべての操作は48 px四方以上です。カードの上から始めたドラッグやピンチも使え、動かなかったタップは、クリックとしてカードに渡されます。
|
|
12
|
+
- **動きの軽減。** `prefers-reduced-motion: reduce`のときは、カードの回転、裏返しの遷移、画像のパン、自動再生、ライブ3Dのカードがすべて止まります。飛ぶ動きと扇は、アニメーションなしで移り、どの動きも、動きありの場合と同じ位置で終わります。有効にするための設定は要りません。
|
|
13
|
+
- **予期しない動きはない。** カードが勝手に自動再生することはなく、閲覧者が動きの軽減を求めている場合は、自動回転も始まりません。
|
|
14
|
+
- **画像の説明は利用側の役目。** カードの絵は、スロットに入れたものそのものです。各`<img>`に`alt`を付けてください。コレクションの項目では、スクリーンリーダーが読み上げるのは`name`です。
|
|
15
|
+
|
|
16
|
+
## 利用側に任されていること
|
|
17
|
+
|
|
18
|
+
渡す画像のコントラスト、画像の説明、要素のまわりのページです。ブラウザー、支援技術、端末の確認範囲は限られています([制限](../../../README.md#limits)を参照)。ここにあるものは、デスクトップとスマートフォンの大きさのヘッドレスChromiumで確かめたもので、実機のスマートフォン、Safari、Firefoxでは確かめていません。
|
|
19
|
+
|
|
20
|
+
## ライトとダーク
|
|
21
|
+
|
|
22
|
+
コレクションは、初期値では閲覧者のライト/ダークの設定に従います。要素に`theme="light"`か`theme="dark"`を付けると、ページ側で決められます。カードスタジオとデモも、同じ理由でURLの`?theme=`を読みます。
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<fuda-collection view="deck" theme="dark"></fuda-collection>
|
|
26
|
+
<script type="module">
|
|
27
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
28
|
+
document.querySelector('fuda-collection').cards = [{ name: 'Alpha', image: '/a.jpg' }];
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 大きさと余白
|
|
33
|
+
|
|
34
|
+
| 設定 | 変わるもの |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `fuda-card`の`width` | カードの大きさ。内側はすべてコンテナー単位で比例して変わる。初期値300 px。 |
|
|
37
|
+
| `fuda-collection`の`--fuda-stage-height` | 表示の高さ。初期値はウィンドウの高さから440 pxを引いた値で、300から620 pxの間。 |
|
|
38
|
+
| `fuda-card`の`--fuda-perspective` | 3Dで回したときの奥行き。初期値`1000px`。 |
|
|
39
|
+
| `fuda-card`の`--fuda-edge` | 縁の色。任意のCSS背景。 |
|
|
40
|
+
| `--fuda-pan-duration` | 画像のパン1回の時間。 |
|
|
41
|
+
| `--fuda-card-spin-duration` | `card-spin`の1周の時間。初期値`180s`。 |
|
|
42
|
+
| `--fuda-yaw`、`--fuda-tilt` | `card-view`のときの角度。 |
|
|
43
|
+
| `--fuda-focus-x`、`--fuda-focus-y` | 画像で中心にする位置。 |
|
|
44
|
+
|
|
45
|
+
シャドウルートは外部のスタイルシートからは閉じているので、これらのカスタムプロパティが外へ開かれたインターフェースです。枠の色は`variant`と`finish`で決まります。
|
|
46
|
+
|
|
47
|
+
## ステージを画面に収める
|
|
48
|
+
|
|
49
|
+
ズームバーは表示の下にあります。ビューアーの上に置くものを短くして、操作が最初の画面に収まるようにしてください。低いウィンドウでは、`--fuda-stage-height`を小さくします。
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<style>fuda-collection { --fuda-stage-height: clamp(260px, calc(100svh - 620px), 620px); }</style>
|
|
53
|
+
<fuda-collection view="case"></fuda-collection>
|
|
54
|
+
<script type="module">
|
|
55
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
56
|
+
document.querySelector('fuda-collection').cards = [{ name: 'Alpha', image: '/a.jpg' }];
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 関連
|
|
61
|
+
|
|
62
|
+
カードが空白、またはちらつく場合は[困ったとき・よくある質問](troubleshooting.md)、動くものすべては[動きと回転](motion-and-spin.md)を参照してください。
|