@johnmorrisdotca/fuda-cards 0.6.0 → 0.7.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/README.md CHANGED
@@ -62,6 +62,16 @@ The card has thickness, drawn to scale at the 63 mm wide card size: set `thickne
62
62
 
63
63
  The top card is the live card. The block under it is one piece, and with `stack-messiness` above 0 (0 neat to 1 very messy, default 0.3) the `stack-depth` cards under the top one (default 10, at most 52) are drawn as flat stills, nudged and turned from `stack-seed`: the same seed gives the same stack, and a card put on top moves none of those under it. A stack is one 3D scene whatever its count, and it draws nothing while it is at rest: a test checks that a 52-card stack requests no frames at rest. The idea of a pile from neat to messy and its parameters come from [toranpu](https://github.com/johnmorrisdotca/toranpu)'s `<toranpu-pile>`. In script, `card.stackCount` and `card.stackHeight` (mm) are read-only, and the package exports `cardMaterials`, `stackPresets`, `stackHeightMm` and `stackLayout`.
64
64
 
65
+ ### Fan a stack, take a card off it
66
+
67
+ A stack of more than one card is a pile like the collection's deck, with the same fan and the same landing. `fan="open"` spreads up to ten cards in an arc (every card drawn with its face and the picture) and closes back exactly where they began. `taken-off="3"` puts the top three cards on a pile at the stack's side, as thick as the cards in it: `card.takeOff()` flies the top card across and `card.putBack()` brings it back, and `deck-land="face-up"` (the default) or `"face-down"` (turned over sideways, showing the back) says how it lands. `pile-controls` draws three buttons (Fan, Take a card off, Put it back; each at least 48 px) under the card; leave about 70 px of room below it. `animate="off"` and `speed="slow|quick"` are the same as in the collection. The card turns with the pile (the angle, tilt and Auto-turn work as before) and an open fan or a pile at the side is part of what turns: `card.pileBounds` says how far they reach beyond the card, in card widths, and `fuda-pile` is sent when it changes, so a page can fit its view.
68
+
69
+ ```html
70
+ <fuda-card title="Deck" stack="52" pile-controls></fuda-card>
71
+ ```
72
+
73
+ The pile code is a separate module (`dist/pile-card.js`) that `<fuda-card>` loads only when a stack asks for `fan`, `taken-off` or `pile-controls`; a card without them is drawn exactly as before and never requests it.
74
+
65
75
  ### Wear: cards that are not perfect
66
76
 
67
77
  `wear="lightly-played"` draws the card after use: corners that are soft, rounded, chipped or folded (a dog-ear), whitening on the edges, creases, scratches, specks, staining, yellowing and a print that sits off centre. The presets are the plain grading terms: `mint`, `near-mint`, `lightly-played`, `moderately-played`, `heavily-played` and `damaged`; `perfect`, no attribute at all, or an unknown name draws nothing. `wear-seed` fixes where the marks lie, so a card looks the same every time it is drawn. `wear-corners`, `wear-edges`, `wear-surface` and `wear-creases` (0 to 1) change one kind on its own, and `wear="0.5"` sets them all at once.
@@ -116,11 +126,13 @@ Run `pnpm dev` and open `/demo/collections-component.html`. Import `@johnmorrisd
116
126
 
117
127
  **Choosing a display.** The twelve displays are a row of buttons across the top, each with a small picture of its layout and its name, at least 48 px high, one chosen, wrapping on a phone (4 to a row, 6 on a desk). It is a radio group: one tab stop, the arrow keys move the choice. There is no drop-down. The colours follow the reader's light or dark setting; set `theme="light"` or `theme="dark"` to choose for them.
118
128
 
119
- **The deck.** `view="deck"` draws a deck of up to ten cards (with a seeded, slightly messy lie: `deck-messiness` 0 to 1, default 0.3, and `deck-seed`) and, beside it, a pile. **Next** flips the top card off the deck: it lifts, flies across and lands on the pile at the deck's other side; **Previous** brings it back. Where it lands is a choice: `deck-land="face-up"` (still facing up, the default), `upside-down` (it spins half way round in its plane) or `face-down` (it turns over about its vertical axis, so the pile shows the card's `backImage`, or the package's own navy back when it has none). The same card element flies, so a card is never drawn twice; with reduced motion it moves without flying. **Rotate the deck**: the deck's view controls have the angle, tilt and Auto-turn (the other displays are flat), and the whole table, both piles, turns in 3D: seen from behind you see the backs of the deck and the faces of a face-down pile.
129
+ **The deck, and the other piles.** Four displays draw a pile of cards, and each does everything a pile does: it turns in 3D, it fans open and closed, and a card comes off it onto a pile at its side. They are the Overlapping Deck (`view="deck"`), Random Draw, the Jukebox Carousel and the Flip Tower (all three drew a pile of three cards before 0.7.0, so they are now the same pile with their own look); the Fan of Cards is the same pile with only its fan. Rolodex and Spotlight Carousel spread their cards out instead of piling them, so they are carousels and stay as they were. `view="deck"` draws a deck of up to ten cards (with a seeded, slightly messy lie: `deck-messiness` 0 to 1, default 0.3, and `deck-seed`) and, beside it, a pile. **Next** flips the top card off the deck: it lifts, flies across and lands on the pile at the deck's other side; **Previous** brings it back. Where it lands is a choice: `deck-land="face-up"` (still facing up, the default) or `face-down` ("Turned over": it turns over sideways about its vertical axis, like turning a page, so the pile shows the card's `backImage`, or the package's own navy back when it has none). A card never lands with its picture on its head. The 0.6.0 value `upside-down` is still accepted and means `face-down`. The same card element flies, so a card is never drawn twice; with reduced motion it moves without flying. **Rotate a pile**: a pile's view controls have the angle, tilt and Auto-turn (the other displays are flat), and the whole table, both piles, turns in 3D: seen from behind you see the backs of the deck and the faces of a face-down pile.
130
+
131
+ **The fan.** Every pile fans open and closes with the **Fan** buttons right under the view (or `fan="open"`): up to ten cards spread in an arc like a hand of playing cards so that most of each card shows, and closing puts each card back exactly where it started. The pile beside the deck moves out of the way and the view fits the open fan (a phone included). A card can still be taken off an open fan, and off a pile that was fanned and closed. `view="fan"` is the same pile with only its fan: `fan-size` (2 to 10) cards from the current one, Next moves the window on. The fan is in the address (`?fan=open`).
120
132
 
121
- **The fan.** `view="fan"` fans the cards out like a hand of playing cards: `fan="open"` spreads up to ten (`fan-size`, 2 to 20) in an arc so that about half of each card shows, and without it the same cards are squared up into the deck they started as. Opening and closing animate every card in turn (none with reduced motion), and closing puts each card back exactly where it started. The Open fan and Closed deck buttons under the view, or the attribute, do it.
133
+ **Animate.** Opening and closing the fan, taking a card off, moving to the next card (Rolodex, Spotlight, the fan), changing a binder page and switching display all move; the wall, story and atlas pan to the card you move to. `animate="off"` turns all of it off (every move then ends at once, in exactly the same place), and `speed="slow"` or `"quick"` makes every move longer or shorter. `animate` is **on** when the attribute is missing, as the flight of a card taken off already was in 0.6.0; set `animate="off"` for the jump you had before. The reader's reduced-motion setting always wins. Moves are CSS transforms and one-shot animations that end by themselves: nothing runs while the view is idle. The Animate and Speed buttons are under the view and in the address (`?animate=off&speed=quick`).
122
134
 
123
- **Zoom, Fit and move in every view.** Under each view sit the `@johnmorrisdotca/kazoku-ui` view controls: **−**, **2×**, **+** and **Fit**, and, once zoomed in, four arrows to move the view. Ctrl or Command with the wheel (or a trackpad pinch) and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view, even when the drag starts on a card; the keys `+`, `−` and `0` work with the view focused. **Fit** shows every card the view draws (the whole binder or case page, every card of the wall, the story and the atlas). The wall, story and atlas open at half size or larger so a card can be read, and the others open at Fit. A tap or click on a card still opens it, and zooming, moving or paging never resets the other: turning to the next card or page keeps your zoom, and zooming keeps the card or page you are on. The deck is the one view that also turns in 3D (see below); the other eleven use zoom and move only. Nothing animates the zoom, so reduced motion needs no special case. Add the boolean `address` attribute to keep the zoom, the display, the fan and the landing in the page address (`?view=fan&fan=open&land=face-down&zoom=2`); a link to it opens the same view. Set `--fuda-stage-height` on the element to change the height of the view (default: the window height less 440 px, between 300 and 620 px) so the controls stay on screen.
135
+ **Zoom, Fit and move in every view.** Under each view sit the `@johnmorrisdotca/kazoku-ui` view controls: **−**, **2×**, **+** and **Fit**, and, once zoomed in, four arrows to move the view. Ctrl or Command with the wheel (or a trackpad pinch) and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view, even when the drag starts on a card; the keys `+`, `−` and `0` work with the view focused. **Fit** shows every card the view draws (the whole binder or case page, every card of the wall, the story and the atlas). The wall, story and atlas open at half size or larger so a card can be read, and the others open at Fit. A tap or click on a card still opens it, and zooming, moving or paging never resets the other: turning to the next card or page keeps your zoom, and zooming keeps the card or page you are on. The piles (see above) also turn in 3D; the other displays use zoom and move only. Zoom itself is not animated. Add the boolean `address` attribute to keep the zoom, the display, the fan, the landing, Animate and Speed in the page address (`?view=fan&fan=open&land=face-down&zoom=2`); a link to it opens the same view. Set `--fuda-stage-height` on the element to change the height of the view (default: the window height less 440 px, between 300 and 620 px) so the controls stay on screen.
124
136
 
125
137
  `@johnmorrisdotca/kazoku-ui` is a runtime dependency of the package (it was a development dependency until 0.2.0). Choice buttons, the light and dark colours and the address are written in the package, because kazoku-ui has no shared part for them yet. A bundler resolves it. On a plain HTML page without a bundler, add an import map next to the module script, with the package served from `node_modules` or a copy of its `dist`:
126
138
 
@@ -11,8 +11,11 @@ export declare class FudaCollection extends HTMLElement {
11
11
  private tiles?;
12
12
  private landing?;
13
13
  private fanChoice?;
14
+ private animateChoice?;
15
+ private speedChoice?;
14
16
  private flip;
15
17
  private addressTimer;
18
+ private fanPlaces;
16
19
  static get observedAttributes(): string[];
17
20
  set cards(value: CollectionCard[]);
18
21
  get cards(): CollectionCard[];
@@ -22,11 +25,14 @@ export declare class FudaCollection extends HTMLElement {
22
25
  disconnectedCallback(): void;
23
26
  attributeChangedCallback(name: string): void;
24
27
  private get currentView();
28
+ /** How a card taken off lands: still facing up, or turned over sideways. The 0.6.0 value `upside-down` is still accepted and means turned over. */
25
29
  private get land();
26
30
  private get fanOpen();
27
31
  private get stacked();
32
+ private get piled();
33
+ private get turnable();
28
34
  private q;
29
- /** With `address`, the display, the fan and the landing are kept in the page's address (`?view=fan&fan=open&land=face-down`), and a link to it opens the same. */
35
+ /** With `address`, the display, the fan, the landing, the animation and its speed are kept in the page's address (`?view=fan&fan=open&land=face-down&animate=off`), and a link to it opens the same. */
30
36
  private readAddress;
31
37
  private writeAddress;
32
38
  private move;
@@ -34,12 +40,27 @@ export declare class FudaCollection extends HTMLElement {
34
40
  private open;
35
41
  private renderDialog;
36
42
  private canDraw;
43
+ /** The one length every move takes, in a custom property the stylesheet reads: `animate="off"` and reduced motion make it 0, `speed` stretches it. */
44
+ private timeVars;
45
+ private syncChoices;
37
46
  private build;
38
- /** One pile of the deck. `positions` are data indexes from the bottom of the pile to its top; the cards under the top one lie nudged and turned from the seed and the top one lies square. */
47
+ /** One pile of the deck. `positions` are data indexes from the bottom of the pile to its top; the cards under the top one lie nudged and turned from the seed and the top one lies square. A deck's cards also carry where they lie when the fan is open. */
39
48
  private pile;
49
+ /** Where the fan's cards lie for a pile of this many cards. A phone's fan lies closer across and leans on its angle. */
50
+ private fanFor;
51
+ /** Open the fan (or close it) on the pile that is on screen, without drawing it again, so every card glides: the open fan's reach is put in custom properties that move the piles apart and the Fit box. */
52
+ private fanVars;
53
+ /** `fan` changed: when a pile is on screen, move its cards to or from the fan in place (animated) and fit the view to it. Returns false when there is no pile to move. */
54
+ private setFan;
40
55
  private renderDeck;
41
- /** The card that just moved flies between the two piles, turning over on the way if it lands face down (or spinning if it lands upside down). The same element, so the card is never drawn twice. */
56
+ /** The card that just moved flies between the two piles, turning over sideways on the way if it lands face down. The same element, so the card is never drawn twice. An open fan sends the card from where the fan holds it. */
42
57
  private playFlip;
43
58
  private renderFan;
59
+ /** Where every card is on screen now, by data index. */
60
+ private snapshot;
61
+ /** Cards that arrive grow and fade in, a little to the side the reader is heading. Only an opening keyframe: they end on the card's own style. */
62
+ private enter;
63
+ /** After a card or page change or a switch of display: glide what stays, let what goes leave, bring in what comes. Nothing runs afterwards: each is one animation that ends by itself. */
64
+ private play;
44
65
  private render;
45
66
  }