ecloud-spark 1.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 +285 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Spark
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Spark is our React component library.
|
|
6
|
+
|
|
7
|
+
<br/>
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Run `npm i @ecloudhub/spark`
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
|
|
15
|
+
## Folder Structure
|
|
16
|
+
|
|
17
|
+
- **/src:** @ecloudHub/spark's raw code.
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
|
|
21
|
+
## Spark in use
|
|
22
|
+
|
|
23
|
+
- [@ecloudHub/Flame](https://flame-eta.vercel.app/).
|
|
24
|
+
|
|
25
|
+
<br />
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
Most of the components work with `ScrollTrigger` from `GSAP` so check their [docs](https://greensock.com/docs/v3/Plugins/ScrollTrigger/) for detailed info.
|
|
30
|
+
|
|
31
|
+
### Menu
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
interface Menu {
|
|
35
|
+
// Element to toggle the menu state
|
|
36
|
+
button?: React.ReactElement;
|
|
37
|
+
// Menu content
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
// Menu will be visible or hidden based on isOpen value. Default: false.
|
|
40
|
+
isOpen?: boolean;
|
|
41
|
+
// To show or hide the overlay. Default: false.
|
|
42
|
+
withOverlay?: boolean;
|
|
43
|
+
// To close menu on overlay click. Default: true.
|
|
44
|
+
closeOnOverlayClick?: boolean;
|
|
45
|
+
// For customization purposes you can pass classes to the menu container. Default: ''.
|
|
46
|
+
menuClass?: string;
|
|
47
|
+
// For customization purposes you can pass classes to the body. Default: ''.
|
|
48
|
+
bodyClass?: string;
|
|
49
|
+
// For customization purposes you can pass classes to the overlay. Default: ''.
|
|
50
|
+
overlayClass?: string;
|
|
51
|
+
// Menu alignment. Default: 'left'.
|
|
52
|
+
alignment?: "left" | "right";
|
|
53
|
+
// The function the overlay will execute on click
|
|
54
|
+
onClose: Dispatch<SetStateAction<boolean>>;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Button
|
|
59
|
+
|
|
60
|
+
Just a default button
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
type Button = {
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
className?: string;
|
|
66
|
+
// Choose between button and a element. Default: button.
|
|
67
|
+
as?:
|
|
68
|
+
| (JSX.IntrinsicElements["a"] & { as?: "a" })
|
|
69
|
+
| (JSX.IntrinsicElements["button"] & { as: "button" });
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Magnetic Button
|
|
74
|
+
|
|
75
|
+
When the cursor is near the button this one will follow it a little.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
type MagneticButton = {
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
className?: string;
|
|
81
|
+
// Choose between button and a elements.
|
|
82
|
+
as?:
|
|
83
|
+
| (JSX.IntrinsicElements["a"] & { as?: "a" })
|
|
84
|
+
| (JSX.IntrinsicElements["button"] & { as: "button" });
|
|
85
|
+
// If you want to use another button. Otherwise it will use the Button component.
|
|
86
|
+
button?: React.ReactElement;
|
|
87
|
+
// To determine how much it will move. Default: 0.5.
|
|
88
|
+
movement?: number;
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Elastic Button
|
|
93
|
+
|
|
94
|
+
A button with an "elastic" movement on hover.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
type ElasticButton = {
|
|
98
|
+
children?: React.ReactNode;
|
|
99
|
+
className?: string;
|
|
100
|
+
// Choose between button and a elements.
|
|
101
|
+
as?:
|
|
102
|
+
| (JSX.IntrinsicElements["a"] & { as?: "a" })
|
|
103
|
+
| (JSX.IntrinsicElements["button"] & { as: "button" });
|
|
104
|
+
// If you want to use another button. Otherwise it will use the Button component look & feel.
|
|
105
|
+
button?: React.ReactElement;
|
|
106
|
+
// Custom html. Default: <div class="spark-elastic__icon"></div>.
|
|
107
|
+
icon?: React.ReactElement;
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Ribbons
|
|
112
|
+
|
|
113
|
+
Two ribbons sliding non-stop.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
interface Ribbons {
|
|
117
|
+
// The children rendered inside each ribbon
|
|
118
|
+
children: ReactNode | ReactNode[];
|
|
119
|
+
// The direction the ribbon at the top slides. Default: right.
|
|
120
|
+
topDirection?: RibbonDir;
|
|
121
|
+
// The direction the ribbon at the bottom slides. Default: left.
|
|
122
|
+
bottomDirection?: RibbonDir;
|
|
123
|
+
// Ribbon speed calculated as pixels/second. Default: 50.
|
|
124
|
+
speed?: number;
|
|
125
|
+
// Whether to pause the ribbon when hovered
|
|
126
|
+
pauseOnHover?: boolean;
|
|
127
|
+
// Container class for customization purposes
|
|
128
|
+
containerClass?: string;
|
|
129
|
+
// Each ribbon class for customization purposes
|
|
130
|
+
ribbonClass?: string;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Text Reader
|
|
135
|
+
|
|
136
|
+
Display text gradually as user scroll.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
interface TextReader {
|
|
140
|
+
// The text you want to display gradually.
|
|
141
|
+
text: string;
|
|
142
|
+
// The color of the text
|
|
143
|
+
textColor?: string;
|
|
144
|
+
// The color of the text before being read
|
|
145
|
+
textColorIdle?: string;
|
|
146
|
+
// Pin section. Default: true.
|
|
147
|
+
pin?: boolean;
|
|
148
|
+
// The element that will be pinned.
|
|
149
|
+
pinRef: RefObject<HTMLDivElement>;
|
|
150
|
+
// String | Number | Function - Determines the starting position of the ScrollTrigger. Default: "top 30%".
|
|
151
|
+
start?: string | number | StartEndFunc;
|
|
152
|
+
// String | Number | Function - Determines the ending position of the ScrollTrigger. Default: "bottom top".
|
|
153
|
+
end?: string | number | StartEndFunc;
|
|
154
|
+
// If true it will animate on both desktop and mobile otherwise it will animate only on desktop. Default: true.
|
|
155
|
+
responsive?: boolean;
|
|
156
|
+
// Change the animation style. If true the component will not be pinned. Default: true.
|
|
157
|
+
withMask?: boolean;
|
|
158
|
+
// A callback for when the progress has completed.
|
|
159
|
+
onComplete?: Dispatch<SetStateAction<boolean>>;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Text Reveal
|
|
164
|
+
|
|
165
|
+
Display text with a fancy animation when it's inside the current viewport.
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
interface TextReveal {
|
|
169
|
+
// Headings, paragraph tags or just text
|
|
170
|
+
children: ReactNode;
|
|
171
|
+
// The duration of the animation in seconds. Default: 3.
|
|
172
|
+
duration?: number | string;
|
|
173
|
+
// String | Number | Function - Determines the starting position of the ScrollTrigger. Default: "top 90%".
|
|
174
|
+
start?: string | number | StartEndFunc;
|
|
175
|
+
// Boolean | Number - Links the progress of the animation directly to the scrollbar so it acts like a scrubber. Default: false.
|
|
176
|
+
scrub?: boolean | number;
|
|
177
|
+
// String - Determines how the linked animation is controlled at the 4 distinct toggle places - onEnter, onLeave, onEnterBack, onLeaveBack, in that order. Default: "play none none none".
|
|
178
|
+
toggleActions?: string;
|
|
179
|
+
// Amount of delay in seconds before the animation should begin. Default: 0;
|
|
180
|
+
delay?: number;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### HPin
|
|
185
|
+
|
|
186
|
+
Pin a section and move content horizontally.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
interface HPin {
|
|
190
|
+
// Each child element will be put in row.
|
|
191
|
+
children: React.ReactNode;
|
|
192
|
+
// To choose which element will be pinned. Default: the component itself.
|
|
193
|
+
triggerRef?: RefObject<HTMLDivElement>;
|
|
194
|
+
// String | Number | Function - Determines the starting position of the ScrollTrigger.
|
|
195
|
+
start?: string | number | StartEndFunc;
|
|
196
|
+
// String | Number | Function - Determines the ending position of the ScrollTrigger. Default: "bottom top".
|
|
197
|
+
end?: string | number | StartEndFunc;
|
|
198
|
+
// Pin section. Default: true.
|
|
199
|
+
pin?: boolean;
|
|
200
|
+
// Boolean | Number - Links the progress of the animation directly to the scrollbar so it acts like a scrubber.
|
|
201
|
+
scrub?: boolean | number;
|
|
202
|
+
// Spacing between each child element.
|
|
203
|
+
spacing?: string;
|
|
204
|
+
// The space at each side of the component. Will be used to calculate padding and margin on mobile.
|
|
205
|
+
sideSpacing?: string;
|
|
206
|
+
// Starting position of the first element.
|
|
207
|
+
startPos?: string | number;
|
|
208
|
+
// The space left between the last element and the end of the viewport horizontally.
|
|
209
|
+
endPos?: number;
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### VPin
|
|
214
|
+
|
|
215
|
+
Pin a section and move content vertically.
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
interface VPin {
|
|
219
|
+
// this will be the content at the left such as a title with a text.
|
|
220
|
+
children: React.ReactNode;
|
|
221
|
+
// Each item will be put vertically in a column.
|
|
222
|
+
items: React.ReactElement;
|
|
223
|
+
// The space between each item. Default: "1rem".
|
|
224
|
+
itemsSpacing?: string;
|
|
225
|
+
// The minimum space between the children elements and the items. Default: "2rem".
|
|
226
|
+
contentGap?: string;
|
|
227
|
+
// The space between the pinned content and the top of the viewport. Default: 6.25rem;
|
|
228
|
+
topGap?: string;
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### VOverlap
|
|
233
|
+
|
|
234
|
+
Overlap images while scrolling through blocks of content
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
interface VOverlap {
|
|
238
|
+
// Array of images to be displayed on the side. Each position must have a object with at least an "url" property.
|
|
239
|
+
images: Img[];
|
|
240
|
+
// An array with each element to be displayed on the right.
|
|
241
|
+
content: React.ReactElement[];
|
|
242
|
+
// You can change images wrapper styles using the class "spark-voverlap-img-wrapper" or another one by changing this option.
|
|
243
|
+
imagesWrapperClass?: string;
|
|
244
|
+
// In order to hide content images on mobile and show them on desktop you can do it by adding the "voverlap-content-img" class to each image or whatever you want changing this option
|
|
245
|
+
contentImgClass?: string;
|
|
246
|
+
// String | Number | Function - Determines the starting position of the ScrollTrigger. Default: "top 70%".
|
|
247
|
+
start?: string | number | StartEndFunc;
|
|
248
|
+
// Space between each item: the first position is for desktop the other one for mobile.
|
|
249
|
+
gap?: [number, number];
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Hooks
|
|
254
|
+
|
|
255
|
+
This library also expose some useful hooks:
|
|
256
|
+
|
|
257
|
+
### useIsomorphicLayoutEffect
|
|
258
|
+
|
|
259
|
+
A helper hook for scheduling a layout effect with a fallback to a regular effect for environments where layout effects should not be used.
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
useIsomorphicLayoutEffect(() => {}, []);
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### useWindowSize
|
|
266
|
+
|
|
267
|
+
It returns window width and height. The values are updated on window `change` and `resize` events.
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
const { windowWidth, windowHeight } = useWindowSize();
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### useMediQuery
|
|
274
|
+
|
|
275
|
+
A React hook that detects whether a media query is true or false.
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
const isDesktop = useMediaQuery(`(min-width: 992px)`);
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Authors
|
|
282
|
+
|
|
283
|
+
This toolkit is curated and maintained by the ecloud team:
|
|
284
|
+
|
|
285
|
+
- Julian Ciccioli ([juciccio](https://www.linkedin.com/in/juciccio/)) – [ecloud](https://ecloud.agency)
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ecloud-spark",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "The spark that will light your projects",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"rollup": "rollup -c"
|
|
7
|
+
},
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Ecloud"
|
|
10
|
+
},
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/ecloudhub/spark.git"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/ecloudhub/spark.git#readme",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
19
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
20
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
21
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
22
|
+
"@types/lodash": "^4.14.197",
|
|
23
|
+
"@types/react": "^17.0.34",
|
|
24
|
+
"@types/react-dom": "^18.2.12",
|
|
25
|
+
"framer-motion": "^10.16.4",
|
|
26
|
+
"gsap": "^3.12.2",
|
|
27
|
+
"lodash": "^4.17.21",
|
|
28
|
+
"node-sass": "^9.0.0",
|
|
29
|
+
"react-fast-marquee": "^1.6.2",
|
|
30
|
+
"rollup": "^2.60.0",
|
|
31
|
+
"rollup-plugin-dts": "^4.0.1",
|
|
32
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
33
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
34
|
+
"split-type": "^0.3.3",
|
|
35
|
+
"tslib": "^2.6.2",
|
|
36
|
+
"typescript": "^4.4.4"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "^18.2.0"
|
|
40
|
+
},
|
|
41
|
+
"main": "dist/cjs/index.js",
|
|
42
|
+
"module": "dist/esm/index.js",
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"types": "dist/index.d.ts"
|
|
47
|
+
}
|