Skip to content

Commit 270fa89

Browse files
feat: Animation & Transition Docs & Examples (#2)
* feat: updated core bindings & implemented shift plugin * added hash routing doc * feat: View Transitions API integration * feat: completed animations with docs & demo * chore: bump to 0.4.0
1 parent 9affd47 commit 270fa89

File tree

21 files changed

+2447
-115
lines changed

21 files changed

+2447
-115
lines changed

ROADMAP.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
| v0.2.0 || [Reactive Attributes & Event Modifiers](#reactive-attributes--event-modifiers) |
1818
| v0.3.0 || [Global State](#global-state) |
1919
| v0.4.0 | | [Animation & Transitions](#animation--transitions) |
20+
| | | [History API Routing Plugin](#history-api-routing-plugin) |
2021
| v0.5.0 | | [Persistence & Offline](#persistence--offline) |
2122
| | | [Background Requests & Reactive Polling](#background-requests--reactive-polling) |
2223
| v0.6.0 | | [Navigation & History Management](#navigation--history-management) |
@@ -174,6 +175,17 @@ _NOTE_: `data-x-*` is now `data-volt-*`
174175
- `data-volt-url` for declarative history updates
175176
- View Transition API integration for animated route changes
176177

178+
### History API Routing Plugin
179+
180+
**Goal:** Deliver a first-class path-based router that leverages the History API while staying signal-driven.
181+
**Outcome:** Volt apps can opt into clean URLs (no hash) with back/forward support, nested segments, and SSR-friendly hydration.
182+
**Deliverables:**
183+
- `data-volt-url="history:signal"` mode with path + search preservation and optional base path configuration
184+
- Route parsing utilities for dynamic params (e.g. `/blog/:slug`) and programmatic redirects
185+
- Scroll restoration hooks and focus management aligned with `navigation` and `popstate` events
186+
- Integration tests covering pushState navigation, deep links, and server-rendered bootstraps
187+
- Documentation updates in `docs/usage/routing.md` contrasting hash vs. history strategies
188+
177189
### Inspector & Developer Tools
178190

179191
**Goal:** Improve developer experience and runtime introspection.

docs/.vitepress/config.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { defineConfig } from "vitepress";
1+
import { DefaultTheme, defineConfig } from "vitepress";
2+
import pkg from "../package.json" assert { type: "json" };
23
import { u } from "./utils";
34

5+
const repoURL = "https://github.com/stormlightlabs/volt";
6+
47
/**
58
* @see https://vitepress.dev/reference/site-config
69
*/
@@ -10,11 +13,27 @@ export default defineConfig({
1013
base: "/volt/",
1114
appearance: "dark",
1215
themeConfig: {
13-
nav: [{ text: "Home", link: "/" }, { text: "Overview", link: "/overview" }, { text: "CSS", link: "/css/volt-css" }],
16+
search: { provider: "local" },
17+
nav: [
18+
{ text: "Home", link: "/" },
19+
{ text: "Overview", link: "/overview" },
20+
{ text: "CSS", link: "/css/volt-css" },
21+
{
22+
text: "Version",
23+
items: [{ text: pkg.version, link: `${repoURL}/releases/tag/v${pkg.version}` }, {
24+
text: "Contributing",
25+
link: `${repoURL}/blob/main/CONTRIBUTING.md`,
26+
}, { text: "Changelog", link: "${repoURL}/blob/main/README.md" }],
27+
},
28+
],
1429
sidebar: [
1530
{
1631
text: "Getting Started",
17-
items: [{ text: "Overview", link: "/overview" }, { text: "Installation", link: "/installation" }],
32+
items:
33+
([{ text: "Overview", link: "/overview" }, {
34+
text: "Installation",
35+
link: "/installation",
36+
}] as DefaultTheme.SidebarItem[]).concat(...u.scanDir("usage", "/usage")),
1837
},
1938
{
2039
text: "Core Concepts",
@@ -26,11 +45,12 @@ export default defineConfig({
2645
{ text: "Animations & Transitions", link: "/animations" },
2746
],
2847
},
29-
{ text: "Tutorials", items: [{ text: "Counter", link: "/usage/counter" }] },
48+
{ text: "Tutorials", collapsed: false, items: u.scanDir("usage", "/usage") },
3049
{
3150
text: "CSS",
3251
collapsed: false,
3352
items: [{ text: "Volt CSS", link: "/css/volt-css" }, { text: "Reference", link: "/css/semantics" }],
53+
docFooterText: "Auto-generated CSS Docs",
3454
},
3555
{ text: "Specs", collapsed: true, items: u.scanDir("spec", "/spec") },
3656
{
@@ -39,13 +59,11 @@ export default defineConfig({
3959
items: u.scanDir("api", "/api"),
4060
docFooterText: "Auto-generated API Docs",
4161
},
42-
{
43-
text: "Internals",
44-
collapsed: false,
45-
items: u.scanDir("internals", "/internals"),
46-
docFooterText: "Auto-generated CSS Docs",
47-
},
62+
{ text: "Internals", collapsed: false, items: u.scanDir("internals", "/internals") },
4863
],
49-
socialLinks: [{ icon: "github", link: "https://github.com/stormlightlabs/volt" }],
64+
socialLinks: [{ icon: "github", link: repoURL }, {
65+
icon: "bluesky",
66+
link: "https://bsky.app/profile/stormlightlabs.org",
67+
}],
5068
},
5169
});

docs/animations.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,166 @@
11
# Animations & Transitions
2+
3+
VoltX provides a powerful, declarative animation system through two complementary plugins:
4+
5+
1. **surge** for enter/leave transitions and
6+
2. **shift** for CSS keyframe animations.
7+
8+
Both integrate with the reactivity system and respect user accessibility preferences.
9+
10+
## Quick Start
11+
12+
Add transitions to any element with `data-volt-if` or `data-volt-show` by adding `data-volt-surge` with a preset name:
13+
14+
```html
15+
<div data-volt-if="isVisible" data-volt-surge="fade">
16+
Content fades in and out smoothly
17+
</div>
18+
```
19+
20+
That's it! The surge plugin automatically hooks into the element's lifecycle, applying transitions when it appears or disappears.
21+
22+
## Built-in Presets
23+
24+
VoltX includes ready-to-use transition presets:
25+
26+
| Preset | Description |
27+
| --------------- | --------------------------------- |
28+
| **fade** | Simple opacity transition |
29+
| **slide-up** | Sliding motion with opacity |
30+
| **slide-down** | |
31+
| **slide-left** | |
32+
| **slide-right** | |
33+
| **scale** | Subtle scale effect with opacity |
34+
| **blur** | Blur effect combined with opacity |
35+
36+
All presets are designed with smooth, professional timing curves and 300ms duration by default.
37+
38+
## Surge Plugin: Enter/Leave Transitions
39+
40+
The surge plugin provides two modes of operation: automatic (with if/show bindings) and explicit (signal-based).
41+
42+
### Automatic Mode
43+
44+
When used with `data-volt-if` or `data-volt-show`, surge automatically manages the element's visibility transitions. The element smoothly animates in when the condition becomes true and animates out before removal.
45+
46+
### Explicit Mode
47+
48+
Watch any signal by providing a signal path. The element will transition in/out based on the signal's truthiness:
49+
50+
```html
51+
<div data-volt-surge="showPanel:slide-down">
52+
Panel slides down when showPanel is true
53+
</div>
54+
```
55+
56+
### Duration and Delay Modifiers
57+
58+
Override preset timing using dot notation:
59+
60+
```html
61+
<!-- 500ms duration -->
62+
<div data-volt-surge="fade.500">...</div>
63+
64+
<!-- 600ms duration, 100ms delay -->
65+
<div data-volt-surge="slide-down.600.100">...</div>
66+
```
67+
68+
### Granular Control
69+
70+
Specify different transitions for enter and leave phases:
71+
72+
```html
73+
<div
74+
data-volt-if="show"
75+
data-volt-surge:enter="slide-down.400"
76+
data-volt-surge:leave="fade.200">
77+
Slides in, fades out
78+
</div>
79+
```
80+
81+
## Shift Plugin: Keyframe Animations
82+
83+
The shift plugin applies CSS keyframe animations, perfect for attention-grabbing effects and continuous animations.
84+
85+
### Built-in Animations
86+
87+
| Animation | Description |
88+
| ---------- | --------------------------------- |
89+
| **bounce** | Quick bounce effect |
90+
| **shake** | Horizontal shake motion |
91+
| **pulse** | Subtle pulsing scale (continuous) |
92+
| **spin** | Full rotation (continuous) |
93+
| **flash** | Opacity flash effect |
94+
95+
### One-Time Animations
96+
97+
Apply animation when element mounts:
98+
99+
```html
100+
<button data-volt-shift="bounce">Bounces on mount</button>
101+
```
102+
103+
### Signal-Triggered Animations
104+
105+
Trigger animations based on signal changes:
106+
107+
```html
108+
<div data-volt-shift="error:shake.600.2">
109+
Shakes twice when error becomes truthy
110+
</div>
111+
```
112+
113+
The syntax supports duration and iteration overrides: `animationName.duration.iterations`
114+
115+
## View Transitions API
116+
117+
VoltX automatically uses the View Transitions API when available, providing native browser-level transitions for ultra-smooth visual updates.
118+
The system gracefully falls back to CSS transitions on unsupported browsers.
119+
120+
For advanced use cases, manually trigger view transitions using `startViewTransition` or `namedViewTransition` from the programmatic API.
121+
122+
## Custom Presets (Programmatic Mode)
123+
124+
Register custom transitions for reuse across your application:
125+
126+
```javascript
127+
import { registerTransition } from "voltx.js";
128+
129+
registerTransition("custom-slide", {
130+
enter: {
131+
from: { opacity: 0, transform: "translateX(-100px)" },
132+
to: { opacity: 1, transform: "translateX(0)" },
133+
duration: 400,
134+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
135+
},
136+
leave: {
137+
from: { opacity: 1, transform: "translateX(0)" },
138+
to: { opacity: 0, transform: "translateX(100px)" },
139+
duration: 300,
140+
easing: "ease-out",
141+
},
142+
});
143+
```
144+
145+
Similarly, register custom shift animations with `registerAnimation`.
146+
147+
## Easing Functions
148+
149+
Surge supports standard CSS easing values plus extended named easings:
150+
151+
- Standard: `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`
152+
- Extended: `ease-in-sine`, `ease-out-quad`, `ease-in-out-cubic`, `ease-in-back`
153+
154+
Custom cubic-bezier values are also supported.
155+
156+
## Integration with Bindings
157+
158+
- With `data-volt-if`, surge defers element insertion/removal until transitions complete, preventing visual glitches.
159+
- With `data-volt-show`, surge manages display property changes around the transition lifecycle.
160+
- Simply add `data-volt-surge` to elements already using these bindings.
161+
162+
## Accessibility
163+
164+
The animation system automatically respects the `prefers-reduced-motion` media query. When enabled, animations are skipped or significantly reduced, instantly applying final states instead.
165+
166+
Both surge and shift plugins honor this setting by default, ensuring your application remains accessible without additional configuration.

docs/overview.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
outline: deep
33
---
44

5-
# Framework Overview
5+
# Overview
66

77
VoltX is a lightweight, hypermedia based reactive framework for building declarative UIs.
88

@@ -43,10 +43,8 @@ It combines HTML-driven behavior via `data-volt-*` attributes with signal-based
4343

4444
## Browser Support
4545

46-
Modern browsers with support for:
46+
Modern browsers (Chrome 90+, Firefox 88+, Safari 14+) with support for:
4747

4848
- ES modules
4949
- Proxy objects
5050
- CSS custom properties
51-
52-
Chrome 90+, Firefox 88+, Safari 14+

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@voltx/docs",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"private": true,
55
"type": "module",
66
"scripts": { "dev": "vitepress dev", "build": "vitepress build", "preview": "vitepress preview" },

0 commit comments

Comments
 (0)