folioscope 0.0.2 → 0.0.3

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
@@ -1,8 +1,9 @@
1
1
  # folioscope
2
2
 
3
3
  **Flip through your prototypes.** `<folioscope-player>` plays the interactive prototype of a
4
- `.fig` file in the browser, with no account and no design tool: screens, clicks and timed links,
5
- transitions. `.sketch`, `.xd` and `.penpot` files follow.
4
+ `.fig`, `.sketch` or `.penpot` file in the browser, with no account and no design tool: screens,
5
+ clicks, hovers, overlays, scrolling, transitions. `.xd` files follow. Not a viewer for the design file: a player
6
+ for its clickable prototype.
6
7
 
7
8
  > Early development: see the [roadmap](https://github.com/baxyz/folioscope/blob/main/PROJECT.md#8-roadmap).
8
9
 
@@ -12,7 +13,7 @@ transitions. `.sketch`, `.xd` and `.penpot` files follow.
12
13
  // vite.config.ts
13
14
  import { folioscope } from "folioscope/vite";
14
15
 
15
- export default { plugins: [folioscope({ include: "designs/*.fig" })] };
16
+ export default { plugins: [folioscope({ include: "designs/*.{fig,sketch}", fonts: "fonts" })] };
16
17
  ```
17
18
 
18
19
  `designs/app.fig` is served as `/folio/app.folio/`: layered images (lossless WebP, or AVIF for
package/dist/index.d.mts CHANGED
@@ -41,6 +41,33 @@ interface FolioFrame {
41
41
  content: Rect;
42
42
  fixed?: string[];
43
43
  };
44
+ /** Interactive component instances, whose variants change in place. */
45
+ components?: FolioComponent[];
46
+ /** For smart animate: the background (named `""`), then each direct child, by name. */
47
+ parts?: {
48
+ name: string;
49
+ layer: Layer;
50
+ }[];
51
+ }
52
+ /** An instance switching between variants ("change to"), each a state with its own layer. */
53
+ interface FolioComponent {
54
+ /** Ids of the instances from the frame down to this one, joined by `;`. */
55
+ id: string;
56
+ name: string;
57
+ /** In the frame's coordinates. */
58
+ bounds: Rect;
59
+ /** The variant shown first. */
60
+ initial: string;
61
+ fixed?: boolean;
62
+ states: {
63
+ variant: string;
64
+ name: string;
65
+ /** From the component's top-left corner. */
66
+ bounds: Rect;
67
+ /** In the state's coordinates. */
68
+ hotspots: Hotspot[];
69
+ layer: Layer;
70
+ }[];
44
71
  }
45
72
  interface OverlaySettings {
46
73
  position: "center" | "topLeft" | "topCenter" | "topRight" | "bottomLeft" | "bottomCenter" | "bottomRight" | "manual";
@@ -88,6 +115,12 @@ type Action = {
88
115
  type: "navigate";
89
116
  to: string;
90
117
  transition: Transition;
118
+ } |
119
+ /** Switches the hotspot's interactive component to another of its variants. */
120
+ {
121
+ type: "changeTo";
122
+ to: string;
123
+ transition: Transition;
91
124
  } | {
92
125
  type: "scrollTo";
93
126
  to: string;
@@ -132,6 +165,13 @@ interface Transition {
132
165
  } | {
133
166
  type: "cubicBezier";
134
167
  points: [number, number, number, number];
168
+ } |
169
+ /** Lasts as long as the spring takes to settle, whatever `durationMs` says. */
170
+ {
171
+ type: "spring";
172
+ mass: number;
173
+ stiffness: number;
174
+ damping: number;
135
175
  } | {
136
176
  type: "other";
137
177
  name: string;
@@ -158,6 +198,8 @@ export declare class FolioscopePlayer extends BaseElement {
158
198
  private base;
159
199
  private density;
160
200
  private shown?;
201
+ /** The frame `shown` draws, for smart animate. */
202
+ private shownFrame?;
161
203
  private timers;
162
204
  private loading;
163
205
  private preloadedPage?;
@@ -290,4 +332,4 @@ declare global {
290
332
  }
291
333
  }
292
334
  //#endregion
293
- export type { Action, Flow, FolioFrame, FolioIndex, FolioPage, Hotspot, Interaction, Layer, OverlaySettings, Point, Rect, SUPPORTED_FOLIO, SUPPORTED_IR, Side, Step, Transition, Trigger };
335
+ export type { Action, Flow, FolioComponent, FolioFrame, FolioIndex, FolioPage, Hotspot, Interaction, Layer, OverlaySettings, Point, Rect, SUPPORTED_FOLIO, SUPPORTED_IR, Side, Step, Transition, Trigger };