@maxigarcia/theme-transitions 0.2.0 → 0.3.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 +9 -18
- package/dist/circular-reveal/index.js +4 -4
- package/dist/fall/index.css +57 -0
- package/dist/fall/index.d.ts +6 -0
- package/dist/fall/index.d.ts.map +1 -0
- package/dist/fall/index.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @maxigarcia/theme-transitions
|
|
2
2
|
|
|
3
|
-
Lightweight, CSS-first theme transitions for the web. Wrap your theme change in the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) and reveal the new theme with a **circular** or **
|
|
3
|
+
Lightweight, CSS-first theme transitions for the web. Wrap your theme change in the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) and reveal the new theme with a **circular**, **sweep**, or **fall** animation—no animation framework required.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -14,20 +14,22 @@ npm install @maxigarcia/theme-transitions
|
|
|
14
14
|
| --------------- | ---------------------------------------------------------------- |
|
|
15
15
|
| Circular reveal | [src/circular-reveal/README.md](./src/circular-reveal/README.md) |
|
|
16
16
|
| Sweep reveal | [src/sweep-reveal/README.md](./src/sweep-reveal/README.md) |
|
|
17
|
+
| Fall | [src/fall/README.md](./src/fall/README.md) |
|
|
17
18
|
|
|
18
19
|
Each module has its own README with setup, API, and usage examples.
|
|
19
20
|
|
|
20
21
|
## Package exports
|
|
21
22
|
|
|
22
|
-
| Import
|
|
23
|
-
|
|
|
24
|
-
| `@maxigarcia/theme-transitions`
|
|
25
|
-
| `@maxigarcia/theme-transitions/circular-reveal
|
|
26
|
-
| `@maxigarcia/theme-transitions/
|
|
23
|
+
| Import | Purpose |
|
|
24
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------- |
|
|
25
|
+
| `@maxigarcia/theme-transitions` | `onCircularRevealAnimation`, `onSweepRevealAnimation`, `onFallAnimation`, types |
|
|
26
|
+
| `@maxigarcia/theme-transitions/circular-reveal.css` | Styles for circular reveal |
|
|
27
|
+
| `@maxigarcia/theme-transitions/fall.css` | Styles for fall |
|
|
28
|
+
| `@maxigarcia/theme-transitions/sweep-reveal.css` | Styles for sweep reveal |
|
|
27
29
|
|
|
28
30
|
## Live demo
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
Go to the [demo](https://theme-transitions.vercel.app)
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
35
|
# from monorepo root
|
|
@@ -45,17 +47,6 @@ npm run build -w @maxigarcia/theme-transitions
|
|
|
45
47
|
npm run lint -w @maxigarcia/theme-transitions
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
### Versioning & publish (Nx Release)
|
|
49
|
-
|
|
50
|
-
Use [Conventional Commits](https://www.conventionalcommits.org/) for changes under this package (`feat`, `fix`, `perf`, etc.). From the monorepo root:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
npm run version-packages # bump version + changelog (no publish)
|
|
54
|
-
npm run release # publish to npm
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
CI on `main` versions and tags both projects, but only publishes this package to npm. See the [root README](../../README.md#releasing).
|
|
58
|
-
|
|
59
50
|
## Browser support
|
|
60
51
|
|
|
61
52
|
Requires [View Transitions](https://caniuse.com/view-transitions) for animated reveals. Unsupported browsers still apply the theme change without animation.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { $html, $onTransitionEnd } from '../utils/index.js';
|
|
2
2
|
export function onCircularRevealAnimation(apply, origin, options) {
|
|
3
|
+
if (!document.startViewTransition) {
|
|
4
|
+
apply();
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
3
7
|
const x = (origin.clientX / window.innerWidth) * 100;
|
|
4
8
|
const y = (origin.clientY / window.innerHeight) * 100;
|
|
5
9
|
const html = $html();
|
|
@@ -12,10 +16,6 @@ export function onCircularRevealAnimation(apply, origin, options) {
|
|
|
12
16
|
}
|
|
13
17
|
html.style.setProperty('--theme-reveal-x', `${x}%`);
|
|
14
18
|
html.style.setProperty('--theme-reveal-y', `${y}%`);
|
|
15
|
-
if (!document.startViewTransition) {
|
|
16
|
-
apply();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
19
|
document.startViewTransition(apply);
|
|
20
20
|
const animationComplete = () => {
|
|
21
21
|
html.style.removeProperty('--theme-reveal-x');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@keyframes theme-fall-out {
|
|
2
|
+
0% {
|
|
3
|
+
transform: translateY(0) scaleY(1) scaleX(1) skewY(0deg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
15% {
|
|
7
|
+
transform: translateY(3vh) scaleY(0.94) scaleX(1.02) skewY(1deg);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
100% {
|
|
11
|
+
transform: translateY(105%) scaleY(0.75) scaleX(1.06) skewY(4deg);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html.fall::view-transition-old(root),
|
|
16
|
+
html.fall::view-transition-new(root),
|
|
17
|
+
html.fall::view-transition-old(*),
|
|
18
|
+
html.fall::view-transition-new(*) {
|
|
19
|
+
mix-blend-mode: normal;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
html.fall::view-transition-group(root),
|
|
23
|
+
html.fall::view-transition-group(*) {
|
|
24
|
+
animation: none;
|
|
25
|
+
transform-origin: bottom center;
|
|
26
|
+
overflow: visible;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html.fall::view-transition-image-pair(root),
|
|
30
|
+
html.fall::view-transition-image-pair(*) {
|
|
31
|
+
isolation: isolate;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
html.fall::view-transition-old(root),
|
|
35
|
+
html.fall::view-transition-old(*) {
|
|
36
|
+
animation: theme-fall-out var(--theme-fall-duration, 700ms) cubic-bezier(0.33, 0, 0.67, 0.15) forwards;
|
|
37
|
+
transform-origin: bottom center;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
html.fall::view-transition-new(root),
|
|
43
|
+
html.fall::view-transition-new(*) {
|
|
44
|
+
animation: none;
|
|
45
|
+
opacity: 1;
|
|
46
|
+
z-index: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Reduce motion */
|
|
50
|
+
@media (prefers-reduced-motion: reduce) {
|
|
51
|
+
html.fall::view-transition-old(root),
|
|
52
|
+
html.fall::view-transition-new(root),
|
|
53
|
+
html.fall::view-transition-old(*),
|
|
54
|
+
html.fall::view-transition-new(*) {
|
|
55
|
+
animation: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fall/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,IAAI,EACjB,OAAO,CAAC,EAAE,WAAW,GACpB,IAAI,CAqBN"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $html } from '../utils/index.js';
|
|
2
|
+
export function onFallAnimation(apply, options) {
|
|
3
|
+
if (!document.startViewTransition) {
|
|
4
|
+
apply();
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const duration = options?.duration ?? 700;
|
|
8
|
+
const html = $html();
|
|
9
|
+
html.classList.add('fall');
|
|
10
|
+
html.style.setProperty('--theme-fall-duration', `${duration}ms`);
|
|
11
|
+
const transition = document.startViewTransition(apply);
|
|
12
|
+
const animationComplete = () => {
|
|
13
|
+
html.classList.remove('fall');
|
|
14
|
+
html.style.removeProperty('--theme-fall-duration');
|
|
15
|
+
};
|
|
16
|
+
void transition.finished.finally(animationComplete);
|
|
17
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxigarcia/theme-transitions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"homepage": "https://github.com/MaxiGarcia13/js-theme-animation-monorepo/tree/main/packages/theme-transitions#readme",
|
|
7
7
|
"repository": {
|
|
@@ -31,8 +31,9 @@
|
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"import": "./dist/index.js"
|
|
33
33
|
},
|
|
34
|
-
"./circular-reveal
|
|
35
|
-
"./
|
|
34
|
+
"./circular-reveal.css": "./dist/circular-reveal/index.css",
|
|
35
|
+
"./fall.css": "./dist/fall/index.css",
|
|
36
|
+
"./sweep-reveal.css": "./dist/sweep-reveal/index.css"
|
|
36
37
|
},
|
|
37
38
|
"main": "./dist/index.js",
|
|
38
39
|
"types": "./dist/index.d.ts",
|