@matteodicristofalo/text-animations 2.0.1 → 2.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 +4 -0
- package/dist/eslint.config.d.ts +2 -0
- package/dist/index.css +5 -19
- package/dist/index.js +86 -69
- package/dist/src/components/text-reveal/text-reveal.d.ts +24 -0
- package/dist/{components → src/components}/text-reveal/text-reveal.stories.d.ts +5 -3
- package/dist/src/components/text-rotate/text-rotate.d.ts +20 -0
- package/dist/{components/text-rotate/split-text-rotate.stories.d.ts → src/components/text-rotate/text-rotate.stories.d.ts} +5 -3
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/use-is-hydrated.d.ts +1 -0
- package/dist/src/utils/jsx.d.ts +10 -0
- package/dist/src/utils/types.d.ts +5 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +41 -15
- package/dist/components/text-reveal/text-reveal.d.ts +0 -92
- package/dist/components/text-rotate/text-rotate.d.ts +0 -60
- package/dist/hooks/index.d.ts +0 -1
- package/dist/utils/jsx.d.ts +0 -7
- /package/dist/{components → src/components}/index.d.ts +0 -0
- /package/dist/{hooks/intersection-overser/intersection-observer.d.ts → src/hooks/use-intersection-observer.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{utils → src/utils}/numbers.d.ts +0 -0
- /package/dist/{utils → src/utils}/text.d.ts +0 -0
package/README.md
CHANGED
|
@@ -61,6 +61,8 @@ export function MyComponent() {
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
If you're using **Next.JS** make sure the component importing `<textReveal>` is marked as **Client Component** via the `"use client"` directive otherwise it won't compile.
|
|
65
|
+
|
|
64
66
|
You can decide how to split the text between one of this options:
|
|
65
67
|
|
|
66
68
|
- char (default)
|
|
@@ -118,6 +120,8 @@ export function MyComponent() {
|
|
|
118
120
|
}
|
|
119
121
|
```
|
|
120
122
|
|
|
123
|
+
As well as `<textReveal>`, If you're using **Next.JS** make sure the component importing `<textRotate>` is marked as **Client Component** via the `"use client"`.
|
|
124
|
+
|
|
121
125
|
This component split always by char, the only thing you can configure is the rotate animation
|
|
122
126
|
|
|
123
127
|
```js
|
package/dist/index.css
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
.text-reveal-module_text__YrhhT {
|
|
2
2
|
position: relative;
|
|
3
3
|
}
|
|
4
|
-
.text-reveal-module_text__YrhhT .text-reveal-module_is-hidden__B7wsX {
|
|
5
|
-
opacity: 0;
|
|
6
|
-
}
|
|
7
|
-
.text-reveal-module_text__YrhhT .text-reveal-module_sr-only__ZQJa3 {
|
|
8
|
-
height: 0;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
position: absolute;
|
|
11
|
-
width: 0;
|
|
12
|
-
}
|
|
13
4
|
.text-reveal-module_text__YrhhT .text-reveal-module_container__HD1Pu {
|
|
14
|
-
display: inline-
|
|
5
|
+
display: inline-block;
|
|
15
6
|
overflow: hidden;
|
|
16
7
|
}
|
|
17
8
|
.text-reveal-module_text__YrhhT .text-reveal-module_container__HD1Pu span {
|
|
18
|
-
|
|
9
|
+
display: inline-block;
|
|
19
10
|
transform: translateY(100%);
|
|
20
11
|
transition-delay: calc(var(--var-delay) + var(--var-stagger));
|
|
21
12
|
transition-duration: var(--var-duration);
|
|
22
13
|
transition-property: transform;
|
|
23
14
|
transition-timing-function: ease-out;
|
|
15
|
+
white-space: pre;
|
|
24
16
|
will-change: transform;
|
|
25
17
|
}
|
|
26
18
|
.text-reveal-module_text__YrhhT.text-reveal-module_animate__kbOPX .text-reveal-module_container__HD1Pu span {
|
|
@@ -31,14 +23,8 @@
|
|
|
31
23
|
overflow: hidden;
|
|
32
24
|
position: relative;
|
|
33
25
|
}
|
|
34
|
-
.text-rotate-module_text__WKSY- .text-rotate-module_sr-only__1ofAD {
|
|
35
|
-
height: 0;
|
|
36
|
-
overflow: hidden;
|
|
37
|
-
position: absolute;
|
|
38
|
-
width: 0;
|
|
39
|
-
}
|
|
40
26
|
.text-rotate-module_text__WKSY- .text-rotate-module_container__2qsrm {
|
|
41
|
-
display:
|
|
27
|
+
display: block;
|
|
42
28
|
}
|
|
43
29
|
.text-rotate-module_text__WKSY- .text-rotate-module_container__2qsrm:nth-of-type(2) {
|
|
44
30
|
position: absolute;
|
|
@@ -47,11 +33,11 @@
|
|
|
47
33
|
}
|
|
48
34
|
.text-rotate-module_text__WKSY- .text-rotate-module_container__2qsrm .text-rotate-module_char__LG3ps {
|
|
49
35
|
display: inline-block;
|
|
50
|
-
min-width: 0.25em;
|
|
51
36
|
transition-delay: var(--var-delay-out);
|
|
52
37
|
transition-duration: var(--var-duration);
|
|
53
38
|
transition-property: transform;
|
|
54
39
|
transition-timing-function: ease-out;
|
|
40
|
+
white-space: pre;
|
|
55
41
|
will-change: transform;
|
|
56
42
|
}
|
|
57
43
|
.text-rotate-module_text__WKSY-:hover .text-rotate-module_container__2qsrm .text-rotate-module_char__LG3ps {
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
3
2
|
|
|
4
|
-
function round(num, digits) {
|
|
5
|
-
return parseFloat(num.toFixed(digits));
|
|
6
|
-
}
|
|
7
|
-
function clamp(n, min, max) {
|
|
8
|
-
return Math.min(Math.max(min, n), max);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function sentences(text) {
|
|
12
|
-
return segment(text, "sentence");
|
|
13
|
-
}
|
|
14
|
-
function words(text) {
|
|
15
|
-
return segment(text, "word");
|
|
16
|
-
}
|
|
17
|
-
function characters(text) {
|
|
18
|
-
return segment(text, "grapheme");
|
|
19
|
-
}
|
|
20
|
-
function segment(text, granularity) {
|
|
21
|
-
var segmenter = new Intl.Segmenter(undefined, { granularity: granularity });
|
|
22
|
-
return Array.from(segmenter.segment(text), function (segment) { return segment.segment; });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
3
|
/******************************************************************************
|
|
26
4
|
Copyright (c) Microsoft Corporation.
|
|
27
5
|
|
|
@@ -55,6 +33,27 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
55
33
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
56
34
|
};
|
|
57
35
|
|
|
36
|
+
function round(num, digits) {
|
|
37
|
+
return parseFloat(num.toFixed(digits));
|
|
38
|
+
}
|
|
39
|
+
function clamp(n, min, max) {
|
|
40
|
+
return Math.min(Math.max(min, n), max);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function sentences(text) {
|
|
44
|
+
return segment(text, "sentence");
|
|
45
|
+
}
|
|
46
|
+
function words(text) {
|
|
47
|
+
return segment(text, "word");
|
|
48
|
+
}
|
|
49
|
+
function characters(text) {
|
|
50
|
+
return segment(text, "grapheme");
|
|
51
|
+
}
|
|
52
|
+
function segment(text, granularity) {
|
|
53
|
+
var segmenter = new Intl.Segmenter(undefined, { granularity: granularity });
|
|
54
|
+
return Array.from(segmenter.segment(text), function (segment) { return segment.segment; });
|
|
55
|
+
}
|
|
56
|
+
|
|
58
57
|
function useIntersectionObserver(ref, options) {
|
|
59
58
|
var _a = useState(false), isIntersecting = _a[0], setIntersecting = _a[1];
|
|
60
59
|
useEffect(function () {
|
|
@@ -78,6 +77,14 @@ function useIntersectionObserver(ref, options) {
|
|
|
78
77
|
return isIntersecting;
|
|
79
78
|
}
|
|
80
79
|
|
|
80
|
+
function useIsHydrated() {
|
|
81
|
+
var _a = useState(false), isHydrated = _a[0], setIsHydrated = _a[1];
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
setIsHydrated(true);
|
|
84
|
+
}, []);
|
|
85
|
+
return isHydrated;
|
|
86
|
+
}
|
|
87
|
+
|
|
81
88
|
var htmlTextElementTags = [
|
|
82
89
|
"h1",
|
|
83
90
|
"h2",
|
|
@@ -88,27 +95,37 @@ var htmlTextElementTags = [
|
|
|
88
95
|
"p",
|
|
89
96
|
"span",
|
|
90
97
|
];
|
|
91
|
-
function generateJsxVariations(
|
|
92
|
-
return htmlTextElementTags.reduce(function (variations,
|
|
93
|
-
variations[
|
|
98
|
+
function generateJsxVariations(Component) {
|
|
99
|
+
return htmlTextElementTags.reduce(function (variations, tag) {
|
|
100
|
+
variations[tag] = function (props) { return (React.createElement(Component, __assign({}, props, { tag: tag }))); };
|
|
94
101
|
return variations;
|
|
95
102
|
}, {});
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
99
106
|
|
|
100
|
-
var styles$1 = {"text":"text-reveal-module_text__YrhhT","
|
|
107
|
+
var styles$1 = {"text":"text-reveal-module_text__YrhhT","container":"text-reveal-module_container__HD1Pu","animate":"text-reveal-module_animate__kbOPX"};
|
|
101
108
|
|
|
102
109
|
var DEFAULT_DURATION$1 = 0.5;
|
|
103
110
|
var DEFAULT_STAGGER$1 = 0.01;
|
|
104
111
|
var MIN_THRESHOLD = 0;
|
|
105
112
|
var MAX_THRESHOLD = 1;
|
|
106
113
|
var DEFAULT_THRESHOLD = 0.25;
|
|
107
|
-
function TextReveal(
|
|
114
|
+
function TextReveal(props) {
|
|
115
|
+
var isHydrated = useIsHydrated();
|
|
116
|
+
if (isHydrated === false) {
|
|
117
|
+
return React.createElement(TextRevealServer, __assign({}, props));
|
|
118
|
+
}
|
|
119
|
+
return React.createElement(TextRevealClient, __assign({}, props));
|
|
120
|
+
}
|
|
121
|
+
function TextRevealServer(_a) {
|
|
122
|
+
var Tag = _a.tag, text = _a.text;
|
|
123
|
+
return React.createElement(Tag, { style: { opacity: 0 } }, text);
|
|
124
|
+
}
|
|
125
|
+
function TextRevealClient(_a) {
|
|
108
126
|
var _b;
|
|
109
|
-
var text = _a.text, _c = _a.splitType, splitType = _c === void 0 ? "char" : _c, animation = _a.animation;
|
|
127
|
+
var Tag = _a.tag, text = _a.text, _c = _a.splitType, splitType = _c === void 0 ? "char" : _c, animation = _a.animation;
|
|
110
128
|
var ref = useRef(null);
|
|
111
|
-
var _d = useState(false), hasBeenMounted = _d[0], setHasBeenMounted = _d[1];
|
|
112
129
|
var intersectionObserverOptions = useMemo(function () {
|
|
113
130
|
var _a;
|
|
114
131
|
var once = (_a = animation === null || animation === void 0 ? void 0 : animation.once) !== null && _a !== void 0 ? _a : true;
|
|
@@ -133,57 +150,57 @@ function TextReveal(_a) {
|
|
|
133
150
|
return characters(text);
|
|
134
151
|
}
|
|
135
152
|
}, [splitType, text]);
|
|
136
|
-
|
|
137
|
-
setHasBeenMounted(true);
|
|
138
|
-
}, []);
|
|
139
|
-
return (React.createElement("span", { ref: ref, className: clsx(styles$1["text"], (_b = {}, _b[styles$1["animate"]] = isInView, _b)), style: {
|
|
153
|
+
return (React.createElement(Tag, { ref: ref, className: clsx(styles$1["text"], (_b = {}, _b[styles$1["animate"]] = isInView, _b)), style: {
|
|
140
154
|
"--var-duration": "".concat(duration, "s"),
|
|
141
|
-
} },
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} }, el)));
|
|
150
|
-
}))) : (React.createElement("span", { className: styles$1["is-hidden"] }, text))));
|
|
155
|
+
}, "aria-label": text }, splittedText.map(function (el, i) {
|
|
156
|
+
var _a;
|
|
157
|
+
return (React.createElement("span", { key: i, className: styles$1["container"], "aria-hidden": "true" },
|
|
158
|
+
React.createElement("span", { "aria-hidden": "true", style: {
|
|
159
|
+
"--var-delay": "".concat((_a = animation === null || animation === void 0 ? void 0 : animation.delay) !== null && _a !== void 0 ? _a : 0, "s"),
|
|
160
|
+
"--var-stagger": "".concat(round(stagger * i, 3), "s"),
|
|
161
|
+
} }, el)));
|
|
162
|
+
})));
|
|
151
163
|
}
|
|
152
164
|
var textReveal = generateJsxVariations(TextReveal);
|
|
153
165
|
|
|
154
|
-
var styles = {"text":"text-rotate-module_text__WKSY-","
|
|
166
|
+
var styles = {"text":"text-rotate-module_text__WKSY-","container":"text-rotate-module_container__2qsrm","char":"text-rotate-module_char__LG3ps"};
|
|
155
167
|
|
|
168
|
+
var NUMBER_OF_COPIES = 2;
|
|
156
169
|
var DEFAULT_DURATION = 0.25;
|
|
157
170
|
var DEFAULT_STAGGER = 0.025;
|
|
158
|
-
function TextRotate(
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
function TextRotate(props) {
|
|
172
|
+
var isHydrated = useIsHydrated();
|
|
173
|
+
if (isHydrated === false) {
|
|
174
|
+
return React.createElement(TextRotateServer, __assign({}, props));
|
|
175
|
+
}
|
|
176
|
+
return React.createElement(TextRotateClient, __assign({}, props));
|
|
177
|
+
}
|
|
178
|
+
function TextRotateServer(_a) {
|
|
179
|
+
var Tag = _a.tag, text = _a.text;
|
|
180
|
+
return React.createElement(Tag, null, text);
|
|
181
|
+
}
|
|
182
|
+
function TextRotateClient(_a) {
|
|
183
|
+
var Tag = _a.tag, text = _a.text, animation = _a.animation;
|
|
184
|
+
var duration = (animation === null || animation === void 0 ? void 0 : animation.duration) || DEFAULT_DURATION;
|
|
185
|
+
var stagger = (animation === null || animation === void 0 ? void 0 : animation.stagger) || DEFAULT_STAGGER;
|
|
186
|
+
var chars = useMemo(function () { return characters(text); }, [text]);
|
|
166
187
|
var delays = useCallback(function (index) {
|
|
167
|
-
var
|
|
188
|
+
var precision = 3;
|
|
189
|
+
var noElementsZeroBased = chars.length - 1;
|
|
168
190
|
return {
|
|
169
|
-
in: round(stagger * index,
|
|
170
|
-
out: round(stagger * (noElementsZeroBased - index),
|
|
191
|
+
in: round(stagger * index, precision),
|
|
192
|
+
out: round(stagger * (noElementsZeroBased - index), precision),
|
|
171
193
|
};
|
|
172
|
-
}, [
|
|
173
|
-
|
|
174
|
-
setHasBeenMounted(true);
|
|
175
|
-
}, []);
|
|
176
|
-
return (React.createElement("span", { className: styles["text"], style: {
|
|
194
|
+
}, [chars, stagger]);
|
|
195
|
+
return (React.createElement(Tag, { className: styles["text"], style: {
|
|
177
196
|
"--var-duration": "".concat(duration, "s"),
|
|
178
|
-
} },
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} }, char));
|
|
186
|
-
}))); }))) : (React.createElement("span", null, text))));
|
|
197
|
+
}, "aria-label": text }, Array.from({ length: NUMBER_OF_COPIES }).map(function (_, i) { return (React.createElement("span", { key: i, className: styles["container"], "aria-hidden": "true" }, chars.map(function (char, i) {
|
|
198
|
+
var charDelays = delays(i);
|
|
199
|
+
return (React.createElement("span", { key: i, className: styles["char"], "aria-hidden": "true", style: {
|
|
200
|
+
"--var-delay-in": "".concat(charDelays.in, "s"),
|
|
201
|
+
"--var-delay-out": "".concat(charDelays.out, "s"),
|
|
202
|
+
} }, char));
|
|
203
|
+
}))); })));
|
|
187
204
|
}
|
|
188
205
|
var textRotate = generateJsxVariations(TextRotate);
|
|
189
206
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { WithTag } from "@utils/types";
|
|
3
|
+
type TextRevealProps = WithTag<{
|
|
4
|
+
text: string;
|
|
5
|
+
splitType?: "sentence" | "word" | "char";
|
|
6
|
+
animation?: Partial<{
|
|
7
|
+
duration: number;
|
|
8
|
+
delay: number;
|
|
9
|
+
stagger: number;
|
|
10
|
+
threshold: number;
|
|
11
|
+
once: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
declare const textReveal: {
|
|
15
|
+
h1: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
16
|
+
h2: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
17
|
+
h3: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
18
|
+
h4: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
19
|
+
h5: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
20
|
+
h6: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
21
|
+
p: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
22
|
+
span: React.FC<import("@utils/types").WithoutTag<TextRevealProps>>;
|
|
23
|
+
};
|
|
24
|
+
export { textReveal };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: React.FC<{
|
|
5
|
+
component: React.FC<import("../../utils/types").WithoutTag<{
|
|
6
6
|
text: string;
|
|
7
7
|
splitType?: "sentence" | "word" | "char";
|
|
8
8
|
animation?: Partial<{
|
|
@@ -12,7 +12,9 @@ declare const meta: {
|
|
|
12
12
|
threshold: number;
|
|
13
13
|
once: boolean;
|
|
14
14
|
}>;
|
|
15
|
-
}
|
|
15
|
+
} & {
|
|
16
|
+
tag: import("../../utils/jsx").HtmlTextElementTag;
|
|
17
|
+
}>>;
|
|
16
18
|
argTypes: {
|
|
17
19
|
text: {
|
|
18
20
|
control: "text";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { WithTag } from "@utils/types";
|
|
3
|
+
type TextRotateProps = WithTag<{
|
|
4
|
+
text: string;
|
|
5
|
+
animation?: Partial<{
|
|
6
|
+
duration: number;
|
|
7
|
+
stagger: number;
|
|
8
|
+
}>;
|
|
9
|
+
}>;
|
|
10
|
+
declare const textRotate: {
|
|
11
|
+
h1: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
12
|
+
h2: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
13
|
+
h3: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
14
|
+
h4: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
15
|
+
h5: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
16
|
+
h6: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
17
|
+
p: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
18
|
+
span: React.FC<import("@utils/types").WithoutTag<TextRotateProps>>;
|
|
19
|
+
};
|
|
20
|
+
export { textRotate };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { StoryObj } from "@storybook/react";
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: import("react").FC<{
|
|
4
|
+
component: import("react").FC<import("../../utils/types").WithoutTag<{
|
|
5
5
|
text: string;
|
|
6
6
|
animation?: Partial<{
|
|
7
7
|
duration: number;
|
|
8
8
|
stagger: number;
|
|
9
9
|
}>;
|
|
10
|
-
}
|
|
10
|
+
} & {
|
|
11
|
+
tag: import("../../utils/jsx").HtmlTextElementTag;
|
|
12
|
+
}>>;
|
|
11
13
|
argTypes: {
|
|
12
14
|
text: {
|
|
13
15
|
control: "text";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsHydrated(): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { WithoutTag } from "./types";
|
|
3
|
+
declare const htmlTextElementTags: readonly ["h1", "h2", "h3", "h4", "h5", "h6", "p", "span"];
|
|
4
|
+
export type HtmlTextElementTag = (typeof htmlTextElementTags)[number];
|
|
5
|
+
export declare function generateJsxVariations<Props extends {
|
|
6
|
+
tag: HtmlTextElementTag;
|
|
7
|
+
}>(Component: React.FC<Props>): {
|
|
8
|
+
[k in HtmlTextElementTag]: React.FC<WithoutTag<Props>>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matteodicristofalo/text-animations",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "React library to animate text",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "Lightweight React component library to animate text",
|
|
5
5
|
"scripts": {
|
|
6
|
+
"lint": "eslint src",
|
|
7
|
+
"test": "vitest --project=storybook",
|
|
6
8
|
"build": "rimraf dist && rollup -c",
|
|
7
9
|
"storybook": "storybook dev -p 6006"
|
|
8
10
|
},
|
|
@@ -10,29 +12,39 @@
|
|
|
10
12
|
"clsx": "^2.1.1"
|
|
11
13
|
},
|
|
12
14
|
"devDependencies": {
|
|
13
|
-
"@chromatic-com/storybook": "^
|
|
15
|
+
"@chromatic-com/storybook": "^5.0.0",
|
|
16
|
+
"@eslint/js": "^9.39.2",
|
|
14
17
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
15
18
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
16
|
-
"@storybook/addon-
|
|
17
|
-
"@storybook/addon-
|
|
18
|
-
"@storybook/addon-
|
|
19
|
-
"@storybook/
|
|
20
|
-
"@storybook/react": "^8.4.6",
|
|
21
|
-
"@storybook/react-vite": "^8.4.6",
|
|
22
|
-
"@storybook/test": "^8.4.6",
|
|
19
|
+
"@storybook/addon-a11y": "^10.2.3",
|
|
20
|
+
"@storybook/addon-docs": "^10.2.3",
|
|
21
|
+
"@storybook/addon-vitest": "^10.2.3",
|
|
22
|
+
"@storybook/react-vite": "^10.2.3",
|
|
23
23
|
"@types/node": "^20",
|
|
24
24
|
"@types/react": "^18",
|
|
25
25
|
"@types/react-dom": "^18",
|
|
26
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
27
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
28
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
29
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
30
|
+
"eslint-plugin-react": "^7.37.5",
|
|
31
|
+
"eslint-plugin-storybook": "^10.2.3",
|
|
32
|
+
"eslint": "^9.39.2",
|
|
33
|
+
"globals": "^17.2.0",
|
|
34
|
+
"jiti": "^2.6.1",
|
|
35
|
+
"playwright": "^1.58.1",
|
|
26
36
|
"rimraf": "^6.0.1",
|
|
27
|
-
"rollup": "^4.28.0",
|
|
28
37
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
29
38
|
"rollup-plugin-postcss": "^4.0.2",
|
|
30
|
-
"rollup
|
|
39
|
+
"rollup": "^4.28.0",
|
|
31
40
|
"sass": "^1.81.0",
|
|
32
|
-
"storybook": "^
|
|
41
|
+
"storybook": "^10.2.3",
|
|
33
42
|
"tslib": "^2.8.1",
|
|
43
|
+
"typescript-eslint": "^8.54.0",
|
|
34
44
|
"typescript": "^5.7.2",
|
|
35
|
-
"vite-tsconfig-paths": "^5.1.3"
|
|
45
|
+
"vite-tsconfig-paths": "^5.1.3",
|
|
46
|
+
"vite": "^7.2.4",
|
|
47
|
+
"vitest": "^4.0.18"
|
|
36
48
|
},
|
|
37
49
|
"peerDependencies": {
|
|
38
50
|
"react": "^18.3.1",
|
|
@@ -53,5 +65,19 @@
|
|
|
53
65
|
"repository": {
|
|
54
66
|
"type": "git",
|
|
55
67
|
"url": "git@github.com:matteodicristofalo/text-animations.git"
|
|
56
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"react",
|
|
71
|
+
"react-components",
|
|
72
|
+
"ui-library",
|
|
73
|
+
"animation",
|
|
74
|
+
"animated-text",
|
|
75
|
+
"text-animation",
|
|
76
|
+
"text-reveal",
|
|
77
|
+
"hover",
|
|
78
|
+
"hover-effects",
|
|
79
|
+
"scroll-animation",
|
|
80
|
+
"typography",
|
|
81
|
+
"microinteractions"
|
|
82
|
+
]
|
|
57
83
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
declare const textReveal: {
|
|
3
|
-
h1: React.FC<{
|
|
4
|
-
text: string;
|
|
5
|
-
splitType?: "sentence" | "word" | "char";
|
|
6
|
-
animation?: Partial<{
|
|
7
|
-
duration: number;
|
|
8
|
-
delay: number;
|
|
9
|
-
stagger: number;
|
|
10
|
-
threshold: number;
|
|
11
|
-
once: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
}>;
|
|
14
|
-
h2: React.FC<{
|
|
15
|
-
text: string;
|
|
16
|
-
splitType?: "sentence" | "word" | "char";
|
|
17
|
-
animation?: Partial<{
|
|
18
|
-
duration: number;
|
|
19
|
-
delay: number;
|
|
20
|
-
stagger: number;
|
|
21
|
-
threshold: number;
|
|
22
|
-
once: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
}>;
|
|
25
|
-
h3: React.FC<{
|
|
26
|
-
text: string;
|
|
27
|
-
splitType?: "sentence" | "word" | "char";
|
|
28
|
-
animation?: Partial<{
|
|
29
|
-
duration: number;
|
|
30
|
-
delay: number;
|
|
31
|
-
stagger: number;
|
|
32
|
-
threshold: number;
|
|
33
|
-
once: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
}>;
|
|
36
|
-
h4: React.FC<{
|
|
37
|
-
text: string;
|
|
38
|
-
splitType?: "sentence" | "word" | "char";
|
|
39
|
-
animation?: Partial<{
|
|
40
|
-
duration: number;
|
|
41
|
-
delay: number;
|
|
42
|
-
stagger: number;
|
|
43
|
-
threshold: number;
|
|
44
|
-
once: boolean;
|
|
45
|
-
}>;
|
|
46
|
-
}>;
|
|
47
|
-
h5: React.FC<{
|
|
48
|
-
text: string;
|
|
49
|
-
splitType?: "sentence" | "word" | "char";
|
|
50
|
-
animation?: Partial<{
|
|
51
|
-
duration: number;
|
|
52
|
-
delay: number;
|
|
53
|
-
stagger: number;
|
|
54
|
-
threshold: number;
|
|
55
|
-
once: boolean;
|
|
56
|
-
}>;
|
|
57
|
-
}>;
|
|
58
|
-
h6: React.FC<{
|
|
59
|
-
text: string;
|
|
60
|
-
splitType?: "sentence" | "word" | "char";
|
|
61
|
-
animation?: Partial<{
|
|
62
|
-
duration: number;
|
|
63
|
-
delay: number;
|
|
64
|
-
stagger: number;
|
|
65
|
-
threshold: number;
|
|
66
|
-
once: boolean;
|
|
67
|
-
}>;
|
|
68
|
-
}>;
|
|
69
|
-
p: React.FC<{
|
|
70
|
-
text: string;
|
|
71
|
-
splitType?: "sentence" | "word" | "char";
|
|
72
|
-
animation?: Partial<{
|
|
73
|
-
duration: number;
|
|
74
|
-
delay: number;
|
|
75
|
-
stagger: number;
|
|
76
|
-
threshold: number;
|
|
77
|
-
once: boolean;
|
|
78
|
-
}>;
|
|
79
|
-
}>;
|
|
80
|
-
span: React.FC<{
|
|
81
|
-
text: string;
|
|
82
|
-
splitType?: "sentence" | "word" | "char";
|
|
83
|
-
animation?: Partial<{
|
|
84
|
-
duration: number;
|
|
85
|
-
delay: number;
|
|
86
|
-
stagger: number;
|
|
87
|
-
threshold: number;
|
|
88
|
-
once: boolean;
|
|
89
|
-
}>;
|
|
90
|
-
}>;
|
|
91
|
-
};
|
|
92
|
-
export { textReveal };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
declare const textRotate: {
|
|
3
|
-
h1: React.FC<{
|
|
4
|
-
text: string;
|
|
5
|
-
animation?: Partial<{
|
|
6
|
-
duration: number;
|
|
7
|
-
stagger: number;
|
|
8
|
-
}>;
|
|
9
|
-
}>;
|
|
10
|
-
h2: React.FC<{
|
|
11
|
-
text: string;
|
|
12
|
-
animation?: Partial<{
|
|
13
|
-
duration: number;
|
|
14
|
-
stagger: number;
|
|
15
|
-
}>;
|
|
16
|
-
}>;
|
|
17
|
-
h3: React.FC<{
|
|
18
|
-
text: string;
|
|
19
|
-
animation?: Partial<{
|
|
20
|
-
duration: number;
|
|
21
|
-
stagger: number;
|
|
22
|
-
}>;
|
|
23
|
-
}>;
|
|
24
|
-
h4: React.FC<{
|
|
25
|
-
text: string;
|
|
26
|
-
animation?: Partial<{
|
|
27
|
-
duration: number;
|
|
28
|
-
stagger: number;
|
|
29
|
-
}>;
|
|
30
|
-
}>;
|
|
31
|
-
h5: React.FC<{
|
|
32
|
-
text: string;
|
|
33
|
-
animation?: Partial<{
|
|
34
|
-
duration: number;
|
|
35
|
-
stagger: number;
|
|
36
|
-
}>;
|
|
37
|
-
}>;
|
|
38
|
-
h6: React.FC<{
|
|
39
|
-
text: string;
|
|
40
|
-
animation?: Partial<{
|
|
41
|
-
duration: number;
|
|
42
|
-
stagger: number;
|
|
43
|
-
}>;
|
|
44
|
-
}>;
|
|
45
|
-
p: React.FC<{
|
|
46
|
-
text: string;
|
|
47
|
-
animation?: Partial<{
|
|
48
|
-
duration: number;
|
|
49
|
-
stagger: number;
|
|
50
|
-
}>;
|
|
51
|
-
}>;
|
|
52
|
-
span: React.FC<{
|
|
53
|
-
text: string;
|
|
54
|
-
animation?: Partial<{
|
|
55
|
-
duration: number;
|
|
56
|
-
stagger: number;
|
|
57
|
-
}>;
|
|
58
|
-
}>;
|
|
59
|
-
};
|
|
60
|
-
export { textRotate };
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useIntersectionObserver } from "./intersection-overser/intersection-observer";
|
package/dist/utils/jsx.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
declare const htmlTextElementTags: readonly ["h1", "h2", "h3", "h4", "h5", "h6", "p", "span"];
|
|
3
|
-
type HtmlTextElementTag = (typeof htmlTextElementTags)[number];
|
|
4
|
-
export declare function generateJsxVariations<Props>(component: React.FC<Props>): {
|
|
5
|
-
[k in HtmlTextElementTag]: React.FC<Props>;
|
|
6
|
-
};
|
|
7
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|