@johnmorrisdotca/fuda-cards 0.1.0 → 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 CHANGED
@@ -23,15 +23,27 @@ Requires Node 22+ and pnpm. Run `pnpm install`, `pnpm check`, then `pnpm dev` an
23
23
 
24
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
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`) 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.
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
27
 
28
28
  3D integrations, framework-specific examples, polished front and back designs, accessibility validation, and photorealistic finishes remain future work.
29
29
 
30
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
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
+
32
42
  ### Whole-card rotation
33
43
 
34
- Set `card-spin="center"` for a slow 3D turn around the card’s vertical center, or `card-spin="corner"` for a flat spin around its upper-left corner. 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.
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.
35
47
 
36
48
  ```html
37
49
  <fuda-card title="Explorer" card-spin="center" style="--fuda-card-spin-duration: 30s">
@@ -39,7 +51,7 @@ Set `card-spin="center"` for a slow 3D turn around the card’s vertical center,
39
51
  </fuda-card>
40
52
  ```
41
53
 
42
- To review, run `pnpm install` and `pnpm dev`, then open the Card Studio. Under **Card rotation**, choose **Rotate around center** or **Spin around corner**; choose **Fast** to see a full turn in eight seconds. Use **Pause card rotation** and **Flip card** to check both faces, then resume. Try the rotation direction and image-motion controls independently. Set your operating system or browser to reduced motion and confirm the card stays still. The center and corner spins are decorative; use the separate flip control to choose the face.
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.
43
55
 
44
56
  ### Moving artwork
45
57
 
package/dist/element.js CHANGED
@@ -1,16 +1,19 @@
1
1
  const template = document.createElement('template');
2
2
  template.innerHTML = `<style>
3
- :host{display:inline-block;width:300px;aspect-ratio:2.5/3.5;perspective:1000px;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:top left;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{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){:host([card-spin]) .rotation{animation:none}:host .card{transition:none}}.card{height:100%;position:relative;transform-style:preserve-3d;transition:transform .65s;filter:drop-shadow(0 12px 14px #0006)}:host([flipped]) .card{transform:rotateY(180deg)}.face{position:absolute;inset:0;border-radius:15px;backface-visibility:hidden;overflow:hidden}.front{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);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}: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></div></div>`;
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
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
6
  export class FudaCard extends HTMLElement {
7
- static observedAttributes = ['title', 'category', 'subtitle', 'description', 'number', 'rarity', 'motion', 'playing'];
7
+ static observedAttributes = ['title', 'category', 'subtitle', 'description', 'number', 'rarity', 'motion', 'playing', 'thickness'];
8
8
  constructor() { super(); const root = this.attachShadow({ mode: 'open' }); root.append(template.content.cloneNode(true)); root.querySelector('button')?.addEventListener('click', () => this.toggleAttribute('playing')); }
9
9
  connectedCallback() { this.render(); }
10
10
  attributeChangedCallback(name) { if (name === 'motion' && this.getAttribute('motion') !== 'pan' && this.hasAttribute('playing'))
11
11
  this.removeAttribute('playing'); if (this.shadowRoot)
12
12
  this.render(); }
13
- render() { const button = this.shadowRoot?.querySelector('.motion-button'); if (button) {
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) {
14
17
  button.hidden = this.getAttribute('motion') !== 'pan';
15
18
  const active = this.hasAttribute('playing');
16
19
  button.textContent = active ? '■ Stop' : '▶ Animate';
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export interface CardOptions {
10
10
  rarity?: string;
11
11
  variant?: CardVariant;
12
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;
13
15
  flipped?: boolean;
14
16
  motion?: 'still' | 'pan';
15
17
  playing?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/fuda-cards",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Fuda Cards: collectible card frames for images and interactive 3D content.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -44,10 +44,12 @@
44
44
  "typecheck": "tsc -p tsconfig.json --noEmit",
45
45
  "test": "pnpm build && node --test test/*.test.mjs",
46
46
  "check": "pnpm typecheck && pnpm build && pnpm test",
47
+ "test:e2e": "pnpm build && node --test test/e2e/*.e2e.mjs",
47
48
  "dev": "pnpm build && node scripts/dev.mjs",
48
49
  "site": "pnpm build && node scripts/site.mjs"
49
50
  },
50
51
  "devDependencies": {
52
+ "@johnmorrisdotca/kazoku-ui": "^0.2.1",
51
53
  "typescript": "5.9.3"
52
54
  },
53
55
  "publishConfig": {