Skip to the content

Fuda Cards札

Collectible card frames for images and live 3D: a true thickness, an edge, foil, stacks, wear and a binder, as two web components.

Fuda is the Japanese word 札 for a card or a tag. About the name

Contents

How-to

The card element

Every attribute, property and CSS variable of the fuda-card element, with the default of each and how to size and style a card.

<fuda-card> is a frame for a picture, or for anything else you slot into it. It registers itself when you import @johnmorrisdotca/fuda-cards/element, and that import is the only thing it needs. The main entry (@johnmorrisdotca/fuda-cards) exports the same options as TypeScript types and tables without touching the DOM, so it is safe to import on a server.

The frame

AttributeValuesWhat it does
titletextThe card's name at the top.
categorytextA word in the corner, such as ROCKET.
subtitletextA line under the picture.
descriptiontextThe text block under the subtitle.
numbertextThe card number at the foot.
raritytextThe rarity mark at the foot.
variantclassic, sport, cosmicThe frame's look: gold, silver or violet.
finishfoil, matteWhether the frame shines.
flippedbooleanShows the back, the navy Fuda face.

The default slot holds the art: an <img>, or any HTML, including an existing interactive viewer. The card has no drag handler, so that viewer owns its own pointer.

import { cardFinishes, cardVariants, type CardOptions } from '@johnmorrisdotca/fuda-cards';

const options: CardOptions = { title: 'Explorer One', variant: cardVariants[2], finish: cardFinishes[0], thickness: 0.325 };
console.log(options.variant, options.finish);
// cosmic foil
cosmic foil

Size

The element is 300 px wide by default, aspect-ratio: 2.5 / 3.5, and every measurement inside it is in container units, so one CSS rule sizes the whole card:

<script type="module">import '@johnmorrisdotca/fuda-cards/element';</script>
<style>fuda-card.small { width: 180px; }</style>
<fuda-card class="small" title="Small"></fuda-card>

The perspective for 3D turns is --fuda-perspective (default 1000px). The edge colour is --fuda-edge, any CSS background; the default is gold for the classic frame and card-stock cream for the others. The drop shadow is on the element itself, so do not put a filter on anything between the card and its faces.

Properties and methods

MemberWhat it gives
card.wearThe wear preset, as the attribute. Setting an empty string removes it.
card.cardThicknessMmThe thickness in use: thickness, else the material's, else 0.325.
card.stackCountHow many cards the stack holds, 1 to 1000.
card.stackHeightThe stack's height in millimetres.
card.heldCountHow many cards are still in the stack, after any taken off.
card.fanOpenTrue while the stack is fanned open.
card.isMovingTrue while the art pans.
card.takeOff(count?), card.putBack(count?)Move cards to the pile at the side and back.
card.pileBoundsHow far an open fan or a side pile reaches beyond the card, in card widths.
card.setFocused(on)Put this card in or out of focus for autoplay="focus".

The fuda-pile event is sent when pileBounds changes. The pile, wear and motion code are separate modules; see Architecture.

Thickness and stacks: Materials and stacks. Used cards: Wear. Turning and panning: Motion and rotation. Fanning and taking off: Binders and piles.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/fuda-cards 0.11.0.