Skip to content

Commit b945626

Browse files
committed
fix: redo animations
1 parent 8b8bb2d commit b945626

File tree

8 files changed

+705
-323
lines changed

8 files changed

+705
-323
lines changed

.changeset/moody-carrots-drive.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,32 @@
22
"@ultraviolet/ui": major
33
---
44

5-
**BREAKING CHANGE** Remove all emotion animation, replace with vanilla-extract animation by default. To use the Emotion animation, add `Emotion` to the name of the animation:
5+
**BREAKING CHANGE** Remove all emotion animation, replace with vanilla-extract animation by default.
66
```js
77
import { fadeIn } from '@ultraviolet/ui' // vanilla-extract animation
8-
import { fadeInEmotion } from '@ultraviolet/ui' // Emotion animation
8+
```
9+
10+
To use animation in another context, add `Default` at the end of the animation name:
11+
```js
12+
import { fadeInDefault } from "@ultraviolet/ui"
13+
````
14+
This returns a string that can be used in many different places.
15+
1. **Emotion**: create the keyframe then use it:
16+
```js
17+
import { fadeInDefault } from "@ultraviolet/ui"
18+
import { keyframes } from '@emotion/react'
19+
20+
const fadeInEmotion = keyframes`${fadeInDefault}`
21+
const StyledDiv = styled.div`
22+
animation: ${fadeInEmotion} 1s ease infinite;`
23+
```
24+
25+
2. Vanilla CSS: simply add the name of the animation you want to use as a className.
26+
```js
27+
const MyComponent = () => <div className="fadeIn">Hello World!</div>
28+
```
29+
30+
To customize the animation, you must overrule the default settings:
31+
```js
32+
const MyComponent = () => <div className="fadeIn" style={{ animationDuration: "300ms" }}>Hello World!</div>
933
```
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Meta } from '@storybook/addon-docs/blocks'
2+
import Colors from '../components/Colors'
3+
4+
<Meta title="Guides/Animations" />
5+
6+
# Ultraviolet animations
7+
Ultraviolet provides a set of ready-to-use animations, each available in three formats to suit different styling approaches.
8+
9+
## Vanilla Extract
10+
Use the animation directly in `vanilla-extract` styles:
11+
```js
12+
// styles.css.ts
13+
import { fadeIn } from '@ultraviolet/ui' // vanilla-extract animation
14+
import { style } from '@vanilla-extract/css'
15+
16+
export const myStyle = style({
17+
animation: `${fadeIn} 0.2s ease-in-out`,
18+
})
19+
```
20+
21+
## CSS-in-JS
22+
For CSS-in-JS libraries like Emotion, import the `Default` version of the animation, which returns a keyframe string.
23+
24+
Example with **Emotion**: create the keyframe then use it:
25+
```js
26+
import { fadeInDefault } from "@ultraviolet/ui"
27+
import { keyframes } from '@emotion/react'
28+
29+
const fadeInEmotion = keyframes`${fadeInDefault}`
30+
31+
const StyledDiv = styled.div`
32+
animation: ${fadeInEmotion} 1s ease infinite;
33+
`
34+
```
35+
36+
## Vanilla CSS
37+
Apply the animation by using the class name with the `_uv` suffix:
38+
39+
```js
40+
const MyComponent = () => <div className="fadeIn_uv">Hello World!</div>
41+
```
42+
43+
To customize animation properties like duration or timing, override them inline:
44+
```js
45+
const MyComponent = () => <div className="fadeIn" style={{ animationDuration: "300ms" }}>Hello World!</div>
46+
```
47+
48+
49+
## List
50+
- bounce
51+
- fadeIn
52+
- fadeOut
53+
- flash
54+
- ping
55+
- pulse
56+
- quickScaleDown
57+
- scaleBack
58+
- scaleDown
59+
- scaleForward
60+
- scaleUp
61+
- sketchIn
62+
- sketchOut
63+
- slideDownLarge
64+
- slideFromBottom
65+
- slideFromLeft
66+
- slideFromRight
67+
- slideFromTop
68+
- slideToBottom
69+
- slideToLeft
70+
- slideToRight
71+
- slideToTop
72+
- slideUpLarge
73+
- unfoldIn
74+
- unfoldOut
75+
- zoomIn
76+
- zoomOut

packages/ui/src/index.ts

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './utils/animations/animations.css'
2+
13
// eslint-disable-next-line no-restricted-syntax
24
export * from './components'
35
export type { UltravioletUITheme } from './theme'
@@ -11,61 +13,61 @@ export {
1113
export {
1214
Breakpoint,
1315
bounce,
14-
bounceEmotion,
16+
bounceDefault,
1517
down,
1618
fadeIn,
17-
fadeInEmotion,
19+
fadeInDefault,
1820
fadeOut,
19-
fadeOutEmotion,
21+
fadeOutDefault,
2022
flash,
21-
flashEmotion,
23+
flashDefault,
2224
getUUID,
2325
normalize,
2426
ping,
25-
pingEmotion,
27+
pingDefault,
2628
pulse,
27-
pulseEmotion,
29+
pulseDefault,
2830
quickScaleDown,
29-
quickScaleDownEmotion,
31+
quickScaleDownDefault,
3032
scaleBack,
31-
scaleBackEmotion,
33+
scaleBackDefault,
3234
scaleDown,
33-
scaleDownEmotion,
35+
scaleDownDefault,
3436
scaleForward,
35-
scaleForwardEmotion,
37+
scaleForwardDefault,
3638
scaleUp,
37-
scaleUpEmotion,
39+
scaleUpDefault,
3840
sketchIn,
39-
sketchInEmotion,
41+
sketchInDefault,
4042
sketchOut,
41-
sketchOutEmotion,
43+
sketchOutDefault,
4244
slideDownLarge,
43-
slideDownLargeEmotion,
45+
slideDownLargeDefault,
4446
slideFromBottom,
45-
slideFromBottomEmotion,
47+
slideFromBottomDefault,
4648
slideFromLeft,
47-
slideFromLeftEmotion,
49+
slideFromLeftDefault,
4850
slideFromRight,
49-
slideFromRightEmotion,
51+
slideFromRightDefault,
5052
slideFromTop,
51-
slideFromTopEmotion,
53+
slideFromTopDefault,
5254
slideToBottom,
53-
slideToBottomEmotion,
55+
slideToBottomDefault,
5456
slideToLeft,
55-
slideToLeftEmotion,
57+
slideToLeftDefault,
5658
slideToRight,
57-
slideToRightEmotion,
59+
slideToRightDefault,
5860
slideToTop,
59-
slideToTopEmotion,
61+
slideToTopDefault,
6062
slideUpLarge,
61-
slideUpLargeEmotion,
63+
slideUpLargeDefault,
6264
unfoldIn,
63-
unfoldInEmotion,
65+
unfoldInDefault,
6466
unfoldOut,
65-
unfoldOutEmotion,
67+
unfoldOutDefault,
6668
up,
6769
zoomIn,
68-
zoomInEmotion,
70+
zoomInDefault,
6971
zoomOut,
70-
zoomOutEmotion,
72+
zoomOutDefault,
7173
} from './utils'

0 commit comments

Comments
 (0)