pele-animate 0.13.0 → 0.15.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
@@ -1,134 +1,114 @@
1
1
  # pele-animate
2
2
 
3
- Animated, illustrated SVG scenes from plain Mermaid code. A small post-processor for
4
- [Pele](https://github.com/obsidianmd/pele) (MIT), which renders the Mermaid; this adds the motion and the pictures.
5
- Unofficial add-on; not affiliated with or endorsed by the Pele or Obsidian teams.
6
- The source stays valid Mermaid, so GitHub or Obsidian still show a normal diagram.
7
-
8
- - Nodes appear in order (BFS from the sources, or pinned with a `%% pa:` comment), edges draw in, labels fade in.
9
- - Hover or focus: tokens travel the edges in sequence. The intro plays once on scroll-in. Click (or Enter) enters step mode: previous / play-pause / next buttons, with Space (play/pause), ←/→ (step) and Esc (leave).
10
- - `@{ icon: "name" }` nodes become illustrations from a glyph pack. Unknown names get a neutral rounded-square glyph.
11
- - Sequence diagrams: participant boxes in a row get the tallest height (Pele sizes each to its own text). Group and box titles are bold.
12
- - Idle state is the finished picture; `prefers-reduced-motion` turns the motion off. Light and dark themes.
13
-
14
- ## Compare
15
-
16
- The same Mermaid source, three renderers. The pele-animate images loop: the intro draws in, then tokens travel the edges (as on hover).
17
- Regenerate with `examples/capture.sh`.
3
+ [![npm](https://img.shields.io/npm/v/pele-animate)](https://www.npmjs.com/package/pele-animate)
4
+ [![CI](https://github.com/dkdev24/pele-animate/actions/workflows/ci.yml/badge.svg)](https://github.com/dkdev24/pele-animate/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/pele-animate)](LICENSE)
18
6
 
19
- ```mermaid
20
- flowchart LR
21
- A[Player] -->|auth token| B[OTT service]
22
- A -->|license request| C[DRM server]
23
- C -->|license| A
24
- ```
25
-
26
- | Renderer | Result |
27
- |---|---|
28
- | Mermaid | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/m1.png" width="560" alt="Flowchart rendered by Mermaid"> |
29
- | Pele | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/p1.png" width="560" alt="Flowchart rendered by Pele"> |
30
- | pele-animate | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a1.gif" width="560" alt="Animated flowchart: nodes appear, edges draw in, tokens travel"> |
31
-
32
- ```mermaid
33
- sequenceDiagram
34
- Player->>OTT: sign in
35
- OTT-->>Player: token
36
- Player->>DRM: token
37
- DRM-->>Player: license
38
- ```
7
+ Mermaid diagrams that explain themselves one step at a time, with icons. You choose the order things appear in, readers
8
+ step through it, and nodes can carry icons. A small post-processor for [Pele](https://github.com/obsidianmd/pele) (MIT),
9
+ which renders the Mermaid; this adds the step order, the playback and the icons. It is not a theme package.
10
+ Unofficial add-on; not affiliated with or endorsed by the Pele or Obsidian teams.
39
11
 
40
- | Renderer | Result |
41
- |---|---|
42
- | Mermaid | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/m2.png" width="560" alt="Sequence diagram rendered by Mermaid"> |
43
- | Pele | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/p2.png" width="560" alt="Sequence diagram rendered by Pele"> |
44
- | pele-animate | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a2.gif" width="560" alt="Animated sequence diagram: messages appear in order, tokens travel"> |
12
+ **[Website](https://pele-animate.pages.dev/) · [Docs](docs/getting-started.md) · [npm](https://www.npmjs.com/package/pele-animate) · [Changelog](CHANGELOG.md)**
45
13
 
46
- With glyphs (`@{ icon }` nodes, `%% pa: 1=P 2=O 3=D` pins the order):
14
+ <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a3.gif" width="560" alt="Animated scene with Tabler icons: a request, a load balancer and a cloud service">
47
15
 
48
- <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a3.gif" width="560" alt="Animated scene with illustrated Player, OTT service and DRM server">
16
+ - **You set the order.** Nodes appear in the order of a `%% pa:` comment, or by default along the edges; edges draw in and labels fade in.
17
+ - **Readers step through it.** Click (or Enter) starts step mode: previous / play-pause / next buttons, Space, ←/→ and Esc. Hover or focus sends tokens along the edges.
18
+ - **Icons.** `@{ icon: "name" }` nodes use any of 4,368 [Tabler](https://github.com/tabler/tabler-icons) icons (loaded per category) or your own. Unknown names get a neutral rounded square.
19
+ - Flowcharts and sequence diagrams. The finished picture is the resting state; `prefers-reduced-motion` turns the motion off. Light and dark themes.
20
+ - The source stays valid Mermaid. One catch: GitHub's own Mermaid renderer does not know the icon names and draws "?" boxes, so the icon examples in this repository are shown as source text.
49
21
 
50
22
  ## Install
51
23
 
52
24
  ```sh
53
25
  npm i pele-animate pele
26
+ # or
27
+ pnpm add pele-animate pele
28
+ yarn add pele-animate pele
29
+ bun add pele-animate pele
54
30
  ```
55
31
 
32
+ `pele` is a peer dependency (`^1.7.0`): install it alongside. Both packages run in the browser and need the DOM, so mount them on the client (see [recipes](docs/recipes.md)). ESM only.
33
+
56
34
  ## Use
57
35
 
58
36
  ```js
59
37
  import { mount } from 'pele';
60
- import { watch } from 'pele-animate';
38
+ import { watch, prepare } from 'pele-animate';
61
39
  import { icons } from 'pele-animate/glyphs';
62
- import 'pele-animate/preset-doverunner'; // the illustrated `doverunner-*` glyphs; skip it to use only Tabler packs
40
+ import 'pele-animate/tabler/computers'; // one Tabler icon category; import as many as you need
63
41
  import 'pele-animate/style.css';
64
42
 
65
43
  for (const el of document.querySelectorAll('pre.mermaid')) {
66
44
  const src = el.textContent;
67
- mount(el, src, { icons });
45
+ mount(el, prepare(src), { icons });
68
46
  watch(el, src); // re-applies after Pele re-lays-out on resize
69
47
  }
70
48
  ```
71
49
 
72
50
  Mermaid source:
73
51
 
74
- ```mermaid
52
+ ```mermaid-icons
75
53
  flowchart LR
76
- %% pa: 1=P 2=O 3=D
77
- P@{ icon: "doverunner-player", form: "square", h: 88, label: "Player" }
78
- O@{ icon: "doverunner-server", form: "square", h: 88, label: "OTT service" }
79
- D@{ icon: "doverunner-key", form: "square", h: 88, label: "DRM server" }
80
- P <-->|auth token| O
81
- P <-->|token / license| D
54
+ %% pa: 1=C 2=L 3=S
55
+ C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
56
+ L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
57
+ S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
58
+ C <-->|route| L
59
+ L <-->|forward| S
82
60
  ```
83
61
 
84
- `form: "square", h: 88` makes a large frameless glyph; leave both out for a small icon in a frame.
85
- `%% pa: 1=P 2=O 3=D` pins nodes to steps (optional). `X>Y` pins the edge from X to Y, so an edge between nodes that are
86
- already visible can have its own step: `%% pa: 1=A,B 2=C,B>C 3=C>B`. Pin the nodes first; an edge pinned before its target appears lands early.
87
- Sequence diagrams animate actors, then messages in order.
62
+ `%% pa: 1=C 2=L 3=S` pins the order (optional). `form: "square", h: 88` makes a large frameless icon.
63
+
64
+ ## Documentation
88
65
 
89
- ## API
66
+ Everything is in [`docs/`](docs/getting-started.md), and ships inside the npm package:
90
67
 
91
- | Export | |
68
+ | | |
92
69
  |---|---|
93
- | `watch(container, source?)` | Animate the SVG inside `container` (and every re-render of it); adds the scene panel and step mode (click / Enter); pass `{ controls: false }` as a third argument for click-to-replay instead |
94
- | `animate(svg, { hover, source })` | Animate one SVG; you handle re-renders |
95
- | `replay(svg)` | Play the intro again |
96
- | `parseOrder(source)` | Read the `%% pa:` pins: `Map(nodeId or 'X>Y' -> level)` |
97
- | `svg.paSteps` | Set by `animate()`: one array per step, each item `[element, parts that animate in]`. Step mode uses it; read it to check the order |
98
- | `registerGlyphs(pack, strokeWidth = 1.1)` (`/glyphs`) | Add glyphs: `{ name: '<inner markup of a 24x24 svg>' }`; colors via `--pa-solid` / `--pa-light` |
99
- | `icons` (`/glyphs`) | Pele `icons` resolver; unknown names get a neutral rounded square, since Pele ships no icons of its own |
70
+ | [Getting started](docs/getting-started.md) · [How it works](docs/how-it-works.md) · [Diagram types](docs/diagram-types.md) | The basics |
71
+ | [Icons](docs/icons.md) · [Custom icons](docs/custom-icons.md) · [Step order](docs/step-order.md) · [Theming](docs/theming.md) · [Recipes](docs/recipes.md) | Guides (Vite, Astro, SvelteKit, Nuxt, React) |
72
+ | [API](docs/api.md) · [Compatibility](docs/compatibility.md) · [Accessibility](docs/accessibility.md) · [Security](docs/security.md) | Reference |
73
+ | [Migrating](docs/migrating.md) · [For coding agents](docs/agents.md) · [FAQ](docs/faq.md) · [Contributing](docs/contributing.md) | Everything else |
100
74
 
101
- Illustrated glyphs (filled, two-tone, DoveRunner style) come from `pele-animate/preset-doverunner` and are all named `doverunner-<name>`: `player`, `server`, `key`, `document`, `shield`, `phone`, `cloud`, `package`, `token`, `lock`, `database`, `video`, `media`, `encoder`, `storage`, `plugin`, `variants`, `watermark`,
102
- `bits-a`, `bits-b`. Plain names (`server`, `lock`, ...) are Tabler's.
75
+ **Coding agents:** the package includes a skill, `skills/pele-animate/`, that wires the library into a project and checks the
76
+ result in a browser. See [For coding agents](docs/agents.md).
103
77
 
104
- ### Tabler icon packs
78
+ ## Compare
105
79
 
106
- About 4,300 line icons from [Tabler Icons](https://github.com/tabler/tabler-icons) (MIT), split by Tabler's own categories. Import only what you need:
80
+ The same Mermaid source, three renderers. The pele-animate images loop: the intro draws in, then tokens travel the edges (as on hover).
81
+ Regenerate with `examples/capture.sh`.
107
82
 
108
- ```js
109
- import 'pele-animate/tabler/devices'; // also: system, database, development, communication, charts, ...
83
+ ```mermaid
84
+ flowchart LR
85
+ A[Client] -->|request| B[API]
86
+ A -->|sign in| C[Auth server]
87
+ C -->|token| A
110
88
  ```
111
89
 
112
- Then use any name from that category: `A@{ icon: "device-tv", form: "square", h: 88 }`. The illustrated glyphs are prefixed `doverunner-`, so no Tabler name is shadowed.
113
- Tabler icons are stroke-only, so the stroke width is adjustable: set `--pa-stroke` on the container (default `1.5`; Tabler draws at 2 and
114
- designs every icon to work at other widths). Categories: see `tabler/` (Brand, Letters, Numbers, Zodiac and Gender are left out).
115
- Regenerate with `node scripts/build-tabler.mjs <tabler-icons checkout>`. License notice: `THIRD-PARTY-NOTICES.md`.
90
+ | Renderer | Result |
91
+ |---|---|
92
+ | Mermaid | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/m1.png" width="560" alt="Flowchart rendered by Mermaid"> |
93
+ | Pele | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/p1.png" width="560" alt="Flowchart rendered by Pele"> |
94
+ | pele-animate | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a1.gif" width="560" alt="Animated flowchart: nodes appear, edges draw in, tokens travel"> |
116
95
 
117
- ```css
118
- .pa-scene { --pa-stroke: 1; }
96
+ ```mermaid
97
+ sequenceDiagram
98
+ Client->>API: sign in
99
+ API-->>Client: token
100
+ Client->>Data: query with token
101
+ Data-->>Client: result
119
102
  ```
120
103
 
121
- ## Theme
122
-
123
- `watch()` adds class `pa-scene` to the container. Override `--pa-bg`, `--pa-solid`, `--pa-light` or any `--pele-*`
124
- variable on it; defaults are `:where()` rules, so your stylesheet wins.
125
-
126
- ## Limits
127
-
128
- - Relies on Pele's SVG structure (`.pele-node`, `.pele-edge`, `data-id`); `pele` is a peer dependency pinned to `^1.7.0`.
129
- - Flowcharts and sequence diagrams only. No types yet.
130
- - Glyph art is square-boxed; wide art is drawn as a wide glyph inside the square.
104
+ | Renderer | Result |
105
+ |---|---|
106
+ | Mermaid | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/m2.png" width="560" alt="Sequence diagram rendered by Mermaid"> |
107
+ | Pele | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/p2.png" width="560" alt="Sequence diagram rendered by Pele"> |
108
+ | pele-animate | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a2.gif" width="560" alt="Animated sequence diagram: messages appear in order, tokens travel"> |
131
109
 
132
- ## Changelog
110
+ ## Credits and license
133
111
 
134
- See [CHANGELOG.md](CHANGELOG.md).
112
+ MIT. Built on [Pele](https://github.com/obsidianmd/pele) by kepano (MIT); this is an unofficial add-on, not affiliated with or
113
+ endorsed by the Pele or Obsidian teams. The Tabler icon packs come from [Tabler Icons](https://github.com/tabler/tabler-icons)
114
+ (MIT, Paweł Kuna); see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). See also [CHANGELOG.md](CHANGELOG.md).
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: Accessibility
3
+ description: What pele-animate does for keyboard users and reduced motion, and what has not been audited.
4
+ order: 11
5
+ section: Reference
6
+ ---
7
+
8
+ # Accessibility
9
+
10
+ What is in place:
11
+
12
+ - **Reduced motion.** `prefers-reduced-motion: reduce` turns off the intro and the tokens. The finished diagram shows.
13
+ - **Keyboard.** The diagram container is focusable (`tabindex="0"`). Enter or Space starts step mode; then Space plays or pauses, ← and → step, and Esc leaves.
14
+ - **Step controls.** The bar has `role="toolbar"` with an accessible name, and its buttons have labels. Previous and next use
15
+ `aria-disabled` at the ends.
16
+ - **Focus outline.** A visible focus ring uses the `--pa-solid` color.
17
+
18
+ What has **not** been checked: a pass with a screen reader, and contrast ratios of custom palettes. Treat the diagram as an
19
+ illustration and keep the key information in the surrounding text as well, as with any diagram. The text of the Mermaid
20
+ source is not a substitute for a description.
package/docs/agents.md ADDED
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: For coding agents
3
+ description: How a coding agent should use pele-animate in a project, and how to verify the result.
4
+ order: 14
5
+ section: Reference
6
+ ---
7
+
8
+ # For coding agents
9
+
10
+ If you are an AI coding agent adding pele-animate to a project, use the skill that ships with the package. It carries the rules
11
+ below in an order that works.
12
+
13
+ ## Install the skill
14
+
15
+ The skill is in the npm package, so after `npm i pele-animate` it is at `node_modules/pele-animate/skills/pele-animate/SKILL.md`.
16
+ For Claude Code, copy it where skills live:
17
+
18
+ ```sh
19
+ mkdir -p .claude/skills
20
+ cp -r node_modules/pele-animate/skills/pele-animate .claude/skills/
21
+ ```
22
+
23
+ Or clone just the skill folder from [GitHub](https://github.com/dkdev24/pele-animate/tree/main/skills/pele-animate) (it has `SKILL.md`, `verify.js` and `references/`).
24
+
25
+ A second skill, `diagram-step-order`, reviews a page's diagrams so the step order matches the text around them.
26
+
27
+ No skill support? Paste this into your instructions file:
28
+
29
+ ```md
30
+ ## Diagrams (pele-animate)
31
+ - Animated Mermaid diagrams use `pele` + `pele-animate`; mount on the client only (see node_modules/pele-animate/docs or the README).
32
+ - Icon names must exist: read node_modules/pele-animate/tabler/<category>.js. Never invent names. Unknown names render a plain square.
33
+ - Order with `%% pa: 1=A 2=B,C`; check svg.paSteps in a browser.
34
+ - Verify by rendering the page and confirming no unexpected rounded-square icons.
35
+ ```
36
+
37
+ ## Rules
38
+
39
+ 1. **Client only.** Never import `pele` or `pele-animate` in server code. Use the framework's mounted hook ([recipes](./recipes.md)).
40
+ 2. **Never invent icon names.** Look them up in `node_modules/pele-animate/tabler/<category>.js` (object keys) and import that category.
41
+ An unknown name does not fail; it renders a rounded square, so a made-up name is a silent bug.
42
+ 3. **Import three things:** `pele-animate/glyphs` (`icons`), the icon pack modules you use, and `pele-animate/style.css`.
43
+ 4. **Pin the order** with `%% pa:` when the default is wrong ([step order](./step-order.md)). Do not rename node ids after pinning.
44
+ 5. **Verify in a browser**, not by reading the code.
45
+
46
+ ## Verify
47
+
48
+ Render the page in a headless browser (Playwright, or any CLI browser) and run this in the page:
49
+
50
+ ```js
51
+ (() => {
52
+ const svgs = [...document.querySelectorAll('.pa-scene svg.pele')];
53
+ const icons = [...document.querySelectorAll('.pa-scene svg.pele-icon[data-icon]')];
54
+ return {
55
+ diagrams: svgs.length,
56
+ steps: svgs.map((s) => s.paSteps?.length ?? 0),
57
+ emptyIcons: icons.filter((i) => !i.innerHTML.trim()).map((i) => i.dataset.icon),
58
+ };
59
+ })()
60
+ ```
61
+
62
+ Expect `diagrams` equal to the number you added, every `steps` entry above 0, and `emptyIcons` empty. A name that was not registered renders
63
+ a rounded square instead of nothing, so also compare the icon names in your Mermaid with the pack source.
package/docs/api.md ADDED
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: API reference
3
+ description: Every export of pele-animate, with types.
4
+ order: 9
5
+ section: Reference
6
+ ---
7
+
8
+ # API reference
9
+
10
+ TypeScript types ship with the package (`types/`).
11
+
12
+ ## `pele-animate`
13
+
14
+ | Export | Signature | Description |
15
+ |---|---|---|
16
+ | `watch` | `watch(container: HTMLElement, source?: string, options?: { controls?: boolean }): void` | Marks the container as a scene (`pa-scene`), animates each SVG Pele renders into it and re-applies after Pele re-lays-out on resize. `controls: false` keeps click-to-replay instead of step mode. |
17
+ | `prepare` | `prepare(source?: string): string` | Returns the Mermaid source with icon-node labels padded so Pele lays out a box at least as wide as the icon (`h`). Pass its result to `mount()` and the original source to `watch()`. Without it, a label shorter than the icon puts edge ends and arrowheads under the icon. |
18
+ | `animate` | `animate(svg: SVGSVGElement, options?: { hover?: Element; source?: string }): void` | Animates one rendered svg. `source` is read for `%% pa:` pins. Sets `svg.paSteps`. |
19
+ | `replay` | `replay(svg: SVGSVGElement \| null \| undefined): void` | Plays the intro again. |
20
+ | `parseOrder` | `parseOrder(source?: string): Map<string, number>` | Parses the `%% pa:` comment: node id, or `'X>Y'` for an edge, to a 0-based step. |
21
+
22
+ `svg.paSteps` (type `PaStep[]`, where `PaStep = Array<[element: Element, parts: Element[]]>`) is set by `animate()`: one array per
23
+ step.
24
+
25
+ ## `pele-animate/glyphs`
26
+
27
+ | Export | Signature | Description |
28
+ |---|---|---|
29
+ | `icons` | `icons(name: string): string` | Pele's `icons` resolver. Unknown names return a neutral rounded square. |
30
+ | `registerGlyphs` | `registerGlyphs(pack: Record<string, string>, strokeWidth?: number): void` | Adds glyphs: `{ name: '<inner markup of a 24x24 svg>' }`. Default stroke width 1.1. |
31
+ | `registerTabler` | `registerTabler(pack: Record<string, string>, strokeWidth?: number): void` | Adds outline icons whose stroke width follows `--pa-stroke` (fallback `strokeWidth`, default 1.5). |
32
+ | `S`, `L`, `W` | `string` | Theme color expressions for glyph markup: solid, light, white. |
33
+
34
+ ## `pele-animate/tabler/<category>`
35
+
36
+ Importing a module registers that category's icons. It also exports `pack: Record<string, string>` (name to inner markup).
37
+ Categories are listed in [icons](./icons.md).
38
+
39
+ ## `pele-animate/preset-doverunner`
40
+
41
+ Importing it registers the 20 `doverunner-*` glyphs. No exports.
42
+
43
+ ## `pele-animate/style.css`
44
+
45
+ The scene frame, motion and step controls. Import it once.
46
+
47
+ ## Classes you may see
48
+
49
+ `pa-scene` (container), `pa-ready` (an animated svg), `pa-in` and `pa-done` (intro states), `pa-stepping` (step mode), `pa-controls`
50
+ (the button bar). These are internal and may change; prefer the CSS variables in [theming](./theming.md) over targeting them.
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: Compatibility
3
+ description: Versions of Pele, browsers, and the parts of Pele's markup pele-animate depends on.
4
+ order: 10
5
+ section: Reference
6
+ ---
7
+
8
+ # Compatibility
9
+
10
+ | | Supported |
11
+ |---|---|
12
+ | Pele | `^1.7.0` (peer dependency). Tested with 1.7 (the docs site), 1.8 and 1.9. |
13
+ | Diagram types | Flowcharts and sequence diagrams ([diagram types](./diagram-types.md)) |
14
+ | Browsers | Current browsers with the Web Animations API, `IntersectionObserver` and `matchMedia` (Chrome, Edge, Firefox, Safari). Without `IntersectionObserver` the intro plays at once. |
15
+ | Module format | ESM only |
16
+ | Server rendering | Not applicable: mount on the client ([recipes](./recipes.md)) |
17
+
18
+ ## What pele-animate depends on in Pele
19
+
20
+ pele-animate reads the SVG Pele produces. It selects on these class names and attributes:
21
+
22
+ `.pele-node`, `.pele-edge`, `.pele-edge-label`, `.pele-marker`, `.pele-cluster-label`, `.pele-icon`, `.pele-lifeline`,
23
+ `.pele-actor-participant`, and the `data-id` attribute.
24
+
25
+ Pele has not promised these are stable across releases (the question is open upstream). That is why Pele is a peer dependency:
26
+ upgrade it deliberately, and re-check your diagrams afterwards. The repository's tests render every documentation example,
27
+ which catches parse errors but not visual changes.
28
+
29
+ ## Known limits
30
+
31
+ - Sequence-diagram participants ignore `@{ icon }`.
32
+ - Step mode is browser-tested on flowcharts only.
33
+ - Glyph art is square-boxed; wide art is drawn as a wide shape inside the square.
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: Contributing
3
+ description: Set up the repository, run the checks, and regenerate the Tabler packs.
4
+ order: 15
5
+ section: Reference
6
+ ---
7
+
8
+ # Contributing
9
+
10
+ ```sh
11
+ git clone https://github.com/dkdev24/pele-animate
12
+ cd pele-animate
13
+ pnpm install
14
+ pnpm test # renders every Mermaid example in the docs and README with Pele, and checks icon names
15
+ pnpm build # builds the site (a placeholder until the site lands)
16
+ ```
17
+
18
+ - The package is plain ESM at the repository root: no build step. The site lives in `site/`.
19
+ - Docs are the Markdown files in `docs/`. A fenced block marked `mermaid` must render, and every `@{ icon }` name in it must exist.
20
+ - Fence convention: ```` ```mermaid live ```` is a diagram GitHub can also draw; the site animates it. A diagram with `@{ icon }` nodes uses ```` ```mermaid-icons live ````, because GitHub's Mermaid cannot draw icons (it shows "?" boxes), so GitHub shows the source text and the site animates it.
21
+ - Tabler packs are generated: `node scripts/build-tabler.mjs <path to a tabler-icons checkout>` rewrites `tabler/*.js`. Do not edit those
22
+ files by hand. The Tabler version is recorded in each file header and in `THIRD-PARTY-NOTICES.md`.
23
+ - Add an entry to `CHANGELOG.md` for any user-visible change. Breaking changes also get a section in `docs/migrating.md`.
24
+ - Versioning stays on `0.x`.
25
+ - Keep example diagrams generic (clients, APIs, databases).
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Custom icons
3
+ description: Register your own glyphs with registerGlyphs.
4
+ order: 5
5
+ section: Guides
6
+ ---
7
+
8
+ # Custom icons
9
+
10
+ Register your own icons with `registerGlyphs`:
11
+
12
+ ```js
13
+ import { registerGlyphs, S, L } from 'pele-animate/glyphs';
14
+
15
+ registerGlyphs({
16
+ 'my-box': `<rect x="4" y="6" width="16" height="12" rx="2" fill="${L}" stroke="${S}"/>`,
17
+ });
18
+ ```
19
+
20
+ Then use `icon: "my-box"` in your Mermaid.
21
+
22
+ ## The contract
23
+
24
+ - A glyph is the **inner markup** of a 24 by 24 SVG: shapes only, no `<svg>` wrapper. Draw inside the 24 by 24 box.
25
+ - Colors: use `S` (solid) and `L` (light), which are the CSS variables `--pa-solid` and `--pa-light` with fallbacks, plus
26
+ `W` for white. Then the glyph follows light and dark themes (see [theming](./theming.md)).
27
+ - `registerGlyphs(pack, strokeWidth = 1.1)` wraps each glyph in a group with that stroke width. Pele draws icons at stroke
28
+ width 2, which looks heavy on a large icon, so glyphs get a thinner one.
29
+ - Line icons that should respond to `--pa-stroke` (as the Tabler packs do) can use `registerTabler(pack, strokeWidth = 1.5)`
30
+ instead. It sets fill none, round caps and joins, and the stroke color for you.
31
+
32
+ ## Names
33
+
34
+ Registering a name that already exists replaces it. Choose a prefix for your own pack (`acme-box`) so your names never clash
35
+ with Tabler's plain names.
36
+
37
+ ## Safety
38
+
39
+ Glyph markup is inserted into the page as SVG. Only register markup you trust. See [security](./security.md).
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: Diagram types
3
+ description: Which Mermaid diagrams pele-animate animates, and what each one does.
4
+ order: 3
5
+ section: Start
6
+ ---
7
+
8
+ # Diagram types
9
+
10
+ pele-animate supports **flowcharts** and **sequence diagrams**. Pele renders other diagram types too, but they are outside what
11
+ pele-animate is built for.
12
+
13
+ ## Flowcharts
14
+
15
+ Nodes appear in step order, edges draw from their source node, and edge labels fade in. Groups (`subgraph`) and their titles
16
+ are kept. Icon nodes (`@{ icon }`) work here; see [icons](./icons.md).
17
+
18
+ ```mermaid live
19
+ flowchart LR
20
+ A[Client] --> B{Cached?}
21
+ B -->|yes| C[Serve]
22
+ B -->|no| D[Fetch] --> C
23
+ ```
24
+
25
+ ## Sequence diagrams
26
+
27
+ Actors appear first, then the messages in order. Participant boxes in a row get the same height, and group titles are bold.
28
+
29
+ ```mermaid live
30
+ sequenceDiagram
31
+ Client->>API: request
32
+ API->>Database: query
33
+ Database-->>API: rows
34
+ API-->>Client: response
35
+ ```
36
+
37
+ **Limit:** Pele ignores `@{ icon }` on sequence participants (the box shows its id), so icons apply to flowcharts only.
38
+
39
+ ## Everything else
40
+
41
+ Other Mermaid types (class, state, ER, gantt, pie and the rest) render through Pele as usual. pele-animate is not designed for
42
+ them and its behavior on them is untested, so use plain Pele for those. Step mode has been checked in a browser on
43
+ flowcharts only; sequence diagrams have not been checked the same way yet.
package/docs/faq.md ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: FAQ
3
+ description: Common questions about pele-animate, Pele, and licenses.
4
+ order: 16
5
+ section: Reference
6
+ ---
7
+
8
+ # FAQ
9
+
10
+ **Is this part of Pele?** No. It is an unofficial add-on, not affiliated with or endorsed by the Pele or Obsidian teams. Pele does the
11
+ layout and drawing; pele-animate adds step order, step-by-step playback and icons on top.
12
+
13
+ **Why not just use Pele?** Pele alone draws a static diagram. Use it directly if that is enough. pele-animate is for diagrams
14
+ you want to explain in order.
15
+
16
+ **Is it a theme?** No. It does not offer visual styles beyond a simple scene frame and light/dark colors you can override.
17
+
18
+ **Why not Mermaid.js?** Pele is much smaller and renders synchronously. pele-animate is built on Pele, so it follows that choice.
19
+
20
+ **Does it work with server rendering?** Mount it on the client ([recipes](./recipes.md)). Static site generators are fine.
21
+
22
+ **How big is it?** The core (`pele-animate.js` plus CSS) is about 20 KB unminified. Icon packs are separate modules, so you only
23
+ ship the categories you import (the largest, `system`, is about 199 KB unminified).
24
+
25
+ **Which diagrams does it support?** Flowcharts and sequence diagrams ([diagram types](./diagram-types.md)).
26
+
27
+ **Can I use my own icons?** Yes ([custom icons](./custom-icons.md)).
28
+
29
+ **Licenses.** pele-animate is MIT. Pele is MIT. The Tabler icon packs are from Tabler Icons (MIT, Paweł Kuna); see
30
+ `THIRD-PARTY-NOTICES.md`.
@@ -0,0 +1,70 @@
1
+ ---
2
+ title: Getting started
3
+ description: Install pele-animate and render your first step-by-step Mermaid diagram.
4
+ order: 1
5
+ section: Start
6
+ ---
7
+
8
+ # Getting started
9
+
10
+ pele-animate makes a [Pele](https://pele.run) diagram explain itself one step at a time. You choose the order things appear
11
+ in, readers step through it with buttons or the keyboard, and any node can carry an icon from a large set. It is an
12
+ unofficial add-on for Pele and does not change how Pele lays out or draws diagrams.
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm i pele-animate pele
18
+ # or
19
+ pnpm add pele-animate pele
20
+ yarn add pele-animate pele
21
+ bun add pele-animate pele
22
+ ```
23
+
24
+ `pele` is a peer dependency (`^1.7.0`): install it alongside. Both run in the browser and need the DOM, so mount them on the client (see
25
+ [recipes](./recipes.md) for frameworks). The packages are ESM only.
26
+
27
+ ## First diagram
28
+
29
+ Put the Mermaid source in an element, then mount it with Pele and hand it to `watch()`:
30
+
31
+ ```js
32
+ import { mount } from 'pele';
33
+ import { watch, prepare } from 'pele-animate';
34
+ import { icons } from 'pele-animate/glyphs';
35
+ import 'pele-animate/tabler/computers'; // icons: one Tabler category, import as many as you need
36
+ import 'pele-animate/style.css';
37
+
38
+ const el = document.querySelector('pre.mermaid');
39
+ const src = el.textContent;
40
+ mount(el, prepare(src), { icons }); // Pele draws the SVG
41
+ watch(el, src); // pele-animate animates it, and re-applies when Pele re-lays-out on resize
42
+ ```
43
+
44
+ The Mermaid source:
45
+
46
+ ```mermaid-icons live
47
+ flowchart LR
48
+ %% pa: 1=C 2=L 3=S
49
+ C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
50
+ L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
51
+ S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
52
+ C <-->|route| L
53
+ L <-->|forward| S
54
+ ```
55
+
56
+ What you get:
57
+
58
+ - The intro plays once when the diagram scrolls into view: nodes appear in order, edges draw in, labels fade in.
59
+ - Hover or focus: small tokens travel along the edges.
60
+ - Click, or focus and press Enter: **step mode**. Previous, play/pause and next buttons appear, and Space, ←, → and Esc work.
61
+ - With `prefers-reduced-motion`, the motion is off and the finished picture shows.
62
+
63
+ The `%% pa: 1=C 2=L 3=S` comment pins the order. Without it, the order follows the edges. See [step order](./step-order.md).
64
+
65
+ ## Next
66
+
67
+ - Pick icons: [icons](./icons.md).
68
+ - Control the order: [step order](./step-order.md).
69
+ - Match your site's colors: [theming](./theming.md).
70
+ - Upgrading from 0.12: [migrating](./migrating.md).
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: How it works
3
+ description: What Pele does, what pele-animate adds, and the three kinds of motion.
4
+ order: 2
5
+ section: Start
6
+ ---
7
+
8
+ # How it works
9
+
10
+ Two layers, one diagram:
11
+
12
+ 1. **Pele** parses the Mermaid, lays the diagram out and returns an SVG. That is all Pele's job; pele-animate does not
13
+ touch layout, sizing or syntax.
14
+ 2. **pele-animate** reads that SVG after Pele draws it, works out the order things should appear in, and adds the motion,
15
+ the step playback and the icons. The Mermaid source stays valid Mermaid, so GitHub or Obsidian still show a normal diagram.
16
+
17
+ ## The calls
18
+
19
+ - `mount(el, prepare(src), { icons })` is Pele's. The `icons` option is how glyphs get in (see [icons](./icons.md)).
20
+ - `watch(el, src)` is pele-animate's. It marks the container as a scene (class `pa-scene`), animates each SVG Pele renders into
21
+ it, and re-applies after Pele re-draws on resize. The intro is skipped on those re-draws once it has played.
22
+ - `animate(svg, { source })` does one SVG. Use it if you render with Pele yourself and do not want `watch()`.
23
+ - `replay(svg)` plays the intro again.
24
+
25
+ ## The three kinds of motion
26
+
27
+ | Motion | When | Notes |
28
+ |---|---|---|
29
+ | **Intro** | Once, when the diagram is 30% in view | Nodes appear by step, each edge draws from its source, labels fade in. A long diagram squeezes its steps so the intro stays near 3 seconds. |
30
+ | **Tokens** | While hovering or focusing the diagram | Small dots travel along the edges in sequence. |
31
+ | **Step mode** | Click, or Enter | You move through the same steps one at a time. See [step order](./step-order.md). |
32
+
33
+ The resting state is always the finished picture. Everything honors `prefers-reduced-motion`.
34
+
35
+ ## Where the order comes from
36
+
37
+ Order is a list of **steps**. By default, a flowchart's steps are the breadth-first levels from the nodes that nothing points to;
38
+ a sequence diagram's steps are its actors, then its messages in order. A `%% pa:` comment overrides that. After
39
+ `animate()` runs, `svg.paSteps` holds one array per step, which is also what step mode uses.
40
+
41
+ ## What it depends on in Pele
42
+
43
+ pele-animate selects on class names in Pele's SVG (`.pele-node`, `.pele-edge`, and a few others) and on the `data-id` attribute.
44
+ Pele is a peer dependency so you control its version. See [compatibility](./compatibility.md).