@johnmorrisdotca/fuda-cards 0.0.0-stage → 0.1.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 +91 -2
- package/assets/README.md +1 -0
- package/dist/collection-element.d.ts +22 -0
- package/dist/collection-element.js +154 -0
- package/dist/collection.d.ts +28 -0
- package/dist/collection.js +64 -0
- package/dist/element.d.ts +7 -0
- package/dist/element.js +28 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +2 -0
- package/docs/collection-displays.md +42 -0
- package/docs/collection-input.md +38 -0
- package/docs/framework-integration.md +75 -0
- package/package.json +65 -4
package/README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fuda Cards
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reusable collectible card frames for caller-provided images and interactive 3D viewers. The core is a standards-based web component, suitable for plain HTML, Angular, React, Vue, Svelte, and other frameworks that support custom elements. No framework or 3D engine is required by the component.
|
|
4
|
+
|
|
5
|
+
This is an early prototype: classic, sport and cosmic are exploratory CSS designs, not yet historically researched recreations or photorealistic materials. The demo uses a still from Uchusen Rockets; see [assets/README.md](assets/README.md) for its model credit.
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
[Open the Fuda Cards demos](https://johnmorrisdotca.github.io/fuda-cards/). The Card Studio and the collection and Pokémon binder demos are built together for GitHub Pages. From the studio, follow the collection links to explore them. Run `pnpm site` to build the static site in `site/`; serve that directory to review it. The Pages workflow runs the checks and deploys the site on pushes to `main`.
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
Requires Node 22+ and pnpm. Run `pnpm install`, `pnpm check`, then `pnpm dev` and open http://localhost:8000. `pnpm build` emits JavaScript and TypeScript declarations to `dist/`.
|
|
14
|
+
|
|
15
|
+
## Embed
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script type="module" src="/path/to/fuda-cards/dist/element.js"></script>
|
|
19
|
+
<fuda-card title="Explorer One" category="ROCKET" variant="cosmic" finish="foil" description="A new explorer.">
|
|
20
|
+
<img src="rocket.jpg" alt="Explorer One rocket">
|
|
21
|
+
</fuda-card>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
In a bundler, import `@johnmorrisdotca/fuda-cards/element` once before rendering `<fuda-card>`. Frameworks may require custom-element configuration (for example, Angular's `CUSTOM_ELEMENTS_SCHEMA`). Framework-specific wrappers have not yet been implemented; see [framework integration examples](docs/framework-integration.md). For published releases, install with `npm install @johnmorrisdotca/fuda-cards`.
|
|
25
|
+
|
|
26
|
+
The default slot accepts HTML, including an existing interactive 3D viewer; its owner handles rotation, zoom and model loading. The card has no drag-to-flip handler, leaving pointer interaction to that viewer. Control the card's reverse independently by adding or removing the `flipped` attribute. The demo provides a flip button. Attributes: `title`, `category`, `subtitle`, `description`, `number`, `rarity`, `variant` (`classic`, `sport`, `cosmic`), `finish` (`foil`, `matte`), `thickness` (millimetres, default `0.3`) and `flipped` (boolean). Set the element width to scale it. The main package entry exports the TypeScript options and available variants and finishes without registering the custom element.
|
|
27
|
+
|
|
28
|
+
3D integrations, framework-specific examples, polished front and back designs, accessibility validation, and photorealistic finishes remain future work.
|
|
29
|
+
|
|
30
|
+
Collection presentation prototypes are available as a reusable `<fuda-collection>` component. See the [collection demo](demo/collections-component.html) and [collection display notes](docs/collection-displays.md).
|
|
31
|
+
|
|
32
|
+
### Back face and thickness
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
The card has thickness, drawn to scale at the 63 mm wide card size: set `thickness` in millimetres (default `0.3`, a standard trading card of about 12 pt stock; roughly `0.8` for a metal card and `1` to `1.5` for a patch or relic card; `0` for a flat card). The edge is drawn from thin planes between the two faces, so it shows edge-on and at any angle, and it scales with the element's width (a 300px card is about 1.4px thick at the default). It is gold foil for the classic gold frame and card-stock cream for the sport and cosmic variants; override it with the `--fuda-edge` CSS custom property (any CSS background). The drop shadow is on the element itself, so a `filter` must not be added to anything between the card and its faces.
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<fuda-card title="Relic" thickness="1.5"></fuda-card>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Whole-card rotation
|
|
43
|
+
|
|
44
|
+
Set `card-spin="center"` for a slow 3D turn around the card’s vertical center, or `card-spin="corner"` for a 3D spin like an ice skater: the card keeps its full size and turns a full 360° around the vertical axis through its bottom-left corner, which stays still at the middle of the element, and shows its back half way round. The card sweeps out to both sides of that point, so give it room (a stage about three times its width and twice its height). Both rotate the entire card, including either face and its content. The default is one turn every 180 seconds; set `--fuda-card-spin-duration` to a positive CSS duration such as `30s`. Set `card-spin-direction="reverse"` to reverse the rotation. Add `card-spin-paused` to pause at the current angle, and remove it to resume. Remove `card-spin` to stop and reset the rotation. These attributes are independent of the artwork `motion` and `playing` attributes and the card’s `flipped` state. Reduced-motion preferences disable the rotation and the flip transition.
|
|
45
|
+
|
|
46
|
+
To drive the turn from your own controls instead of the built-in animation, add the boolean `card-view` attribute and set the CSS custom properties `--fuda-yaw` and `--fuda-tilt` (angles, for example `40deg`); the pivot is the one chosen by `card-spin`. The Card Studio does this with [`@johnmorrisdotca/kazoku-ui`](https://www.npmjs.com/package/@johnmorrisdotca/kazoku-ui) view controls (angle, tilt, Auto-turn, Front, zoom out, 2x, zoom in, Fit, pan, drag and pinch, kept in the address), which also zoom and move the whole stage so the full sweep can always be seen. That package is used by the demo only (a dev dependency); `<fuda-card>` itself has no dependencies. `--fuda-perspective` (default `1000px`) sets the card’s perspective.
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<fuda-card title="Explorer" card-spin="center" style="--fuda-card-spin-duration: 30s">
|
|
50
|
+
<img src="rocket.jpg" alt="Explorer rocket">
|
|
51
|
+
</fuda-card>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To review, run `pnpm install` and `pnpm dev`, then open the Card Studio. Under **Card rotation**, choose **Rotate around center** or **Spin around bottom corner**. The view controls under the card turn and tip it (Angle, Tilt), start **Auto-turn**, and zoom with **−**, **2×**, **+** and **Fit** (Ctrl or Command with the wheel, or a pinch, also zoom; zoomed in, a drag or the arrows move the view). The Card Studio opens at full card size; **Fit** is one press away and shows the whole sweep, and the corner stays at the middle of the stage at every zoom. Choose **Fast** to see a full turn in eight seconds, and try the direction control and **Flip card**. Auto-turn does not start by itself when your operating system or browser asks for reduced motion. The spin is decorative; use the separate flip control to choose the face.
|
|
55
|
+
|
|
56
|
+
### Moving artwork
|
|
57
|
+
|
|
58
|
+
Set `motion="pan"` on a card containing a slotted `<img>` to enable an Animate button on a tall image. By default the card starts on a still, cropped view; add the boolean `playing` attribute to start with motion. Tapping Animate starts the pan, and tapping Stop returns to the still. A host can add or remove `playing` to control the state. Set `--fuda-focus-x` and `--fuda-focus-y` (for example `50%` and `20%`) to choose the focal point. Cards without the pan option show a still, fully visible image. `pan-direction="up"` starts at the bottom; the default is down. The image travels back and forth by default; set `pan-loop="restart"` to repeat in one direction. Set the CSS custom property `--fuda-pan-duration` (for example, `16s`) to control the duration of each pass. If the image is not taller than the window after filling its width, there may be no vertical distance to pan. Reduced-motion preferences disable the animation and preserve the focused still. This option applies to images; moving a 3D camera is a separate future integration owned by the viewer.
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<fuda-card title="Starship" motion="pan" pan-direction="down" style="--fuda-pan-duration: 16s">
|
|
62
|
+
<img src="starship.jpg" alt="Starship">
|
|
63
|
+
</fuda-card>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Planned JSON, API, scanned-card and interactive-content inputs are outlined in [docs/collection-input.md](docs/collection-input.md).
|
|
67
|
+
|
|
68
|
+
## Pokémon binder demo
|
|
69
|
+
|
|
70
|
+
Open `demo/tcgdex.html` through the local server to browse the Pokémon Base Set as full-card images supplied by [TCGdex](https://tcgdex.dev/). Search by name or number, change pages and select a card to enlarge it. This standalone demo fetches public set data and remote images in the browser; it requires an internet connection. No API key, personal collection storage, or image hosting by Fuda is involved. A missing image or failed request is reported in the UI. Card images and metadata are provided by TCGdex; consult provider terms before deploying a public demo.
|
|
71
|
+
|
|
72
|
+
## Collection viewer
|
|
73
|
+
|
|
74
|
+
Run `pnpm dev` and open `/demo/collections-component.html`. Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage? }`. Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique. Set `view` to `deck`, `rolodex`, `binder`, `case`, `jukebox`, `random`, `story`, `wall`, `tower`, `spotlight`, or `atlas`. Set `page-size` for the binder and case (1–100 cards) and `columns` (1–10) for their grid; small screens use at most two columns. In random view, filter card names to limit the draw; the draw button is disabled when no cards match.
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<fuda-collection view="deck"></fuda-collection>
|
|
78
|
+
<script type="module">
|
|
79
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
80
|
+
document.querySelector('fuda-collection').cards = [
|
|
81
|
+
{ id: 'one', name: 'My card', image: '/cards/front.jpg', backImage: '/cards/back.jpg' }
|
|
82
|
+
];
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
These are early display prototypes: the case and rotating displays use CSS perspective rather than fully modeled 3D devices; the atlas is a draggable, zoomable plane rather than an unbounded or virtualized canvas. The demo can save and load named collections in the current browser using localStorage; this is not account-based sync or a backup. Configurable case geometry, integrated 3D content, and full browser and accessibility testing remain to be completed. Atlas supports drag, a zoom slider, and a basic two-finger pinch; touch behaviour still needs browser testing.
|
|
87
|
+
|
|
88
|
+
Saved demo collections are scoped to the selected profile. Use “Import older saved collections” to copy pre-profile saves without overwriting same-named collections; the originals remain intact. The demo supports JSON export and deletion, and storage stays local to this browser.
|
|
89
|
+
|
|
90
|
+
The collection component demo includes three fictional demo users—Alex, Sam, and Riley—with different example collections. Select a user to switch the displayed cards. These are local demo profiles, not accounts; the existing named-collection save/load remains local to the browser and separate from the demo profiles.
|
|
91
|
+
|
|
92
|
+
Development priorities and handoff notes: [feature roadmap](docs/feature-roadmap.md) · [work log](docs/work-log.md).
|
package/assets/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The demo image `starship-v3-preview.jpg` is cropped from `docs/images/main-painted.jpg` in John Morris's uchusen-rockets repository. It depicts the modified SpaceX Starship Block 3 model by Clarence365, licensed CC BY 4.0: https://sketchfab.com/3d-models/spacex-starship-block-3-6f6c6f88a3eb4b4d822fdca66733fbb2 . The original screenshot is retained as `uchusen-main-painted.jpg`. The model was reduced, rescaled, separated into parts, and had logos and serial numbers removed in uchusen-rockets. Screenshot cropped for this preview.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CollectionCard } from './collection.js';
|
|
2
|
+
export declare class FudaCollection extends HTMLElement {
|
|
3
|
+
private root;
|
|
4
|
+
private data;
|
|
5
|
+
private index;
|
|
6
|
+
private zoom;
|
|
7
|
+
private pageSize;
|
|
8
|
+
private selected;
|
|
9
|
+
private back;
|
|
10
|
+
private drawFilter;
|
|
11
|
+
static get observedAttributes(): string[];
|
|
12
|
+
set cards(value: CollectionCard[]);
|
|
13
|
+
get cards(): CollectionCard[];
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
attributeChangedCallback(): void;
|
|
16
|
+
private get currentView();
|
|
17
|
+
private move;
|
|
18
|
+
private image;
|
|
19
|
+
private open;
|
|
20
|
+
private renderDialog;
|
|
21
|
+
private render;
|
|
22
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { collectionViews, parseCollection, randomDrawIndex, movePage } from './collection.js';
|
|
2
|
+
export class FudaCollection extends HTMLElement {
|
|
3
|
+
root = this.attachShadow({ mode: 'open' });
|
|
4
|
+
data = [];
|
|
5
|
+
index = 0;
|
|
6
|
+
zoom = 1;
|
|
7
|
+
pageSize = 9;
|
|
8
|
+
selected = null;
|
|
9
|
+
back = false;
|
|
10
|
+
drawFilter = "";
|
|
11
|
+
static get observedAttributes() { return ['view', 'page-size', 'columns']; }
|
|
12
|
+
set cards(value) { this.data = parseCollection(value); this.index = Math.min(this.index, Math.max(0, this.data.length - 1)); this.render(); }
|
|
13
|
+
get cards() { return this.data.map(c => ({ ...c, ...(c.metadata ? { metadata: { ...c.metadata } } : {}) })); }
|
|
14
|
+
connectedCallback() { this.render(); }
|
|
15
|
+
attributeChangedCallback() { this.pageSize = Math.min(100, Math.max(1, Math.floor(Number(this.getAttribute('page-size')) || 9))); this.index = 0; this.render(); }
|
|
16
|
+
get currentView() { let v = this.getAttribute('view'); return collectionViews.some(x => x.id === v) ? v : 'deck'; }
|
|
17
|
+
move(n) { if (!this.data.length)
|
|
18
|
+
return; if (['binder', 'case'].includes(this.currentView)) {
|
|
19
|
+
this.index = movePage(this.index, this.data.length, this.pageSize, n);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.index = (this.index + n + this.data.length) % this.data.length;
|
|
23
|
+
} this.render(); }
|
|
24
|
+
image(c) { let button = document.createElement('button'); button.className = 'card'; button.setAttribute('aria-label', `Inspect ${c.name}`); let img = document.createElement('img'); img.src = c.image; img.alt = c.name; img.loading = 'lazy'; img.onerror = () => { img.replaceWith(document.createTextNode(`Image unavailable: ${c.name}`)); }; button.append(img); button.onclick = () => this.open(c); return button; }
|
|
25
|
+
open(c) { this.selected = c; this.back = false; this.renderDialog(); }
|
|
26
|
+
renderDialog() { let dlg = this.root.querySelector('dialog'); dlg.replaceChildren(); let close = document.createElement('button'); close.textContent = 'Close'; close.onclick = () => dlg.close(); dlg.append(close); if (this.selected) {
|
|
27
|
+
let img = document.createElement('img');
|
|
28
|
+
img.className = 'detail';
|
|
29
|
+
img.src = this.back && this.selected.backImage ? this.selected.backImage : this.selected.image;
|
|
30
|
+
img.alt = `${this.selected.name}, ${this.back ? 'back' : 'front'}`;
|
|
31
|
+
let label = document.createElement('p');
|
|
32
|
+
label.textContent = this.selected.name;
|
|
33
|
+
dlg.append(img, label);
|
|
34
|
+
if (this.selected.backImage) {
|
|
35
|
+
let flip = document.createElement('button');
|
|
36
|
+
flip.textContent = this.back ? 'Show front' : 'Show back';
|
|
37
|
+
flip.onclick = () => { this.back = !this.back; this.renderDialog(); };
|
|
38
|
+
dlg.append(flip);
|
|
39
|
+
}
|
|
40
|
+
} if (!dlg.open)
|
|
41
|
+
dlg.showModal(); }
|
|
42
|
+
render() {
|
|
43
|
+
if (!this.isConnected)
|
|
44
|
+
return;
|
|
45
|
+
this.root.innerHTML = `<style>
|
|
46
|
+
:host{display:block;color:#f6f4f1;font:16px system-ui}*{box-sizing:border-box}.shell{background:#20212c;padding:1rem;border-radius:1rem}header,.nav{display:flex;gap:.6rem;align-items:center;justify-content:center;flex-wrap:wrap}button,select{font:inherit;color:inherit;background:#353747;border:1px solid #79798c;border-radius:.5rem;padding:.55rem .8rem;cursor:pointer}button:focus-visible,select:focus-visible{outline:3px solid #ffd27e}.stage{position:relative;height:min(65vh,620px);min-height:300px;overflow:auto;border-radius:1rem;margin:1rem 0;background:radial-gradient(ellipse,#52495a,#222330 68%);touch-action:pan-y}.card{padding:0;border:0;background:transparent;line-height:0}.card img{width:100%;height:100%;object-fit:contain;border-radius:5%;box-shadow:0 6px 16px #0009}.stack .card{position:absolute;width:min(64vw,300px);height:86%;top:7%;left:50%;transition:transform .25s}.grid{display:grid;grid-template-columns:repeat(var(--columns,3),minmax(0,1fr));gap:1rem;padding:1rem;align-content:start}.grid .card{height:clamp(130px,24vw,220px)}.case{perspective:800px;background:linear-gradient(#615346,#222)!important}.case .card{transform:perspective(600px) rotateX(-15deg)}.wall{display:flex;gap:1rem;align-items:center;padding:1rem}.wall .card{height:90%;flex:0 0 190px}.story{display:flex;flex-direction:column;align-items:center;gap:1rem;padding:1rem}.story .card{width:min(75%,300px);flex:0 0 90%}.atlas{touch-action:none}.plane{position:absolute;transform-origin:0 0;display:grid;gap:18px;grid-template-columns:repeat(var(--atlas-cols,5),140px);padding:30px;will-change:transform}.plane .card{height:195px}.jukebox{border:12px solid #aa7147;box-shadow:inset 0 0 20px #fbb579}.spotlight{background:radial-gradient(ellipse at center,#e5ce99,#454054 40%,#171822 78%)}dialog{color:white;background:#242632;border:1px solid #777;border-radius:1rem;text-align:center;max-width:95vw;max-height:95vh}dialog::backdrop{background:#000c}.detail{display:block;height:min(70vh,600px);max-width:80vw;object-fit:contain;margin:1rem auto}.empty{text-align:center;padding:3rem} @media(max-width:500px){.grid{grid-template-columns:repeat(min(2,var(--columns,3)),minmax(0,1fr))}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}
|
|
47
|
+
</style><section class="shell"><header><label>Display <select aria-label="Collection display"></select></label></header><div class="stage" aria-label="Collection"></div><div class="nav"><button class="prev">← Previous</button><span class="count" aria-live="polite"></span><button class="next">Next →</button><label class="draw-filter" hidden>Filter cards <input type="search" aria-label="Filter cards for random draw"></label><button class="draw" hidden>Draw a card</button><label class="zoom" hidden>Zoom <input type="range" min="0.4" max="2" step="0.1" value="${this.zoom}" aria-label="Zoom card atlas"></label></div><dialog aria-label="Card detail"></dialog></section>`;
|
|
48
|
+
let select = this.root.querySelector('select');
|
|
49
|
+
collectionViews.forEach(v => select.add(new Option(v.label, v.id)));
|
|
50
|
+
select.value = this.currentView;
|
|
51
|
+
select.onchange = () => this.setAttribute('view', select.value);
|
|
52
|
+
let stage = this.root.querySelector('.stage');
|
|
53
|
+
let count = this.root.querySelector('.count');
|
|
54
|
+
count.textContent = this.data.length ? (['binder', 'case'].includes(this.currentView) ? `Page ${Math.floor(this.index / this.pageSize) + 1} / ${Math.ceil(this.data.length / this.pageSize)}` : `${this.index + 1} / ${this.data.length}`) : 'No cards';
|
|
55
|
+
for (const [selector, delta] of [['.prev', -1], ['.next', 1]]) {
|
|
56
|
+
const button = this.root.querySelector(selector);
|
|
57
|
+
button.disabled = !this.data.length;
|
|
58
|
+
button.onclick = () => { this.move(delta); this.root.querySelector(selector).focus(); };
|
|
59
|
+
}
|
|
60
|
+
if (this.currentView === 'random') {
|
|
61
|
+
const filter = this.root.querySelector('.draw-filter');
|
|
62
|
+
filter.hidden = false;
|
|
63
|
+
const input = filter.querySelector('input');
|
|
64
|
+
input.value = this.drawFilter;
|
|
65
|
+
input.oninput = () => { this.drawFilter = input.value; const draw = this.root.querySelector('.draw'); draw.disabled = !this.data.some(c => c.name.toLocaleLowerCase().includes(this.drawFilter.trim().toLocaleLowerCase())); };
|
|
66
|
+
const draw = this.root.querySelector('.draw');
|
|
67
|
+
draw.hidden = false;
|
|
68
|
+
draw.disabled = !this.data.some(c => c.name.toLocaleLowerCase().includes(this.drawFilter.trim().toLocaleLowerCase()));
|
|
69
|
+
draw.onclick = () => { const next = randomDrawIndex(this.data, this.index, this.drawFilter); if (next === null)
|
|
70
|
+
return; this.index = next; this.render(); this.root.querySelector('.draw').focus(); };
|
|
71
|
+
}
|
|
72
|
+
if (!this.data.length) {
|
|
73
|
+
stage.innerHTML = '<p class="empty">No cards in this collection.</p>';
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let view = this.currentView;
|
|
77
|
+
if (view === 'binder' || view === 'case') {
|
|
78
|
+
stage.classList.add('grid', view);
|
|
79
|
+
const columns = Math.min(10, Math.max(1, Math.floor(Number(this.getAttribute('columns')) || 3)));
|
|
80
|
+
stage.style.setProperty('--columns', String(columns));
|
|
81
|
+
let start = Math.floor(this.index / this.pageSize) * this.pageSize;
|
|
82
|
+
this.data.slice(start, start + this.pageSize).forEach(c => stage.append(this.image(c)));
|
|
83
|
+
}
|
|
84
|
+
else if (view === 'wall' || view === 'story') {
|
|
85
|
+
stage.classList.add(view);
|
|
86
|
+
this.data.forEach(c => stage.append(this.image(c)));
|
|
87
|
+
}
|
|
88
|
+
else if (view === 'atlas') {
|
|
89
|
+
stage.classList.add('atlas');
|
|
90
|
+
let plane = document.createElement('div');
|
|
91
|
+
plane.className = 'plane';
|
|
92
|
+
this.data.forEach(c => plane.append(this.image(c)));
|
|
93
|
+
stage.append(plane);
|
|
94
|
+
let x = 0, y = 0;
|
|
95
|
+
const paint = () => plane.style.transform = `translate(${x}px,${y}px) scale(${this.zoom})`;
|
|
96
|
+
paint();
|
|
97
|
+
let start = null;
|
|
98
|
+
stage.onpointerdown = e => { if (e.target.closest('button'))
|
|
99
|
+
return; start = { x: e.clientX, y: e.clientY, px: x, py: y }; stage.setPointerCapture(e.pointerId); };
|
|
100
|
+
stage.onpointermove = e => { if (start) {
|
|
101
|
+
x = start.px + e.clientX - start.x;
|
|
102
|
+
y = start.py + e.clientY - start.y;
|
|
103
|
+
paint();
|
|
104
|
+
} };
|
|
105
|
+
stage.onpointerup = () => { start = null; };
|
|
106
|
+
stage.onpointercancel = () => { start = null; };
|
|
107
|
+
let touchDistance = 0;
|
|
108
|
+
stage.addEventListener('touchstart', e => { if (e.touches.length === 2) {
|
|
109
|
+
touchDistance = Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY);
|
|
110
|
+
start = null;
|
|
111
|
+
} }, { passive: true });
|
|
112
|
+
stage.addEventListener('touchmove', e => { if (e.touches.length === 2 && touchDistance) {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
const distance = Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY);
|
|
115
|
+
this.zoom = Math.min(2, Math.max(.4, this.zoom * distance / touchDistance));
|
|
116
|
+
touchDistance = distance;
|
|
117
|
+
this.root.querySelector('.zoom input').value = String(this.zoom);
|
|
118
|
+
paint();
|
|
119
|
+
} }, { passive: false });
|
|
120
|
+
stage.addEventListener('touchend', () => { touchDistance = 0; }, { passive: true });
|
|
121
|
+
let wrap = this.root.querySelector('.zoom');
|
|
122
|
+
wrap.hidden = false;
|
|
123
|
+
wrap.querySelector('input').oninput = e => { this.zoom = Number(e.target.value); paint(); };
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
stage.classList.add('stack', view);
|
|
127
|
+
let count = Math.min(3, this.data.length);
|
|
128
|
+
for (let d = count - 1; d >= 0; d--) {
|
|
129
|
+
let c = this.data[(this.index + d) % this.data.length], el = this.image(c);
|
|
130
|
+
let offset = view === 'rolodex' ? d * 42 : view === 'spotlight' ? d * 70 : d * 14;
|
|
131
|
+
let rotation = view === 'rolodex' ? d * 12 : view === 'tower' ? 0 : d * 5;
|
|
132
|
+
el.style.transform = `translateX(calc(-50% + ${offset}px)) rotate(${rotation}deg) scale(${1 - d * .08})`;
|
|
133
|
+
el.style.opacity = String(1 - d * .2);
|
|
134
|
+
stage.append(el);
|
|
135
|
+
}
|
|
136
|
+
let startX = 0;
|
|
137
|
+
stage.addEventListener('touchstart', e => { if (e.touches.length === 1)
|
|
138
|
+
startX = e.touches[0].clientX; }, { passive: true });
|
|
139
|
+
stage.addEventListener('touchend', e => { if (e.changedTouches.length !== 1)
|
|
140
|
+
return; const dx = e.changedTouches[0].clientX - startX; if (Math.abs(dx) > 45) {
|
|
141
|
+
if (e.cancelable)
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
this.move(dx < 0 ? 1 : -1);
|
|
144
|
+
} }, { passive: false });
|
|
145
|
+
stage.addEventListener('keydown', e => { if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
this.move(e.key === 'ArrowRight' ? 1 : -1);
|
|
148
|
+
this.root.querySelector('.stack .card:last-child')?.focus();
|
|
149
|
+
} });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!customElements.get('fuda-collection'))
|
|
154
|
+
customElements.define('fuda-collection', FudaCollection);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Browser-native collection viewer. Import this module to register <fuda-collection>. */
|
|
2
|
+
export type CollectionView = 'deck' | 'rolodex' | 'binder' | 'case' | 'jukebox' | 'random' | 'story' | 'wall' | 'tower' | 'spotlight' | 'atlas';
|
|
3
|
+
export interface CollectionMetadata {
|
|
4
|
+
set?: string;
|
|
5
|
+
year?: number;
|
|
6
|
+
number?: string;
|
|
7
|
+
edition?: string;
|
|
8
|
+
condition?: string;
|
|
9
|
+
grade?: string;
|
|
10
|
+
quantity?: number;
|
|
11
|
+
notes?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CollectionCard {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
image: string;
|
|
17
|
+
backImage?: string;
|
|
18
|
+
metadata?: CollectionMetadata;
|
|
19
|
+
}
|
|
20
|
+
export declare const collectionViews: ReadonlyArray<{
|
|
21
|
+
id: CollectionView;
|
|
22
|
+
label: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function parseCollection(value: unknown): CollectionCard[];
|
|
25
|
+
/** Choose a matching card, avoiding the current card when another match exists. */
|
|
26
|
+
export declare function randomDrawIndex(cards: CollectionCard[], current: number, filter: string, random?: () => number): number | null;
|
|
27
|
+
/** Return the first card index of a wrapped page. */
|
|
28
|
+
export declare function movePage(index: number, length: number, pageSize: number, delta: number): number;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const collectionViews = [
|
|
2
|
+
{ id: 'deck', label: 'Overlapping Deck' }, { id: 'rolodex', label: 'Rolodex' }, { id: 'binder', label: 'Binder Pages' },
|
|
3
|
+
{ id: 'case', label: 'Convention Display Case' }, { id: 'jukebox', label: 'Jukebox Carousel' }, { id: 'random', label: 'Random Draw' },
|
|
4
|
+
{ id: 'story', label: 'Vertical Story Scroll' }, { id: 'wall', label: 'Sliding Gallery Wall' }, { id: 'tower', label: 'Flip Tower' },
|
|
5
|
+
{ id: 'spotlight', label: 'Spotlight Carousel' }, { id: 'atlas', label: 'Infinite Card Atlas' }
|
|
6
|
+
];
|
|
7
|
+
export function parseCollection(value) {
|
|
8
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && 'cards' in value)
|
|
9
|
+
value = value.cards;
|
|
10
|
+
if (!Array.isArray(value))
|
|
11
|
+
throw new Error('Collection must be an array or an object containing a cards array.');
|
|
12
|
+
const ids = new Set();
|
|
13
|
+
return value.map((item, i) => {
|
|
14
|
+
if (!item || typeof item !== 'object')
|
|
15
|
+
throw new Error(`Card ${i + 1} must be an object.`);
|
|
16
|
+
const c = item;
|
|
17
|
+
if (typeof c.name !== 'string' || !c.name.trim() || typeof c.image !== 'string' || !c.image.trim())
|
|
18
|
+
throw new Error(`Card ${i + 1} needs a name and image URL.`);
|
|
19
|
+
const id = typeof c.id === 'string' && c.id ? c.id : String(i);
|
|
20
|
+
if (ids.has(id))
|
|
21
|
+
throw new Error(`Duplicate card id: ${id}`);
|
|
22
|
+
ids.add(id);
|
|
23
|
+
if (c.backImage !== undefined && typeof c.backImage !== 'string')
|
|
24
|
+
throw new Error(`Card ${i + 1} backImage must be a URL.`);
|
|
25
|
+
let metadata;
|
|
26
|
+
if (c.metadata !== undefined) {
|
|
27
|
+
if (!c.metadata || typeof c.metadata !== 'object' || Array.isArray(c.metadata))
|
|
28
|
+
throw new Error(`Card ${i + 1} metadata must be an object.`);
|
|
29
|
+
const m = c.metadata;
|
|
30
|
+
for (const key of ['set', 'number', 'edition', 'condition', 'grade', 'notes'])
|
|
31
|
+
if (m[key] !== undefined && typeof m[key] !== 'string')
|
|
32
|
+
throw new Error(`Card ${i + 1} metadata.${key} must be a string.`);
|
|
33
|
+
for (const key of ['year', 'quantity'])
|
|
34
|
+
if (m[key] !== undefined && (typeof m[key] !== 'number' || !Number.isSafeInteger(m[key]) || m[key] < (key === 'quantity' ? 1 : 0)))
|
|
35
|
+
throw new Error(`Card ${i + 1} metadata.${key} must be a valid integer.`);
|
|
36
|
+
metadata = {};
|
|
37
|
+
for (const key of ['set', 'number', 'edition', 'condition', 'grade', 'notes'])
|
|
38
|
+
if (typeof m[key] === 'string')
|
|
39
|
+
metadata[key] = m[key];
|
|
40
|
+
for (const key of ['year', 'quantity'])
|
|
41
|
+
if (typeof m[key] === 'number')
|
|
42
|
+
metadata[key] = m[key];
|
|
43
|
+
}
|
|
44
|
+
return { id, name: c.name, image: c.image, ...(c.backImage ? { backImage: c.backImage } : {}), ...(metadata ? { metadata } : {}) };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Choose a matching card, avoiding the current card when another match exists. */
|
|
48
|
+
export function randomDrawIndex(cards, current, filter, random = Math.random) {
|
|
49
|
+
const query = filter.trim().toLocaleLowerCase();
|
|
50
|
+
const matches = cards.map((card, index) => ({ card, index })).filter(({ card }) => card.name.toLocaleLowerCase().includes(query));
|
|
51
|
+
if (!matches.length)
|
|
52
|
+
return null;
|
|
53
|
+
const alternatives = matches.filter(({ index }) => index !== current);
|
|
54
|
+
const pool = alternatives.length ? alternatives : matches;
|
|
55
|
+
return pool[Math.floor(random() * pool.length)].index;
|
|
56
|
+
}
|
|
57
|
+
/** Return the first card index of a wrapped page. */
|
|
58
|
+
export function movePage(index, length, pageSize, delta) {
|
|
59
|
+
if (length === 0)
|
|
60
|
+
return 0;
|
|
61
|
+
const pages = Math.ceil(length / pageSize);
|
|
62
|
+
const page = Math.floor(index / pageSize);
|
|
63
|
+
return (((page + delta) % pages + pages) % pages) * pageSize;
|
|
64
|
+
}
|
package/dist/element.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const template = document.createElement('template');
|
|
2
|
+
template.innerHTML = `<style>
|
|
3
|
+
:host{display:inline-block;width:300px;aspect-ratio:2.5/3.5;perspective:var(--fuda-perspective,1000px);container-type:inline-size;filter:drop-shadow(0 12px 14px #0006);--edge:linear-gradient(90deg,#f6dc8c,#b98631 50%,#f6dc8c);font-family:Georgia,serif;color:#27201b}*{box-sizing:border-box}.rotation{height:100%;transform-style:preserve-3d;transform-origin:center center}:host([card-spin="center"]) .rotation{animation:fuda-turn var(--fuda-card-spin-duration, 180s) linear infinite}:host([card-spin="corner"]) .rotation{transform-origin:0 100%;transform:translate(50%,-50%);animation:fuda-corner-turn var(--fuda-card-spin-duration, 180s) linear infinite}:host([card-spin-direction="reverse"]) .rotation{animation-direction:reverse}:host([card-spin-paused]) .rotation{animation-play-state:paused}@keyframes fuda-turn{to{transform:rotateY(360deg)}}@keyframes fuda-corner-turn{from{transform:translate(50%,-50%) rotateY(0)}to{transform:translate(50%,-50%) rotateY(360deg)}}:host([card-view]) .rotation{animation:none;transform:rotateX(var(--fuda-tilt,0deg)) rotateY(var(--fuda-yaw,0deg))}:host([card-view][card-spin="corner"]) .rotation{transform:translate(50%,-50%) rotateX(var(--fuda-tilt,0deg)) rotateY(var(--fuda-yaw,0deg))}@media (prefers-reduced-motion:reduce){:host([card-spin]) .rotation{animation:none}:host .card{transition:none}}.card{--t:calc(var(--mm,.3) * 100cqw / 63);height:100%;position:relative;transform-style:preserve-3d;transition:transform .65s}:host([flipped]) .card{transform:rotateY(180deg)}.face{position:absolute;inset:0;border-radius:15px;backface-visibility:hidden;overflow:hidden}.front{transform:translateZ(calc(var(--t) / 2));padding:13px;background:linear-gradient(135deg,#fbdf87,#ab742c 35%,#ffe9a6 58%,#ae792d);border:2px solid #9c702d}.inner{height:100%;padding:12px;background:linear-gradient(150deg,#f9edc8,#d6b477);border:2px solid #76512a;display:flex;flex-direction:column;gap:8px}.heading,.footer{display:flex;justify-content:space-between;align-items:center;gap:5px}.heading{font-weight:bold;font-size:20px}.badge{font:700 10px sans-serif;letter-spacing:.12em}.art{position:relative;height:53%;border:5px ridge #dcc18a;box-shadow:0 2px 5px #47301488;background:radial-gradient(circle at 50% 35%,#7496a1,#273c4c);overflow:hidden}.art ::slotted(*){width:100%;height:100%;object-fit:contain;display:block}:host([motion="pan"]) .art ::slotted(img){object-fit:cover;object-position:var(--fuda-focus-x, 50%) var(--fuda-focus-y, 25%)}:host([motion="pan"][playing]) .art ::slotted(img){animation:fuda-pan var(--fuda-pan-duration, 12s) ease-in-out infinite alternate}:host([motion="pan"][pan-loop="restart"]) .art ::slotted(img){animation-direction:normal}:host([motion="pan"][pan-direction="up"]) .art ::slotted(img){animation-direction:alternate-reverse}:host([motion="pan"][pan-direction="up"][pan-loop="restart"]) .art ::slotted(img){animation-direction:reverse}@keyframes fuda-pan{from{object-position:50% 0%}to{object-position:50% 100%}}@media (prefers-reduced-motion:reduce){:host([motion="pan"][playing]) .art ::slotted(img){animation:none}}.motion-button{position:absolute;right:6px;bottom:6px;z-index:1;border:1px solid #fff9;border-radius:20px;padding:5px 9px;background:#101827dd;color:white;font:600 10px system-ui;cursor:pointer}.motion-button:focus-visible{outline:3px solid white;outline-offset:2px}.motion-button[hidden]{display:none}.subtitle{text-align:center;font:italic 11px Georgia}.description{border-top:1px solid #9d8054;padding-top:9px;font-size:13px;line-height:1.35;flex:1}.footer{border-top:1px solid #9d8054;padding-top:5px;font:700 9px sans-serif;letter-spacing:.08em}.back{transform:rotateY(180deg) translateZ(calc(var(--t) / 2));background:radial-gradient(ellipse at center,#b78745 0 12%,#152d46 13% 27%,#386988 28% 31%,#10233b 32% 62%,#d2b074 63% 66%,#182c45 67%);border:11px solid #b39158;display:grid;place-items:center;color:#f7e9bf}.emblem{width:125px;height:125px;border:2px solid #edd18c;border-radius:50%;display:grid;place-items:center;background:#17334a;box-shadow:0 0 0 7px #967344,0 0 30px #e6c98288;font:bold 23px Georgia;letter-spacing:.12em}.shine{pointer-events:none;position:absolute;inset:0;opacity:.35;mix-blend-mode:screen;background:linear-gradient(125deg,transparent 25%,#fff9 36%,transparent 48%,#7cf6 56%,#f9a5 62%,transparent 70%)}:host([finish=matte]) .shine{display:none}.edge{position:absolute;background:var(--fuda-edge,var(--edge))}:host([variant=sport]),:host([variant=cosmic]){--edge:#ece4d2}:host([variant=sport]) .front{background:linear-gradient(135deg,#ebedef,#525e69,#fff,#47505d)}:host([variant=sport]) .inner{background:linear-gradient(145deg,#eef1ee,#aebac1);border-color:#394c5b}:host([variant=sport]) .art{border-color:#a9b9c0}:host([variant=cosmic]) .front{background:linear-gradient(130deg,#c9b4ff,#433b83,#dabdff,#503969)}:host([variant=cosmic]) .inner{background:linear-gradient(145deg,#e6dafa,#a997cd);border-color:#584378}
|
|
4
|
+
</style><div class="rotation"><div class="card"><div class="face front"><div class="inner"><div class="heading"><span id="title"></span><span class="badge" id="category"></span></div><div class="art"><slot></slot><button class="motion-button" type="button" aria-pressed="false" hidden>▶ Animate</button></div><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><div class="face back"><div class="emblem">FUDA</div><div class="shine"></div></div><i class="edge" style="left:50%;top:0;width:calc(100% - 30px);height:var(--t);transform:translate(-50%,-50%) rotate(0deg) rotateX(90deg)"></i><i class="edge" style="left:50%;top:100%;width:calc(100% - 30px);height:var(--t);transform:translate(-50%,-50%) rotate(0deg) rotateX(90deg)"></i><i class="edge" style="left:0;top:50%;width:var(--t);height:calc(100% - 30px);transform:translate(-50%,-50%) rotateY(90deg)"></i><i class="edge" style="left:100%;top:50%;width:var(--t);height:calc(100% - 30px);transform:translate(-50%,-50%) rotateY(90deg)"></i><i class="edge" style="left:2.20px;top:9.70px;width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(-67.5deg) rotateX(90deg)"></i><i class="edge" style="left:9.70px;top:2.20px;width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(-22.5deg) rotateX(90deg)"></i><i class="edge" style="left:2.20px;top:calc(100% - 9.70px);width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(67.5deg) rotateX(90deg)"></i><i class="edge" style="left:9.70px;top:calc(100% - 2.20px);width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(22.5deg) rotateX(90deg)"></i><i class="edge" style="left:calc(100% - 2.20px);top:9.70px;width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(67.5deg) rotateX(90deg)"></i><i class="edge" style="left:calc(100% - 9.70px);top:2.20px;width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(22.5deg) rotateX(90deg)"></i><i class="edge" style="left:calc(100% - 2.20px);top:calc(100% - 9.70px);width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(-67.5deg) rotateX(90deg)"></i><i class="edge" style="left:calc(100% - 9.70px);top:calc(100% - 2.20px);width:11.48px;height:var(--t);transform:translate(-50%,-50%) rotate(-22.5deg) rotateX(90deg)"></i></div></div>`;
|
|
5
|
+
const defaults = { title: 'Untitled', category: 'COLLECTIBLE', subtitle: 'An item worth collecting', description: 'Add a description to tell its story.', number: 'NO. 001', rarity: '✦' };
|
|
6
|
+
export class FudaCard extends HTMLElement {
|
|
7
|
+
static observedAttributes = ['title', 'category', 'subtitle', 'description', 'number', 'rarity', 'motion', 'playing', 'thickness'];
|
|
8
|
+
constructor() { super(); const root = this.attachShadow({ mode: 'open' }); root.append(template.content.cloneNode(true)); root.querySelector('button')?.addEventListener('click', () => this.toggleAttribute('playing')); }
|
|
9
|
+
connectedCallback() { this.render(); }
|
|
10
|
+
attributeChangedCallback(name) { if (name === 'motion' && this.getAttribute('motion') !== 'pan' && this.hasAttribute('playing'))
|
|
11
|
+
this.removeAttribute('playing'); if (this.shadowRoot)
|
|
12
|
+
this.render(); }
|
|
13
|
+
render() { const mm = Number.parseFloat(this.getAttribute('thickness') ?? ''); const card = this.shadowRoot?.querySelector('.card'); if (mm >= 0)
|
|
14
|
+
card?.style.setProperty('--mm', String(mm));
|
|
15
|
+
else
|
|
16
|
+
card?.style.removeProperty('--mm'); const button = this.shadowRoot?.querySelector('.motion-button'); if (button) {
|
|
17
|
+
button.hidden = this.getAttribute('motion') !== 'pan';
|
|
18
|
+
const active = this.hasAttribute('playing');
|
|
19
|
+
button.textContent = active ? '■ Stop' : '▶ Animate';
|
|
20
|
+
button.setAttribute('aria-pressed', String(active));
|
|
21
|
+
} for (const key of FudaCard.observedAttributes) {
|
|
22
|
+
const node = this.shadowRoot?.getElementById(key);
|
|
23
|
+
if (node)
|
|
24
|
+
node.textContent = this.getAttribute(key) || (defaults[key] ?? '');
|
|
25
|
+
} }
|
|
26
|
+
}
|
|
27
|
+
if (typeof customElements !== 'undefined' && !customElements.get('fuda-card'))
|
|
28
|
+
customElements.define('fuda-card', FudaCard);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A card's finish and visual family. */
|
|
2
|
+
export type CardFinish = 'foil' | 'matte';
|
|
3
|
+
export type CardVariant = 'classic' | 'sport' | 'cosmic';
|
|
4
|
+
export interface CardOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
category?: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
number?: string;
|
|
10
|
+
rarity?: string;
|
|
11
|
+
variant?: CardVariant;
|
|
12
|
+
finish?: CardFinish;
|
|
13
|
+
/** Card thickness in millimetres at the 63 mm wide card size; default 0.3, 0 for a flat card. */
|
|
14
|
+
thickness?: number;
|
|
15
|
+
flipped?: boolean;
|
|
16
|
+
motion?: 'still' | 'pan';
|
|
17
|
+
playing?: boolean;
|
|
18
|
+
panDirection?: 'down' | 'up';
|
|
19
|
+
panLoop?: 'alternate' | 'restart';
|
|
20
|
+
cardSpin?: 'center' | 'corner';
|
|
21
|
+
cardSpinDirection?: 'normal' | 'reverse';
|
|
22
|
+
cardSpinPaused?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const cardVariants: readonly CardVariant[];
|
|
25
|
+
export declare const cardFinishes: readonly CardFinish[];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Collection displays
|
|
2
|
+
|
|
3
|
+
Fuda supplies reusable frames for a caller's cards and reusable ways to display collections on websites. The hosting site supplies the card data and artwork or interactive content. Initial versions of eleven layouts now exist in `<fuda-collection>`. They are prototypes; the detailed capabilities below remain design goals unless described as implemented in the README.
|
|
4
|
+
|
|
5
|
+
## Binder and booklet
|
|
6
|
+
|
|
7
|
+
- Configurable page grids, such as 3 columns by 4 rows or 4 by 4, and responsive alternatives for small screens.
|
|
8
|
+
- An optional binder or booklet presentation with covers, pages, sleeves, and opening and page-turning animations; a simple grid remains available.
|
|
9
|
+
- Multiple named collections or binders, with their own cards, ordering, and optional titles and covers.
|
|
10
|
+
- Page controls that work with keyboard and touch, with a reduced-motion alternative.
|
|
11
|
+
- Present each card's front and back, and preserve interaction with any 3D viewer in the card window. Page turning, card flipping, and rotating an object must be distinct actions.
|
|
12
|
+
|
|
13
|
+
## Rotating card index
|
|
14
|
+
|
|
15
|
+
- A rotating, circular index of cards inspired by a desktop card file, with next/previous controls and a clearly visible selected card.
|
|
16
|
+
- Touch, pointer, and keyboard access, with reduced-motion support.
|
|
17
|
+
- Adapt the number of visible cards and layout to the available space.
|
|
18
|
+
|
|
19
|
+
## Convention display case
|
|
20
|
+
|
|
21
|
+
- A three-dimensional tabletop showcase with cards on angled, stepped risers, inspired by convention and card-shop cases. Configurable rows and columns (including 10 × 10), tilt, spacing, row height and overlap; avoid assuming one fixed industry layout.
|
|
22
|
+
- Configurable case materials and appearance: glass or clear acrylic lid, frame, lighting and optional graded holders. Keep reflections from hiding card content.
|
|
23
|
+
- Browse the case using touch or pointer, with keyboard-accessible card selection and a reduced-motion option. Select any card to open a large, full-screen-style detail view, then return to the same position. Preserve card flip controls and interaction with a 3D model inside the selected card.
|
|
24
|
+
- Support a responsive alternative for small displays and large collections; avoid rendering a separate active 3D viewer per card at once. The host controls the collection and card content.
|
|
25
|
+
- Research: [angled modular display risers](https://boxboy.co/products/modular-display-risers), [staggered rear rows](https://dhoptcg.com/?product=glass-display-shelves), and [a 13-column, 7-row cabinet](https://www.jz-shop.com.tw/en/graded-card-display-case-slim). These examples show different capacities, so dimensions and overlap should remain adjustable.
|
|
26
|
+
|
|
27
|
+
## Jukebox-style display
|
|
28
|
+
|
|
29
|
+
- Present the collection inside a jukebox-like device. Browse cards in the device, then select a card to bring it into a focused view.
|
|
30
|
+
- Provide a clear way back to browsing and preserve the selected card and collection position.
|
|
31
|
+
- Keep card flip and interactive content controls separate from the device navigation; make browse and selection usable by keyboard, touch, and pointer.
|
|
32
|
+
- Allow the host to configure device styling and the cards supplied. Support a reduced-motion alternative to mechanical animations.
|
|
33
|
+
|
|
34
|
+
## Feeling lucky
|
|
35
|
+
|
|
36
|
+
- Pick a random card from a caller-provided collection, optionally limited to a current filter or binder.
|
|
37
|
+
- Show the selected card and provide a way to choose another. Empty and single-card collections must be handled gracefully.
|
|
38
|
+
- Random selection is for discovery; it is not a claim of cryptographic randomness or a rarity-based draw unless a host explicitly supplies that behavior.
|
|
39
|
+
|
|
40
|
+
## Integration direction
|
|
41
|
+
|
|
42
|
+
Keep presentation separate from card data and artwork. Accept caller-supplied cards and interactive content; do not bundle rockets, devices, or a particular 3D engine into the core. Support plain HTML and common frameworks through standard custom elements, with optional adapters where helpful. Define how a host supplies card content and identity before implementing collection persistence or navigation. The project's card styles and realistic materials remain work in progress.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Collection input
|
|
2
|
+
|
|
3
|
+
Fuda should display real collections as well as cards generated from other projects. The collection viewer accepts a JSON array or an object containing a cards array. The broader integration features below remain planned.
|
|
4
|
+
|
|
5
|
+
## Sources
|
|
6
|
+
|
|
7
|
+
- A JSON file, a JavaScript array or object supplied by the host, and data fetched from an API by the host.
|
|
8
|
+
- Adapters can map different external APIs and collection exports into Fuda's common card format. The host controls authentication, fetch, refresh and error handling; Fuda does not require a server or assume an external service.
|
|
9
|
+
- Treat image and asset URLs as supplied by the host, and give useful feedback when a file, URL, or field is missing. Support partial data and optional front and back images.
|
|
10
|
+
|
|
11
|
+
## Card data
|
|
12
|
+
|
|
13
|
+
An example supported collection format:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"version": 1,
|
|
18
|
+
"name": "Rocket collection",
|
|
19
|
+
"cards": [
|
|
20
|
+
{
|
|
21
|
+
"id": "starship-v3",
|
|
22
|
+
"name": "Starship Block 3",
|
|
23
|
+
"image": "https://example.com/starship-front.jpg",
|
|
24
|
+
"backImage": "https://example.com/starship-back.jpg",
|
|
25
|
+
"metadata": { "year": 2026, "number": "001" }
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Represent photographed or scanned cards as full-card front and back images, so collectors can display what they already own. Alternatively, use a Fuda frame with a separate image or host-provided interactive artwork in its window.
|
|
32
|
+
- Keep collector details optional: set, year, card number, edition, condition, grade, quantity, notes, and other metadata. Do not assume every item has a market price or grade.
|
|
33
|
+
- Provide stable IDs for selection and navigation; validate malformed input and report errors without discarding valid cards.
|
|
34
|
+
- Allow host-supplied visual content, including interactive 3D elements, in addition to serializable image references; JSON alone cannot contain a live 3D viewer.
|
|
35
|
+
- Each collection presentation (binder, case, jukebox, rotating index, random viewer) consumes the same normalized collection and can expose filtering and selection to the host.
|
|
36
|
+
|
|
37
|
+
No accounts, collection storage, third-party integrations, importers, or synchronization are implemented yet. Avoid requiring accounts or uploading a collection to Fuda merely to display it.
|
|
38
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Framework integration
|
|
2
|
+
|
|
3
|
+
Build with `pnpm build`, then install or link the package in the host application. The package is not published yet. Import each element's registration entry once in browser code. `cards` is a JavaScript **property**, not an HTML attribute: assign an array of `{ id, name, image, backImage? }` objects. Image URLs are supplied by the host. Equivalent integrations were bundled and exercised in Chromium using React 19, Angular 19, Vue 3 and Svelte 4; check your framework version and server-rendering setup.
|
|
4
|
+
|
|
5
|
+
## Plain HTML
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<script type="module">
|
|
9
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
10
|
+
document.querySelector('fuda-collection').cards = [
|
|
11
|
+
{id: 'one', name: 'Example', image: '/cards/one.jpg'}
|
|
12
|
+
];
|
|
13
|
+
</script>
|
|
14
|
+
<fuda-collection view="binder"></fuda-collection>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For an unbundled page, replace the bare import with the URL of `dist/collection-element.js` and serve the complete `dist` directory.
|
|
18
|
+
|
|
19
|
+
## React
|
|
20
|
+
|
|
21
|
+
Use a ref to set the array property. In TypeScript projects, declare the custom element in JSX's intrinsic element types for your React version, or create it with DOM APIs in a wrapper.
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import {useEffect, useRef} from 'react';
|
|
25
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
26
|
+
function Cards({cards}) {
|
|
27
|
+
const ref = useRef(null);
|
|
28
|
+
useEffect(() => { if (ref.current) ref.current.cards = cards; }, [cards]);
|
|
29
|
+
return <fuda-collection ref={ref} view="binder" />;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Angular
|
|
34
|
+
|
|
35
|
+
Add `CUSTOM_ELEMENTS_SCHEMA` to the standalone component's schemas (or to its NgModule), and load the registration entry in browser code. Angular property binding sets the array property.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
|
39
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
40
|
+
@Component({selector: 'app-cards', standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
41
|
+
template: '<fuda-collection view="binder" [cards]="cards"></fuda-collection>'})
|
|
42
|
+
export class CardsComponent {
|
|
43
|
+
cards = [{id: 'one', name: 'Example', image: '/cards/one.jpg'}];
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Vue 3
|
|
48
|
+
|
|
49
|
+
Configure the Vue compiler's `isCustomElement` option for `fuda-collection` (for Vite, in the Vue plugin's `template.compilerOptions`). Use a DOM property binding for the array.
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<script setup>
|
|
53
|
+
import '@johnmorrisdotca/fuda-cards/collection-element';
|
|
54
|
+
defineProps({ cards: {type: Array, required: true} });
|
|
55
|
+
</script>
|
|
56
|
+
<template><fuda-collection view="binder" :cards.prop="cards" /></template>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Svelte
|
|
60
|
+
|
|
61
|
+
Assign the property to a bound element; changes to `cards` update it after mounting.
|
|
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
|
+
These elements extend `HTMLElement` at module evaluation time. For server-side rendering, import their registration modules only on the client after the DOM exists; render a placeholder on the server. Do not import a browser registration entry in server-only code.
|
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/fuda-cards",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Fuda Cards: collectible card frames for images and interactive 3D content.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/element.js",
|
|
8
|
+
"./dist/collection-element.js"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./element": {
|
|
18
|
+
"types": "./dist/element.d.ts",
|
|
19
|
+
"import": "./dist/element.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./collection": {
|
|
23
|
+
"types": "./dist/collection.d.ts",
|
|
24
|
+
"import": "./dist/collection.js"
|
|
25
|
+
},
|
|
26
|
+
"./collection-element": {
|
|
27
|
+
"types": "./dist/collection-element.d.ts",
|
|
28
|
+
"import": "./dist/collection-element.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"docs/collection-displays.md",
|
|
35
|
+
"docs/collection-input.md",
|
|
36
|
+
"docs/framework-integration.md",
|
|
37
|
+
"assets/README.md"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
46
|
+
"check": "pnpm typecheck && pnpm build && pnpm test",
|
|
47
|
+
"test:e2e": "pnpm build && node --test test/e2e/*.e2e.mjs",
|
|
48
|
+
"dev": "pnpm build && node scripts/dev.mjs",
|
|
49
|
+
"site": "pnpm build && node scripts/site.mjs"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@johnmorrisdotca/kazoku-ui": "^0.2.1",
|
|
53
|
+
"typescript": "5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"packageManager": "pnpm@10.11.0",
|
|
59
|
+
"homepage": "https://johnmorrisdotca.github.io/fuda-cards/",
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/johnmorrisdotca/fuda-cards.git"
|
|
63
|
+
},
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/johnmorrisdotca/fuda-cards/issues"
|
|
66
|
+
}
|
|
67
|
+
}
|