@weser/keyframes 0.0.6 → 0.0.8
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/dist/createKeyframe.d.ts +2 -2
- package/dist/createKeyframe.js +8 -8
- package/dist/index.d.ts +1 -1
- package/package.json +7 -2
package/dist/createKeyframe.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, createElement } from 'react';
|
|
2
2
|
type Key = `${number}%` | 'from' | 'to';
|
|
3
|
-
export type
|
|
4
|
-
export default function createKeyframe(style:
|
|
3
|
+
export type T_Keyframe = Partial<Record<Key, CSSProperties>>;
|
|
4
|
+
export default function createKeyframe(style: T_Keyframe, nonce?: string): [string, ReturnType<typeof createElement>];
|
|
5
5
|
export {};
|
package/dist/createKeyframe.js
CHANGED
|
@@ -2,14 +2,6 @@ import { createElement } from 'react';
|
|
|
2
2
|
import { cssifyObject } from 'css-in-js-utils';
|
|
3
3
|
import hash from './hash.js';
|
|
4
4
|
const cache = new Map();
|
|
5
|
-
function getValueFromCache(animationName, style) {
|
|
6
|
-
if (!cache.has(animationName)) {
|
|
7
|
-
const keyframe = Object.entries(style).reduce((keyframe, [key, declaration = {}]) => keyframe + key + '{' + cssifyObject(declaration) + '}', '');
|
|
8
|
-
const css = `@keyframes ${animationName}{${keyframe}}`;
|
|
9
|
-
cache.set(animationName, css);
|
|
10
|
-
}
|
|
11
|
-
return cache.get(animationName);
|
|
12
|
-
}
|
|
13
5
|
export default function createKeyframe(style, nonce) {
|
|
14
6
|
const animationName = '_' + hash(JSON.stringify(style));
|
|
15
7
|
const css = getValueFromCache(animationName, style);
|
|
@@ -21,3 +13,11 @@ export default function createKeyframe(style, nonce) {
|
|
|
21
13
|
});
|
|
22
14
|
return [animationName, node];
|
|
23
15
|
}
|
|
16
|
+
function getValueFromCache(animationName, style) {
|
|
17
|
+
if (!cache.has(animationName)) {
|
|
18
|
+
const keyframe = Object.entries(style).reduce((keyframe, [key, declaration = {}]) => keyframe + key + '{' + cssifyObject(declaration) + '}', '');
|
|
19
|
+
const css = `@keyframes ${animationName}{${keyframe}}`;
|
|
20
|
+
cache.set(animationName, css);
|
|
21
|
+
}
|
|
22
|
+
return cache.get(animationName);
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as createKeyframe,
|
|
1
|
+
export { default as createKeyframe, T_Keyframe } from './createKeyframe.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weser/keyframes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Tiny helpers for CSS keyframes in React",
|
|
5
5
|
"author": "Robin Weser <robin@weser.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,13 +40,18 @@
|
|
|
40
40
|
"invariant",
|
|
41
41
|
"utils"
|
|
42
42
|
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">16.3.0"
|
|
45
|
+
},
|
|
43
46
|
"dependencies": {
|
|
44
47
|
"css-in-js-utils": "^3.1.0"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
50
|
+
"@types/react": "^18.3.3",
|
|
47
51
|
"ava": "^6.1.3",
|
|
52
|
+
"react": "canary",
|
|
48
53
|
"rimraf": "^3.0.2",
|
|
49
54
|
"typescript": "^5.4.5"
|
|
50
55
|
},
|
|
51
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9dce5f658f08431e80506b022369229dfeff7dd7"
|
|
52
57
|
}
|