react-awesome-reveal 4.3.1 → 5.0.0-next.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.
Files changed (122) hide show
  1. package/README.md +16 -207
  2. package/dist/index.d.ts +1 -3
  3. package/dist/index.js +1 -1831
  4. package/dist/keyframes.d.ts +1 -0
  5. package/dist/keyframes.js +1 -0
  6. package/package.json +51 -58
  7. package/skills/migrating-from-v4/SKILL.md +95 -0
  8. package/dist/Reveal.d.ts +0 -69
  9. package/dist/animations/attention_seekers/bounce.d.ts +0 -5
  10. package/dist/animations/attention_seekers/flash.d.ts +0 -5
  11. package/dist/animations/attention_seekers/headShake.d.ts +0 -5
  12. package/dist/animations/attention_seekers/heartBeat.d.ts +0 -5
  13. package/dist/animations/attention_seekers/index.d.ts +0 -13
  14. package/dist/animations/attention_seekers/jello.d.ts +0 -5
  15. package/dist/animations/attention_seekers/pulse.d.ts +0 -5
  16. package/dist/animations/attention_seekers/rubberBand.d.ts +0 -5
  17. package/dist/animations/attention_seekers/shake.d.ts +0 -5
  18. package/dist/animations/attention_seekers/shakeX.d.ts +0 -5
  19. package/dist/animations/attention_seekers/shakeY.d.ts +0 -5
  20. package/dist/animations/attention_seekers/swing.d.ts +0 -5
  21. package/dist/animations/attention_seekers/tada.d.ts +0 -5
  22. package/dist/animations/attention_seekers/wobble.d.ts +0 -5
  23. package/dist/animations/bouncing_entrances/bounceIn.d.ts +0 -5
  24. package/dist/animations/bouncing_entrances/bounceInDown.d.ts +0 -5
  25. package/dist/animations/bouncing_entrances/bounceInLeft.d.ts +0 -5
  26. package/dist/animations/bouncing_entrances/bounceInRight.d.ts +0 -5
  27. package/dist/animations/bouncing_entrances/bounceInUp.d.ts +0 -5
  28. package/dist/animations/bouncing_entrances/index.d.ts +0 -5
  29. package/dist/animations/bouncing_exits/bounceOut.d.ts +0 -5
  30. package/dist/animations/bouncing_exits/bounceOutDown.d.ts +0 -5
  31. package/dist/animations/bouncing_exits/bounceOutLeft.d.ts +0 -5
  32. package/dist/animations/bouncing_exits/bounceOutRight.d.ts +0 -5
  33. package/dist/animations/bouncing_exits/bounceOutUp.d.ts +0 -5
  34. package/dist/animations/bouncing_exits/index.d.ts +0 -5
  35. package/dist/animations/fading_entrances/fadeIn.d.ts +0 -5
  36. package/dist/animations/fading_entrances/fadeInBottomLeft.d.ts +0 -5
  37. package/dist/animations/fading_entrances/fadeInBottomRight.d.ts +0 -5
  38. package/dist/animations/fading_entrances/fadeInDown.d.ts +0 -5
  39. package/dist/animations/fading_entrances/fadeInDownBig.d.ts +0 -5
  40. package/dist/animations/fading_entrances/fadeInLeft.d.ts +0 -5
  41. package/dist/animations/fading_entrances/fadeInLeftBig.d.ts +0 -5
  42. package/dist/animations/fading_entrances/fadeInRight.d.ts +0 -5
  43. package/dist/animations/fading_entrances/fadeInRightBig.d.ts +0 -5
  44. package/dist/animations/fading_entrances/fadeInTopLeft.d.ts +0 -5
  45. package/dist/animations/fading_entrances/fadeInTopRight.d.ts +0 -5
  46. package/dist/animations/fading_entrances/fadeInUp.d.ts +0 -5
  47. package/dist/animations/fading_entrances/fadeInUpBig.d.ts +0 -5
  48. package/dist/animations/fading_entrances/index.d.ts +0 -13
  49. package/dist/animations/fading_exits/fadeOut.d.ts +0 -5
  50. package/dist/animations/fading_exits/fadeOutBottomLeft.d.ts +0 -5
  51. package/dist/animations/fading_exits/fadeOutBottomRight.d.ts +0 -5
  52. package/dist/animations/fading_exits/fadeOutDown.d.ts +0 -5
  53. package/dist/animations/fading_exits/fadeOutDownBig.d.ts +0 -5
  54. package/dist/animations/fading_exits/fadeOutLeft.d.ts +0 -5
  55. package/dist/animations/fading_exits/fadeOutLeftBig.d.ts +0 -5
  56. package/dist/animations/fading_exits/fadeOutRight.d.ts +0 -5
  57. package/dist/animations/fading_exits/fadeOutRightBig.d.ts +0 -5
  58. package/dist/animations/fading_exits/fadeOutTopLeft.d.ts +0 -5
  59. package/dist/animations/fading_exits/fadeOutTopRight.d.ts +0 -5
  60. package/dist/animations/fading_exits/fadeOutUp.d.ts +0 -5
  61. package/dist/animations/fading_exits/fadeOutUpBig.d.ts +0 -5
  62. package/dist/animations/fading_exits/index.d.ts +0 -13
  63. package/dist/animations/flippers/flip.d.ts +0 -5
  64. package/dist/animations/flippers/flipInX.d.ts +0 -5
  65. package/dist/animations/flippers/flipInY.d.ts +0 -5
  66. package/dist/animations/flippers/flipOutX.d.ts +0 -5
  67. package/dist/animations/flippers/flipOutY.d.ts +0 -5
  68. package/dist/animations/flippers/index.d.ts +0 -5
  69. package/dist/animations/rotating_entrances/index.d.ts +0 -5
  70. package/dist/animations/rotating_entrances/rotateIn.d.ts +0 -5
  71. package/dist/animations/rotating_entrances/rotateInDownLeft.d.ts +0 -5
  72. package/dist/animations/rotating_entrances/rotateInDownRight.d.ts +0 -5
  73. package/dist/animations/rotating_entrances/rotateInUpLeft.d.ts +0 -5
  74. package/dist/animations/rotating_entrances/rotateInUpRight.d.ts +0 -5
  75. package/dist/animations/rotating_exits/index.d.ts +0 -5
  76. package/dist/animations/rotating_exits/rotateOut.d.ts +0 -5
  77. package/dist/animations/rotating_exits/rotateOutDownLeft.d.ts +0 -5
  78. package/dist/animations/rotating_exits/rotateOutDownRight.d.ts +0 -5
  79. package/dist/animations/rotating_exits/rotateOutUpLeft.d.ts +0 -5
  80. package/dist/animations/rotating_exits/rotateOutUpRight.d.ts +0 -5
  81. package/dist/animations/sliding_entrances/index.d.ts +0 -4
  82. package/dist/animations/sliding_entrances/slideInDown.d.ts +0 -5
  83. package/dist/animations/sliding_entrances/slideInLeft.d.ts +0 -5
  84. package/dist/animations/sliding_entrances/slideInRight.d.ts +0 -5
  85. package/dist/animations/sliding_entrances/slideInUp.d.ts +0 -5
  86. package/dist/animations/sliding_exits/index.d.ts +0 -4
  87. package/dist/animations/sliding_exits/slideOutDown.d.ts +0 -5
  88. package/dist/animations/sliding_exits/slideOutLeft.d.ts +0 -5
  89. package/dist/animations/sliding_exits/slideOutRight.d.ts +0 -5
  90. package/dist/animations/sliding_exits/slideOutUp.d.ts +0 -5
  91. package/dist/animations/specials/hinge.d.ts +0 -5
  92. package/dist/animations/specials/index.d.ts +0 -4
  93. package/dist/animations/specials/jackInTheBox.d.ts +0 -5
  94. package/dist/animations/specials/rollIn.d.ts +0 -5
  95. package/dist/animations/specials/rollOut.d.ts +0 -5
  96. package/dist/animations/zooming_entrances/index.d.ts +0 -5
  97. package/dist/animations/zooming_entrances/zoomIn.d.ts +0 -5
  98. package/dist/animations/zooming_entrances/zoomInDown.d.ts +0 -5
  99. package/dist/animations/zooming_entrances/zoomInLeft.d.ts +0 -5
  100. package/dist/animations/zooming_entrances/zoomInRight.d.ts +0 -5
  101. package/dist/animations/zooming_entrances/zoomInUp.d.ts +0 -5
  102. package/dist/animations/zooming_exits/index.d.ts +0 -5
  103. package/dist/animations/zooming_exits/zoomOut.d.ts +0 -5
  104. package/dist/animations/zooming_exits/zoomOutDown.d.ts +0 -5
  105. package/dist/animations/zooming_exits/zoomOutLeft.d.ts +0 -5
  106. package/dist/animations/zooming_exits/zoomOutRight.d.ts +0 -5
  107. package/dist/animations/zooming_exits/zoomOutUp.d.ts +0 -5
  108. package/dist/components/AttentionSeeker.d.ts +0 -12
  109. package/dist/components/Bounce.d.ts +0 -17
  110. package/dist/components/Fade.d.ts +0 -22
  111. package/dist/components/Flip.d.ts +0 -17
  112. package/dist/components/Hinge.d.ts +0 -4
  113. package/dist/components/JackInTheBox.d.ts +0 -4
  114. package/dist/components/Roll.d.ts +0 -10
  115. package/dist/components/Rotate.d.ts +0 -17
  116. package/dist/components/Slide.d.ts +0 -17
  117. package/dist/components/Zoom.d.ts +0 -17
  118. package/dist/components/index.d.ts +0 -10
  119. package/dist/index.cjs +0 -1846
  120. package/dist/utils/animations.d.ts +0 -8
  121. package/dist/utils/guards.d.ts +0 -2
  122. package/dist/utils/patterns.d.ts +0 -2
package/README.md CHANGED
@@ -1,221 +1,30 @@
1
- # React Awesome Reveal
1
+ # react-awesome-reveal
2
2
 
3
- [![Version](https://badgen.net/npm/v/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal/v/latest)
4
- [![Last Commit](https://badgen.net/github/last-commit/awesome-reveal/react-awesome-reveal/main)](https://github.com/awesome-reveal/react-awesome-reveal/commit)
5
- [![Downloads](https://badgen.net/npm/dt/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal/v/latest)
6
- [![Size](https://badgen.net/bundlephobia/minzip/react-awesome-reveal)](https://bundlephobia.com/result?p=react-awesome-reveal@latest)
7
- [![License](https://badgen.net/npm/license/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal/v/latest)
8
- [![Rate on Openbase](https://badges.openbase.io/js/rating/react-awesome-reveal.svg)](https://openbase.io/js/react-awesome-reveal?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
3
+ [![Version](https://badgen.net/npm/v/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal)
4
+ [![Downloads](https://badgen.net/npm/dt/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal)
5
+ [![License](https://badgen.net/npm/license/react-awesome-reveal)](https://www.npmjs.com/package/react-awesome-reveal)
9
6
 
10
- > [!TIP]
11
- > If you like this library, please [consider supporting its creator](https://github.com/sponsors/morellodev).
7
+ React Awesome Reveal is now [`@awesome-reveal/react`](https://www.npmjs.com/package/@awesome-reveal/react). Version 5 of this package re-exports it, with the same entry points:
12
8
 
13
- [React Awesome Reveal](https://react-awesome-reveal.morello.dev) is a library for React apps written in TypeScript that adds reveal animations using the Intersection Observer API to detect when the elements appear in the viewport. Animations are internally provided by [Emotion](https://emotion.sh) and implemented as CSS Animations to benefit from hardware acceleration.
9
+ | Import path | Same as |
10
+ | -------------------------------- | --------------------------------- |
11
+ | `react-awesome-reveal` | `@awesome-reveal/react` |
12
+ | `react-awesome-reveal/keyframes` | `@awesome-reveal/react/keyframes` |
14
13
 
15
- ## Table Of Contents
16
-
17
- - [Features](#features)
18
- - [Installation](#installation)
19
- - [Quick Start](#quick-start)
20
- - [Supported Effects](#supported-effects)
21
- - [Attention Seekers](#attention-seekers)
22
- - [Props](#props)
23
- - [Example](#example)
24
- - [Chaining Multiple Animations](#chaining-multiple-animations)
25
- - [Custom Animations](#custom-animations)
26
- - [Other Props](#other-props)
27
- - [Intersection Observer](#intersection-observer)
28
- - [Polyfill](#polyfill)
29
- - [Past Releases](#past-releases)
30
- - [License](#license)
31
-
32
- ## Features
33
-
34
- - 🎁 **Modern stack** – It is built for modern React and supports React 18
35
- - 🏷 **TypeScript support** – It is written in TypeScript to improve the DX
36
- - 🍃 **Lightweight** – Very little footprint on your project
37
- - ⚙️ **Uses native APIs** – Intersection Observer and CSS Animations are now supported by all browsers
38
- - 🚀 **Fast** – Buttery smooth experience thanks to the use of native asynchronous APIs and hardware acceleration
39
- - 💅 **Fully customizable** – Define custom animations and let the library render them
40
- - 💻 **SSR support** – Server Side Rendering works out-of-the-box
41
- - 🌳 **Tree-shakeable** – Only the parts you use will be included in your final bundle
42
-
43
- ## Installation
44
-
45
- To add this package as a dependency to your app, simply run
46
-
47
- ```sh
48
- npm install react-awesome-reveal @emotion/react --save
49
- ```
50
-
51
- or, if you are using Yarn:
52
-
53
- ```sh
54
- yarn add react-awesome-reveal @emotion/react
55
- ```
56
-
57
- or, if you are using PNPM (as I strongly suggest):
58
-
59
- ```sh
60
- pnpm add react-awesome-reveal @emotion/react
61
- ```
62
-
63
- ## Quick Start
64
-
65
- Import effects from [React Awesome Reveal](https://www.npmjs.com/package/react-awesome-reveal) to your React component, for example the `Fade` effect:
66
-
67
- ```js
68
- import { Fade } from "react-awesome-reveal";
69
- ```
70
-
71
- Then simply wrap the components you want to animate:
72
-
73
- ```jsx
74
- <Fade>
75
- <p>I will gently appear as I enter the viewport</p>
76
- </Fade>
77
- ```
78
-
79
- ## Supported Effects
80
-
81
- The effects currently supported are `Bounce`, `Fade`, `Flip`, `Hinge`, `JackInTheBox`, `Roll`, `Rotate`, `Slide` and `Zoom`. Refer to the [Animate.css](https://animate.style) documentation for the details.
82
-
83
- ### Attention Seekers
84
-
85
- Since version 3, attention seeker animations are wrapped by the `AttentionSeeker` component, which accepts a prop called `effect` that specifies the animation to render (defaults to `"bounce”`). The supported effects are: `”bounce"`, `"flash"`, `"headShake”`, `"heartBeat"`, `"jello”`, `"pulse"`, `"rubberBand"`, `“shake”`, `“shakeX"`, `"shakeY”`, `"swing”`, `"tada"` and `“wobble”`.
86
-
87
- Again, refer to the [Animate.css](https://animate.style) documentation for the details.
88
-
89
- ### Props
90
-
91
- You can pass the following props to the animation components to customize the behavior:
92
-
93
- | Prop | Description | Values | Default |
94
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
95
- | `cascade` | If set, each child of a reveal animation automatically get assigned a delay that takes into account their predecessor (child `i` enters the viewport after `i * delay * damping` milliseconds) – useful for animating list items. | `true` or `false` | `false` |
96
- | `damping` | Factor that affects the delay that each animated component in a cascade animation will be assigned. If `damping = 1` then the delay will be equal to the animation duration; if `damping < 1` then the delay will be lower than the animation duration; if `damping > 1` then the delay will be greater than the animation duration. | `number` | `0.5` (meaning that the delay will be half of the animation duration) |
97
- | `direction` | Origin of the animation (where applicable). | Usually `"down"`, `"left"`, `"right"` or `"up"`, with some exceptions documented in the code | `undefined` |
98
- | `delay` | Time to wait before the animation starts (in milliseconds). | `number` | `0` |
99
- | `duration` | The animation duration (milliseconds). | `number` | `1000` |
100
- | `fraction` | How much an element should be in viewport before the animation is triggered. | `number` between `0` and `1` | `0` |
101
- | `triggerOnce` | Specifies if the animation should run only once or everytime an element enters/exits/re-enters the viewport. | `true` or `false` | `false` |
102
- | `className` | The class names to add to the container element. | `string` | `undefined` |
103
- | `style` | The inline styles to add to the container element. | `React.CSSProperties` | `undefined` |
104
- | `childClassName` | The class names to add to the child element. | `string` | `undefined` |
105
- | `childStyle` | The inline styles to add to the child element. | `React.CSSProperties` | `undefined` |
106
- | `onVisibilityChange` | Callback executed when the element enters or leaves the viewport. If more than one element is being animated, this function is called on each element. | `(inView: boolean, entry: IntersectionObserverEntry) => void` | `undefined` |
107
-
108
- ### Example
109
-
110
- To trigger the animation only the first time an element enters the viewport:
111
-
112
- ```jsx
113
- <Slide triggerOnce>
114
- <p>I will animate only the first time you see me</p>
115
- </Slide>
116
- ```
117
-
118
- ### Chaining Multiple Animations
119
-
120
- To chain together multiple animations, set the `cascade` prop to `true`:
121
-
122
- ```jsx
123
- <Fade cascade>
124
- <p>I enter first...</p>
125
- <p>...then comes my turn...</p>
126
- <p>...and finally you see me!</p>
127
- </Fade>
128
- ```
129
-
130
- Play with the `damping` prop to alter the delay by which each child will progressively appear:
131
-
132
- ```tsx
133
- <Fade cascade damping={0.1}>
134
- <p>I enter first...</p>
135
- <p>...then comes my turn...</p>
136
- <p>...and finally you see me!</p>
137
- </Fade>
138
- ```
139
-
140
- ## Custom Animations
141
-
142
- Starting from version 3.2.0, you can define custom animations! Simply import the `Reveal` component (which is the default export of the library – give it the name you want) and pass it a `keyframes` prop:
143
-
144
- ```jsx
145
- import React from "react";
146
- import Reveal from "react-awesome-reveal";
147
- import { keyframes } from "@emotion/react";
148
-
149
- const customAnimation = keyframes`
150
- from {
151
- opacity: 0;
152
- transform: translate3d(-200px, -100px, 0);
153
- }
154
-
155
- to {
156
- opacity: 1;
157
- transform: translate3d(0, 0, 0);
158
- }
159
- `;
160
-
161
- function CustomAnimation({ children }) {
162
- return <Reveal keyframes={customAnimation}>{children}</Reveal>;
163
- }
164
- ```
165
-
166
- If no `keyframes` prop is passed, the default rendered animation is a fading entrance from the left (equivalent to `<Fade direction="left">...</Fade>`).
167
-
168
- ### Other Props
169
-
170
- You can also pass these props to `Reveal`:
171
-
172
- - `cascade`
173
- - `damping`
174
- - `delay`
175
- - `duration`
176
- - `fraction`
177
- - `triggerOnce`
178
- - `className` and `childClassName`
179
- - `style` and `childStyle`
180
- - `onVisibilityChange`
181
-
182
- ## Intersection Observer
183
-
184
- [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is the API used to determine if an element is inside the viewport or not. [Browser support](http://caniuse.com/#feat=intersectionobserver) is really good – with [Safari adding support in 12.1](https://webkit.org/blog/8718/new-webkit-features-in-safari-12-1), all major browsers now support Intersection Observers natively.
185
-
186
- If you need to support old browsers, add the polyfill for the Intersection Observer API.
187
-
188
- ### Polyfill
189
-
190
- You can add the [polyfill](https://www.npmjs.com/package/intersection-observer) directly or use a service like [polyfill.io](https://polyfill.io/v2/docs) to add it when needed.
14
+ Install `@awesome-reveal/react` in new projects:
191
15
 
192
16
  ```sh
193
- yarn add intersection-observer
17
+ pnpm add @awesome-reveal/react
194
18
  ```
195
19
 
196
- Then import it in your app:
20
+ ## Migrating from v4
197
21
 
198
- ```javascript
199
- import "intersection-observer";
200
- ```
201
-
202
- If you are using Webpack (or similar) you could use [dynamic imports](https://webpack.js.org/guides/code-splitting/#dynamic-imports) to load the polyfill only if needed. A basic implementation could look something like this:
203
-
204
- ```javascript
205
- /**
206
- * Do feature detection, to figure out which polyfills needs to be imported.
207
- **/
208
- async function loadPolyfills() {
209
- if (typeof window.IntersectionObserver === "undefined") {
210
- await import("intersection-observer");
211
- }
212
- }
213
- ```
22
+ Version 5 is not compatible with v4. It has no effect components, such as `Fade` or `Slide`, and it does not use Emotion. Read [Migrating from v4](https://github.com/awesome-reveal/awesome-reveal/tree/next/packages/react#migrating-from-v4).
214
23
 
215
- ## Past Releases
24
+ This package includes the `migrating-from-v4` agent skill, which helps a coding agent do the migration.
216
25
 
217
- To see the documentation for previous versions, navigate through past tags in the GitHub's project repository and read the README for that specific version.
26
+ The v4 documentation is in the [README of `react-awesome-reveal@4.3.1`](https://github.com/awesome-reveal/awesome-reveal/blob/react-awesome-reveal%404.3.1/README.md).
218
27
 
219
28
  ## License
220
29
 
221
- Project source code is licensed under the MIT license. You are free to fork this repository, edit the code, share and use it both for non-commercial and commercial purposes.
30
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- export * from './components';
2
- export * from './Reveal';
3
- export { Reveal as default } from './Reveal';
1
+ export * from '@awesome-reveal/react';