@johnmorrisdotca/fuda-cards 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +14 -0
- package/README.md +466 -60
- package/dist/binder.d.ts +4 -6
- package/dist/binder.js +32 -23
- package/dist/card-markup.d.ts +2 -0
- package/dist/card-markup.js +59 -0
- package/dist/card-options.d.ts +131 -0
- package/dist/card-options.js +48 -0
- package/dist/card-styles.d.ts +2 -0
- package/dist/card-styles.js +314 -0
- package/dist/choice.d.ts +1 -1
- package/dist/choice.js +27 -23
- package/dist/collection-address.d.ts +8 -0
- package/dist/collection-address.js +52 -0
- package/dist/collection-binder-view.d.ts +9 -0
- package/dist/collection-binder-view.js +123 -0
- package/dist/collection-controls.d.ts +2 -0
- package/dist/collection-controls.js +143 -0
- package/dist/collection-deck.d.ts +11 -0
- package/dist/collection-deck.js +165 -0
- package/dist/collection-dialog.d.ts +2 -0
- package/dist/collection-dialog.js +28 -0
- package/dist/collection-element.d.ts +41 -63
- package/dist/collection-element.js +288 -472
- package/dist/collection-host.d.ts +5 -0
- package/dist/collection-host.js +1 -0
- package/dist/collection-icons.d.ts +3 -0
- package/dist/collection-icons.js +19 -0
- package/dist/collection-motion.d.ts +11 -0
- package/dist/collection-motion.js +72 -0
- package/dist/collection-styles.d.ts +4 -0
- package/dist/collection-styles.js +336 -0
- package/dist/collection-views.d.ts +8 -0
- package/dist/collection-views.js +8 -0
- package/dist/collection.d.ts +140 -11
- package/dist/collection.js +139 -33
- package/dist/element-define.d.ts +2 -0
- package/dist/element-define.js +3 -0
- package/dist/element.d.ts +20 -1
- package/dist/element.js +289 -98
- package/dist/index.d.ts +9 -52
- package/dist/index.js +5 -5
- package/dist/live-3d.d.ts +126 -0
- package/dist/live-3d.js +229 -0
- package/dist/materials.d.ts +117 -6
- package/dist/materials.js +191 -28
- package/dist/motion.d.ts +2 -0
- package/dist/motion.js +4 -0
- package/dist/pile-card.js +138 -91
- package/dist/pile.d.ts +61 -8
- package/dist/pile.js +89 -29
- package/dist/stack.d.ts +42 -6
- package/dist/stack.js +28 -3
- package/dist/version.d.ts +11 -0
- package/dist/version.js +11 -0
- package/dist/wear.d.ts +147 -9
- package/dist/wear.js +273 -89
- package/dist/zoom.d.ts +1 -1
- package/dist/zoom.js +73 -42
- package/docs/API.md +783 -0
- package/docs/collection-displays.md +1 -1
- package/docs/guides/accessibility-and-theming.md +62 -0
- package/docs/guides/architecture.md +53 -0
- package/docs/guides/binder-and-piles.md +83 -0
- package/docs/guides/bundlers.md +60 -0
- package/docs/guides/card-element.md +65 -0
- package/docs/guides/collections.md +86 -0
- package/docs/guides/embed-in-an-iframe.md +39 -0
- package/docs/guides/frameworks.md +132 -0
- package/docs/guides/getting-started.md +96 -0
- package/docs/guides/html-and-cdn.md +69 -0
- package/docs/guides/ja/accessibility-and-theming.md +62 -0
- package/docs/guides/ja/architecture.md +53 -0
- package/docs/guides/ja/binder-and-piles.md +83 -0
- package/docs/guides/ja/bundlers.md +60 -0
- package/docs/guides/ja/card-element.md +65 -0
- package/docs/guides/ja/collections.md +86 -0
- package/docs/guides/ja/embed-in-an-iframe.md +39 -0
- package/docs/guides/ja/frameworks.md +132 -0
- package/docs/guides/ja/getting-started.md +96 -0
- package/docs/guides/ja/html-and-cdn.md +69 -0
- package/docs/guides/ja/live-3d.md +75 -0
- package/docs/guides/ja/materials-and-stacks.md +73 -0
- package/docs/guides/ja/motion-and-spin.md +73 -0
- package/docs/guides/ja/troubleshooting.md +60 -0
- package/docs/guides/ja/typescript-and-node.md +45 -0
- package/docs/guides/ja/upgrading.md +56 -0
- package/docs/guides/ja/wear.md +63 -0
- package/docs/guides/live-3d.md +75 -0
- package/docs/guides/materials-and-stacks.md +73 -0
- package/docs/guides/motion-and-spin.md +73 -0
- package/docs/guides/troubleshooting.md +60 -0
- package/docs/guides/typescript-and-node.md +45 -0
- package/docs/guides/upgrading.md +56 -0
- package/docs/guides/wear.md +63 -0
- package/docs/live-3d.md +59 -0
- package/package.json +81 -11
|
@@ -0,0 +1,96 @@
|
|
|
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's own version is exported as `VERSION`, so a page can say which one it runs.
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
## Your first card
|
|
23
|
+
|
|
24
|
+
Import the element once, then write the tag. The picture goes inside it, as a child.
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<script type="module">
|
|
28
|
+
import '@johnmorrisdotca/fuda-cards/element';
|
|
29
|
+
</script>
|
|
30
|
+
<fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" description="A new explorer.">
|
|
31
|
+
<img src="rocket.jpg" alt="Explorer One rocket">
|
|
32
|
+
</fuda-card>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`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.
|
|
36
|
+
|
|
37
|
+
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 [HTML and CDN](html-and-cdn.md) and [Bundlers](bundlers.md)).
|
|
38
|
+
|
|
39
|
+
## Turn it over and give it thickness
|
|
40
|
+
|
|
41
|
+
A card has two faces and an edge. `flipped` shows the back; `thickness` is in millimetres and drawn to scale.
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
45
|
+
<fuda-card title="Relic" thickness="1.5" flipped></fuda-card>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## A stack, and a card that has been used
|
|
49
|
+
|
|
50
|
+
`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.
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
|
|
54
|
+
<fuda-card title="Deck" material="paper-310-black-core" stack="52" stack-messiness="0.3" stack-seed="7"></fuda-card>
|
|
55
|
+
<fuda-card title="Rookie" wear="moderately-played" wear-seed="7"></fuda-card>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+

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

|
|
88
|
+
|
|
89
|
+
Change `view` to `deck`, `rolodex`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` to see the others; [Collections](collections.md) lists them all.
|
|
90
|
+
|
|
91
|
+
## Where to go next
|
|
92
|
+
|
|
93
|
+
- Every attribute of the card: [The card element](card-element.md).
|
|
94
|
+
- Why the page must not flash a raw picture before the card appears: [Troubleshooting](troubleshooting.md#the-picture-flashes-before-the-card-appears).
|
|
95
|
+
- How the package is built and why: [Architecture](architecture.md).
|
|
96
|
+
- The demos, to try each option with your eyes: the [Card Studio](https://johnmorrisdotca.github.io/fuda-cards/).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HTML and CDN
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 9
|
|
5
|
+
description: Put a card on a page with no build step, from jsDelivr or unpkg, or with an import map for the collection and live 3D.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
A card needs one script tag and nothing else: `<fuda-card>` imports only its own small modules, so no import map is needed. Both CDNs answer for the package; `pnpm test:usage` opens each page below with the CDN's answers stood in by the package as npm packs it.
|
|
9
|
+
|
|
10
|
+
## From jsDelivr
|
|
11
|
+
|
|
12
|
+
jsDelivr bundles a subpath of the package with its dependencies when the address ends in `/+esm`.
|
|
13
|
+
|
|
14
|
+
```html no-check
|
|
15
|
+
<!doctype html>
|
|
16
|
+
<html lang="en">
|
|
17
|
+
<head>
|
|
18
|
+
<meta charset="utf-8" />
|
|
19
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
20
|
+
<title>Fuda Cards from jsDelivr</title>
|
|
21
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/fuda-cards/element/+esm"></script>
|
|
22
|
+
</head>
|
|
23
|
+
<body>
|
|
24
|
+
<fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" stack="10" wear="near-mint">
|
|
25
|
+
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='%23335'/%3E%3C/svg%3E" alt="Explorer One" />
|
|
26
|
+
</fuda-card>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## From unpkg
|
|
32
|
+
|
|
33
|
+
unpkg serves the package's own files; `?module` makes it rewrite the imports so that the browser can follow them.
|
|
34
|
+
|
|
35
|
+
```html no-check
|
|
36
|
+
<!doctype html>
|
|
37
|
+
<html lang="en">
|
|
38
|
+
<head>
|
|
39
|
+
<meta charset="utf-8" />
|
|
40
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
41
|
+
<title>Fuda Cards from unpkg</title>
|
|
42
|
+
<script type="module" src="https://unpkg.com/@johnmorrisdotca/fuda-cards/dist/element.js?module"></script>
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<fuda-card title="Explorer One" category="ROCKET" variant="sport" finish="matte" material="steel-0.5">
|
|
46
|
+
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='%23335'/%3E%3C/svg%3E" alt="Explorer One" />
|
|
47
|
+
</fuda-card>
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## The collection and live 3D from a CDN
|
|
53
|
+
|
|
54
|
+
`<fuda-collection>` draws its zoom bar with kazoku-ui, and live 3D loads `three`. Without a bundler, an import map says where each lives.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<script type="importmap">
|
|
58
|
+
{ "imports": {
|
|
59
|
+
"@johnmorrisdotca/fuda-cards/collection-element": "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/fuda-cards/collection-element/+esm"
|
|
60
|
+
} }
|
|
61
|
+
</script>
|
|
62
|
+
<fuda-collection view="binder"></fuda-collection>
|
|
63
|
+
<script type="module">
|
|
64
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
65
|
+
document.querySelector('fuda-collection').cards = [{ id: 'one', name: 'Example', image: 'one.jpg' }];
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The single card needs none of this. For a server's or a bundler's way of loading the same modules see [Bundlers](bundlers.md) and [Frameworks](frameworks.md).
|
|
@@ -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)を参照してください。
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: アーキテクチャ
|
|
3
|
+
section: explanation
|
|
4
|
+
order: 11
|
|
5
|
+
description: パッケージが小さなモジュールにどう分かれているか、ふつうのカードがほとんど何も読み込まない理由、srcの各ファイルの役割を説明します。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Fudaは、フレームワークも3Dエンジンも使わず、ESモジュールにコンパイルされるふつうのTypeScriptです。設計の原則は、**ページは使うものの分だけ負担する**ことです。摩耗のないカードは摩耗のコードを読み込まず、山のないカードは山のコードを読み込まず、画像だけのページはthree.jsを読み込みません。
|
|
9
|
+
|
|
10
|
+
## エントリーポイント
|
|
11
|
+
|
|
12
|
+
| エントリー | ファイル | 内容 | サイズ(圧縮前、gzip -9) |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| `@johnmorrisdotca/fuda-cards` | `dist/index.js` | 型と表:バリアント、仕上げ、素材、山のプリセット、山と摩耗の計算。DOMなし。 | 0.4 KB(ほかに依存モジュール) |
|
|
15
|
+
| `.../element` | `dist/element.js` | `<fuda-card>`を登録する。 | 21.4 KB、6.5 KB |
|
|
16
|
+
| `.../collection` | `dist/collection.js` | コレクションのデータの規則:`parseCollection`、表示、種類、扇の配置。DOMなし。 | 4.7 KB、1.6 KB |
|
|
17
|
+
| `.../collection-element` | `dist/collection-element.js` | `<fuda-collection>`を登録する。 | 45.1 KB、13.4 KB |
|
|
18
|
+
| `.../live-3d` | `dist/live-3d.js` | ライブ3Dのカードのフォーカスの方針。 | 7.5 KB、2.3 KB |
|
|
19
|
+
|
|
20
|
+
## 各エントリーを支えるモジュール
|
|
21
|
+
|
|
22
|
+
- **`element.ts`**はカードを描きます。2つの面、薄い面を重ねた縁、画像のスロット、Animateボタンとパン、回転です。`materials.ts`と`stack.ts`をインポートし、残りは必要なときに読み込みます。登録するクラス`FudaCard`もエクスポートされるので、サブクラスや型に使えます。
|
|
23
|
+
- **`wear.ts`**(17 KB)は独立したモジュールで、カードに`wear`属性があるときだけ`import()`で読み込まれます。摩耗のないカードは、以前とまったく同じに描かれます。
|
|
24
|
+
- **`pile-card.ts`**(13.7 KB)は、`<fuda-card stack>`の扇、取り出し、脇の山を受け持ち、カードが`fan`、`taken-off`、`pile-controls`を求めたときだけ読み込まれます。
|
|
25
|
+
- **`pile.ts`**は、すべての山が共有するものです。着地、扇の配置、時間の扱い(`animate`、`speed`、動きの軽減)です。カードとコレクションの両方が使うので、山はどこでも同じように動きます。
|
|
26
|
+
- **`stack.ts`**は、一番上の下にあるカードを、シードから毎回同じように並べます(シード付きの小さな乱数生成器mulberry32)。
|
|
27
|
+
- **`materials.ts`**は、出典のある厚みの表と、山のプリセットです。
|
|
28
|
+
- **`binder.ts`**は、シート、ポケット、めくれるページを作ります。
|
|
29
|
+
- **`zoom.ts`**と**`choice.ts`**は、コレクションをkazoku-uiの表示操作につなぎ、選択ボタンの列を描きます。
|
|
30
|
+
- **`collection-element.ts`**は、クラス`FudaCollection`で10種類の表示を描きます。
|
|
31
|
+
- **`live-3d.ts`**は、どのカードをライブにするかを決めます。コンテキスト、共有アセット、静止画、ピクセルの予算は、kazoku-uiの共有レンダラーのものです。
|
|
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
|
+
## 描画
|
|
42
|
+
|
|
43
|
+
カードはWebGLではなく、CSSの3D平面の重なりです。厚みは`calc(var(--mm) * 100cqw / 63)`なので要素の幅に従い、縁は面の間に置いた薄い平面の集まりです。山は、枚数が何枚でも1つの3Dシーンで、静止中は何も描きません。動きはCSSの変形と、自分で終わる1回きりのアニメーションで、タイマーで動くものはありません。WebGLを使うのはライブ3Dだけで、そこでもコンテキストは常に1つしかありません。
|
|
44
|
+
|
|
45
|
+
画像は、カードが画面上の大きさを持ち、スロットのすべての画像が読み込まれるまで隠されるので、元の画像が枠の外に出ることはありません([困ったとき・よくある質問](troubleshooting.md#カードが現れる前に画像がちらつく)を参照)。
|
|
46
|
+
|
|
47
|
+
## 依存
|
|
48
|
+
|
|
49
|
+
`@johnmorrisdotca/kazoku-ui`は実行時の依存です(ズームバー、共有レンダラー)。`three`は省略可能なピア依存で、利用側で用意します。`<fuda-card>`1枚だけなら、どちらも読み込みません。
|
|
50
|
+
|
|
51
|
+
## テスト
|
|
52
|
+
|
|
53
|
+
`pnpm test`は、表と規則の単体テストを実行します。`pnpm test:e2e`は、ソフトウェア描画のヘッドレスChromiumを、デスクトップとスマートフォンの大きさで、1ファイルずつ動かします。どちらも`pnpm check`とリリースに含まれます。[開発](../../../README.md#development)を参照してください。
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: バインダーと山
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 7
|
|
5
|
+
description: リングまたはジップのバインダーのページをめくり、カードの山を扇状に開き、1枚取り出し、animateとspeedで動きを調整します。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
収集家のすることの大半は、2種類の表示で見せられます。2枚のシートが向かい合って開く**バインダー**と、扇状に開いて1枚ずつカードを取り出せる**山**です。山は、`<fuda-collection>`(重ねたデッキ、ランダムに引く、カードの扇)でも、`<fuda-card stack>`でも、同じコードで描かれます。
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## バインダー
|
|
13
|
+
|
|
14
|
+
`view="binder"`は、2枚のシートが向かい合って開いたバインダーです。各シートは、わずかに光沢のある透明なポケットが並ぶページで、ポケット1つにカード1枚が入ります。シートは透明か黒で、リング側には穴の列があります。次へ・前へでページがめくれます。1枚のページが綴じ目を軸に振れ、曲がりながら動いて、裏側のポケットが見えます。
|
|
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
|
+
| 属性 | 値 | 初期値 |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| `binder` | `ring`、`zip`(ファスナーとつまみ付き) | `ring` |
|
|
27
|
+
| `cover` | `green`、`black`、`teal`、`navy`、`red` | `green` |
|
|
28
|
+
| `sheet` | `clear`、`black` | `clear` |
|
|
29
|
+
| `pockets` | `4`(2×2)、`9`(3×3)、`12`(横4×縦3) | `9` |
|
|
30
|
+
|
|
31
|
+
以前からの`page-size`と`columns`も使え、1枚のシートのポケット数を決めます。各設定は、表示の下のボタンの列にもあり、URLにも入ります。カードをクリックすると開きます。`animate="off"`や動きの軽減のときは、ページが即座に変わり、最後は同じ状態になります。
|
|
32
|
+
|
|
33
|
+
## デッキと、ほかのすべての山
|
|
34
|
+
|
|
35
|
+
重ねたデッキ(`view="deck"`)は、最大10枚のカードを、シードで決まる少し乱れた並びで描き(`deck-messiness`は0から1で初期値0.3、`deck-seed`)、その脇に山を置きます。**次へ**で一番上のカードがデッキから離れます。持ち上がり、横切って飛び、デッキの反対側の山に着地します。**前へ**で戻ります。「ランダムに引く」も山で、「カードの扇」は扇だけを見せる同じ山です。ロロデックスとスポットライトはカードを広げて見せるカルーセルで、山ではありません。
|
|
36
|
+
|
|
37
|
+
カードの着地は`deck-land`で決まります。`face-up`(初期値)は表向きのまま、`face-down`は縦軸を中心に横向きに、ページをめくるように裏返り、山にはカードの`backImage`かパッケージ自前の裏面が見えます。絵が逆さまになって着地することはありません。0.6.0の値`upside-down`も今まで通り受け付けられ、`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
|
+
## 山を扇状に開く、1枚取り出す
|
|
54
|
+
|
|
55
|
+
`fan="open"`は最大10枚を、トランプの手札のように弧状に広げ、それぞれのカードの大部分が見えるようにして、閉じるときは始めの位置にぴったり戻ります。開いた扇からも、扇を開いて閉じた山からも、カードを取り出せます。コレクションでは、ボタンは表示のすぐ下にあり、扇はURLに入ります(`?fan=open`)。`view="fan"`は扇だけを見せる同じ山で、現在のカードから`fan-size`枚(2から10)を扇にし、次へで扇にする範囲が先へ進みます。
|
|
56
|
+
|
|
57
|
+
`<fuda-card>`では、`stack`が山の役目を果たします。
|
|
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"`は、一番上の3枚を脇の山に移します。山の厚みは、中のカードの枚数分です。`card.takeOff(count)`と`card.putBack(count)`でも変えられます。
|
|
71
|
+
- `pile-controls`は、3つのボタン(扇、1枚取り出す、戻す)を描きます。どれも48 px以上で、カードの下に約70 pxの余白を残してください。
|
|
72
|
+
- `card.pileBounds`は、開いた扇や脇の山がカードの外へ広がる距離をカード幅で示します。変わると`fuda-pile`イベントが送られるので、ページ側が表示に合わせられます。
|
|
73
|
+
- 山のコードは別のモジュール(`dist/pile-card.js`)で、カードが`fan`、`taken-off`、`pile-controls`を求めたときだけ読み込まれます。ふつうのカードはこれを要求しません。
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
## Animateとspeed
|
|
78
|
+
|
|
79
|
+
`animate="off"`ですべての動きがなくなり(どれも即座に、まったく同じ位置で終わります)、`speed="slow"`か`"quick"`で、すべての動きが長くなる、または短くなります。`animate`は、属性がないときは**オン**です。動きはCSSの変形と、自分で終わる1回きりのアニメーションなので、表示が静止している間は何も動いておらず、閲覧者の動きの軽減の設定が常に優先されます。どちらも表示の下とURLにあります(`?animate=off&speed=quick`)。
|
|
80
|
+
|
|
81
|
+
## 山を回す
|
|
82
|
+
|
|
83
|
+
山の表示操作には、角度、傾き、自動回転があります(平らな表示にはありません)。そして、2つの山を含むテーブル全体が3Dで回り、後ろからはデッキの裏面と、裏返した山の表面が見えます。コレクションの中のオブジェクトは閲覧者に正対したままです。種類については[コレクション](collections.md)を参照してください。
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: バンドラー
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 10
|
|
5
|
+
description: Viteまたはwebpackでカードを使う方法です。要素は、ブラウザーで動くコードの中で1回インポートするだけで、ほかに設定はいりません。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
バンドラーはすべてを`node_modules`から解決します。`@johnmorrisdotca/fuda-cards/element`(コレクションなら`/collection-element`も)を、ブラウザーで動く場所のどこかで1回インポートしてください。パッケージは要素のファイルを副作用ありと印してあるので、インポートしたものを何も使わなくても、バンドラーはそのインポートを残します。どちらの例も、`pnpm test:usage`がnpmの作るとおりのパッケージからビルドし、できたページを開いて確かめています。
|
|
9
|
+
|
|
10
|
+
## Vite
|
|
11
|
+
|
|
12
|
+
```ts no-run
|
|
13
|
+
import "@johnmorrisdotca/fuda-cards/element";
|
|
14
|
+
import { type CardOptions, cardAttributes } from "@johnmorrisdotca/fuda-cards";
|
|
15
|
+
|
|
16
|
+
const options: CardOptions = { title: "Explorer One", category: "ROCKET", stack: 10, wear: "near-mint" };
|
|
17
|
+
const card = document.createElement("fuda-card");
|
|
18
|
+
for (const [name, value] of Object.entries(cardAttributes(options))) card.setAttribute(name, value);
|
|
19
|
+
document.getElementById("app")?.append(card);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!doctype html>
|
|
24
|
+
<html lang="en">
|
|
25
|
+
<head>
|
|
26
|
+
<meta charset="utf-8" />
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
28
|
+
<title>Fuda Cards with Vite</title>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="app"></div>
|
|
32
|
+
<script type="module" src="./main.ts"></script>
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## webpack
|
|
38
|
+
|
|
39
|
+
```js no-run
|
|
40
|
+
import "@johnmorrisdotca/fuda-cards/element";
|
|
41
|
+
|
|
42
|
+
const card = document.createElement("fuda-card");
|
|
43
|
+
card.setAttribute("title", "Explorer One");
|
|
44
|
+
card.setAttribute("variant", "cosmic");
|
|
45
|
+
document.body.append(card);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { fileURLToPath } from "node:url";
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
mode: "production",
|
|
53
|
+
entry: "./src/index.js",
|
|
54
|
+
output: { path: fileURLToPath(new URL("./dist", import.meta.url)), filename: "main.js" },
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 得られるもの
|
|
59
|
+
|
|
60
|
+
山、傷み、カードの山のためのモジュールは、カードがそれを必要としたときだけ読み込まれるので、ふつうのカードは軽く済みます。各エントリーポイントの大きさは[アーキテクチャ](architecture.md)にあります。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: カード要素
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 2
|
|
5
|
+
description: fuda-card要素のすべての属性、プロパティ、CSS変数と、それぞれの初期値、大きさと見た目の整え方を説明します。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`<fuda-card>`は、画像、またはスロットに入れたほかのHTMLを囲む枠です。`@johnmorrisdotca/fuda-cards/element`をインポートすると自分で登録され、必要なのはそのインポートだけです。メインのエントリー(`@johnmorrisdotca/fuda-cards`)は、同じオプションをTypeScriptの型と表として公開し、DOMには触れないので、サーバーでも安全にインポートできます。
|
|
9
|
+
|
|
10
|
+
## 枠
|
|
11
|
+
|
|
12
|
+
| 属性 | 値 | 働き |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `title` | テキスト | 上部のカード名。 |
|
|
15
|
+
| `category` | テキスト | 角に出す言葉。例:`ROCKET`。 |
|
|
16
|
+
| `subtitle` | テキスト | 画像の下の1行。 |
|
|
17
|
+
| `description` | テキスト | サブタイトルの下の文章。 |
|
|
18
|
+
| `number` | テキスト | 下部のカード番号。 |
|
|
19
|
+
| `rarity` | テキスト | 下部のレアリティの印。 |
|
|
20
|
+
| `variant` | `classic`、`sport`、`cosmic` | 枠の見た目。金、銀、紫。 |
|
|
21
|
+
| `finish` | `foil`、`matte` | 枠が光るかどうか。 |
|
|
22
|
+
| `flipped` | 真偽値 | 裏面(紺色のFudaの面)を見せる。 |
|
|
23
|
+
|
|
24
|
+
既定のスロットには画像を入れます。`<img>`でも、既存のインタラクティブなビューアーを含む任意のHTMLでも構いません。カードにはドラッグの処理がないので、そのビューアーが自分でポインターを扱います。
|
|
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.325 };
|
|
30
|
+
console.log(options.variant, options.finish);
|
|
31
|
+
// cosmic foil
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 大きさ
|
|
35
|
+
|
|
36
|
+
要素は初期値で幅300 px、`aspect-ratio: 2.5 / 3.5`で、内側の寸法はすべてコンテナー単位なので、CSSを1行書くだけでカード全体の大きさが変わります。
|
|
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
|
+
3Dで回すときの遠近は`--fuda-perspective`(初期値`1000px`)です。縁の色は`--fuda-edge`で、任意のCSS背景を指定できます。初期値は、classicの枠が金、ほかの枠がカード用紙のクリーム色です。ドロップシャドウは要素そのものに付いているので、カードとその面の間にある要素に`filter`を付けないでください。
|
|
45
|
+
|
|
46
|
+
## プロパティとメソッド
|
|
47
|
+
|
|
48
|
+
| メンバー | 内容 |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `card.wear` | 属性と同じ、摩耗のプリセット。空文字列を代入すると取り除かれる。 |
|
|
51
|
+
| `card.cardThicknessMm` | 実際に使われる厚み。`thickness`、なければ素材の厚み、なければ0.325。 |
|
|
52
|
+
| `card.stackCount` | 山の枚数。1から1000。 |
|
|
53
|
+
| `card.stackHeight` | 山の高さ(ミリメートル)。 |
|
|
54
|
+
| `card.heldCount` | 取り出した分を除いて、山に残っている枚数。 |
|
|
55
|
+
| `card.fanOpen` | 山が扇状に開いているときに真。 |
|
|
56
|
+
| `card.isMoving` | 画像がパンしているときに真。 |
|
|
57
|
+
| `card.takeOff(count?)`、`card.putBack(count?)` | カードを脇の山へ移す、戻す。 |
|
|
58
|
+
| `card.pileBounds` | 開いた扇や脇の山がカードの外へ広がる距離。カードの幅を単位とする。 |
|
|
59
|
+
| `card.setFocused(on)` | `autoplay="focus"`のために、このカードをフォーカス状態にする、または外す。 |
|
|
60
|
+
|
|
61
|
+
`pileBounds`が変わると、`fuda-pile`イベントが送られます。山、摩耗、動きのコードは別のモジュールです。[アーキテクチャ](architecture.md)を参照してください。
|
|
62
|
+
|
|
63
|
+
## 関連するガイド
|
|
64
|
+
|
|
65
|
+
厚みと山:[素材と山](materials-and-stacks.md)。使い込んだカード:[摩耗](wear.md)。回転とパン:[動きと回転](motion-and-spin.md)。扇と取り出し:[バインダーと山](binder-and-piles.md)。
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: コレクション
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 6
|
|
5
|
+
description: fuda-collectionでコレクション全体を10種類の表示で見せます。渡す一覧の入力規則、種類、メタデータ、URLの扱いを説明します。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`<fuda-collection>`は、渡した一覧を10種類の表示のどれかで見せ、閲覧者にズームバー、表示の選択、そして表示ごとの設定を用意します。一覧を用意するのは利用側で、Fudaは何も保存せず、アカウントも求めず、指定された画像のURL以外は何も取得しません。
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## カードを渡す
|
|
13
|
+
|
|
14
|
+
`@johnmorrisdotca/fuda-cards/collection-element`を1回インポートし、`cards`**プロパティ**を設定します(配列は属性にできません)。
|
|
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
|
+
入力は配列か、`cards`配列を持つオブジェクトです。各項目には`name`と`image`のURLが必要です。`id`は省略でき(省略すると位置が使われます)、重複はできません。`backImage`は任意で、なければパッケージ自前の紺色の裏面が使われます。
|
|
29
|
+
|
|
30
|
+
## 先に一覧を検査する
|
|
31
|
+
|
|
32
|
+
`parseCollection`は、要素が実行する検査と同じもので、ファイルを渡す前に自分で実行できるように公開されています。正規化した一覧を返すか、問題の項目を示す`Error`を投げます。
|
|
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?)`は、名前にフィルターの文字を含むカードから1枚を選び、ほかに一致があるときは現在のカードを避けます。一致がなければ`null`です。`movePage(index, length, pageSize, delta)`は、`delta`ページ先のページの最初の位置を返し、端では回り込みます。
|
|
52
|
+
|
|
53
|
+
## 種類
|
|
54
|
+
|
|
55
|
+
`kind`は項目が何かを表し、`"card"`(初期値。この項目ができる前に書かれたコレクションも、すべてカードとして扱われます)か`"object"`です。カードは平らで薄く裏があるので、3Dで回り、後ろから見え、山から取り出すと裏返しで着地します。オブジェクトは、ゲーム機のようなカードではないものの画像で、裏も厚みもないので、裏返ることはなく、いつも表向きに着地します。カードを1枚も含まないコレクションでは、角度、傾き、自動回転は出ず、URLにも角度が含まれません。混在するコレクションでは、操作はカードのためにあり、オブジェクトは閲覧者に正対したままです。オブジェクトも、扇状に開くことや山から取り出すことはできます。
|
|
56
|
+
|
|
57
|
+
## メタデータ
|
|
58
|
+
|
|
59
|
+
`metadata`は任意で、`set`、`number`、`edition`、`condition`、`grade`、`notes`(文字列)と、`year`、`quantity`(整数。`quantity`は1以上)を持てます。価格や評価があるとは仮定しません。
|
|
60
|
+
|
|
61
|
+
## 10種類の表示
|
|
62
|
+
|
|
63
|
+
| `view` | 表示 | 表示の種類 |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `deck` | 重ねたデッキ | 山と、その脇にもう1つの山 |
|
|
66
|
+
| `rolodex` | ロロデックス | カルーセル |
|
|
67
|
+
| `binder` | バインダーのページ | ポケット付きのシート |
|
|
68
|
+
| `case` | 展示ケース | 台に並べたカード |
|
|
69
|
+
| `random` | ランダムに引く | 山。引くボタンは名前で絞り込める |
|
|
70
|
+
| `story` | 縦スクロール | 1列 |
|
|
71
|
+
| `wall` | スライドするギャラリーウォール | 壁に並ぶ1行 |
|
|
72
|
+
| `spotlight` | スポットライト・カルーセル | 1枚が照らされ、周りに隣のカード |
|
|
73
|
+
| `atlas` | カードテーブル | すべてのカードを1つの平面に並べる |
|
|
74
|
+
| `fan` | カードの扇 | 手札 |
|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
`jukebox`と`tower`は0.8.0で廃止されましたが、今もデッキ表示として開きます(`collectionViewAliases`)。バインダーとケースは`page-size`(1から100枚)と`columns`(1から10。小さい画面では最大2)を受け付けます。表示は、閲覧者が上部のボタンの列で選びます。タブ停止が1つで矢印キーで選択が動くラジオグループです。
|
|
79
|
+
|
|
80
|
+
## URLとテーマ
|
|
81
|
+
|
|
82
|
+
真偽値の`address`属性を付けると、ズーム、表示、扇、着地、Animate、SpeedがページのURLに保存され(`?view=fan&fan=open&land=face-down&zoom=2`)、リンクを開くと同じ表示になります。`theme="light"`か`theme="dark"`で配色を固定でき、指定がなければ閲覧者の設定に従います。`--fuda-stage-height`は表示の高さを決め(初期値はウィンドウの高さから440 pxを引いた値で、300から620 pxの間)、操作が最初の画面に収まるようにします。
|
|
83
|
+
|
|
84
|
+
## コレクションでのライブ3D
|
|
85
|
+
|
|
86
|
+
`collection.live = { cards: live, item: (card) => itemFor(card) }`と設定すると、どの表示でも、フォーカスされたカードが3Dで回ります。[カード内のライブ3D](live-3d.md)を参照してください。山とバインダーの詳細は[バインダーと山](binder-and-piles.md)にあります。
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: iframeに埋め込む
|
|
3
|
+
section: how-to
|
|
4
|
+
order: 12
|
|
5
|
+
description: 自分で作らないページにカードを載せる方法です。埋め込みページのiframeを使い、設定はそのアドレスに入れます。
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`demo/embed.html`は、`<iframe>`に入れるために作ったページで、カード以外は何もなく、アドレスに書かれた内容を描きます。何も追跡せず、訪れた人の端末に何も残さず、指定された絵以外は何も読み込みません。
|
|
9
|
+
|
|
10
|
+
```html no-check
|
|
11
|
+
<!doctype html>
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="utf-8" />
|
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
16
|
+
<title>A Fuda card in an iframe</title>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<iframe
|
|
20
|
+
src="https://johnmorrisdotca.github.io/fuda-cards/demo/embed.html?title=Explorer+One&variant=sport&finish=foil&stack=10&card-spin=center"
|
|
21
|
+
title="Explorer One, a silver card on a stack of ten"
|
|
22
|
+
width="340"
|
|
23
|
+
height="480"
|
|
24
|
+
loading="lazy"
|
|
25
|
+
style="border: 0"
|
|
26
|
+
></iframe>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## アドレス
|
|
32
|
+
|
|
33
|
+
`<fuda-card>`の設定はどれも、属性名のままパラメーターにできます。`title`、`variant`、`finish`、`stack`、`wear`、`material`、`card-spin`などで、残りは[カード要素](card-element.md)にあります。スイッチは`1`にします。`image`は絵のアドレスで、指定しなければスターシップの絵になります。[ビルダー](https://johnmorrisdotca.github.io/fuda-cards/builder.html)は、選んだ設定から、幅と高さを含めたiframeを書き出します。
|
|
34
|
+
|
|
35
|
+
コレクションには専用のページ`demo/embed-collection.html`があり、コレクションの属性(`view`、`cover`、`pockets`)をパラメーターにでき、見本のカード18枚か、`cards`で指定したJSONファイルを表示します。
|
|
36
|
+
|
|
37
|
+
## 大きさ
|
|
38
|
+
|
|
39
|
+
ページはiframeに合わせます。カードはiframeが許す幅まで、最大300ピクセルの幅になり、縦横の比は保ちます。例のように、iframeの高さは幅の1.4倍に、影の分の余裕を少し足してください。
|