You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+89-34Lines changed: 89 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,33 +2,49 @@
2
2
3
3
An animation component library & higher-order component for generating easily configurable `<Transition>` components from `react-transition-group`.
4
4
5
-
`react-transition-components` is roughly 3 kB gzipped, has peer dependencies on `react` and `react-transition-group`, and supports `webpack` tree-shaking by default: https://bundlephobia.com/result?p=react-transition-components
5
+
`react-transition-components` is 3 kB gzipped, has peer dependencies on `react` and `react-transition-group`, and supports `webpack` tree-shaking by default: https://bundlephobia.com/result?p=react-transition-components
6
6
7
-
`npm i react-transition-components`
7
+
```
8
+
yarn install react-transition-components
9
+
```
8
10
9
-
# Motivation
10
-
The drive behind `react-transition-components` comes from being able to create common transition components for React easily using the tried and true `react-transition-group`.
11
+
## Motivation
11
12
12
-
Not only that, but these components need to be easily configurable with a simple API, and minimal context switching.
13
+
`react-transition-components` has 2 goals:
14
+
- Provide a component library of common lightweight UI transitions that are configurable on durations, delays, easings, and other animation values.
15
+
- Make it easy to create configurable transition components by providing a `createTransition` higher-order component.
13
16
14
-
`react-transition-components` aims to provide a component library of common UI transitions, and to make it easier to create re-usable transition components by providing a `createTransition` higher-order component for wrapping `<Transition>` and providing a very simple API for allowing you to express a transition in **6** lines of code in the simplest case:
17
+
The aforementioned `createTransition` higher-order component wraps `<Transition>` from `react-transition-group`, maintains backwards compatibility with its props, and enhances it with configurable timings, delays, and easings. It provides a concise API, allowing you to express an enter/exit CSS transition in **6** lines of code in the simplest case:
`react-transition-components` comes out of the box with multiple components that work out of the box. A Storybook is live at: https://setsun.io/react-transition-components
28
+
## Component Library
29
+
`react-transition-components` comes with multiple components that work out of the box. A Storybook is live at: https://setsun.io/react-transition-components
30
+
31
+
The following components are included, and implement the most common CSS transitions:
32
+
- FadeTransition for `opacity` animations
33
+
- HeightTransition for `height` animations
34
+
- TranslateTransition for `translate3d` animations
35
+
- ScaleTransition for `scale3d` animations
36
+
- RotateTransition for `rotate3d` animations
37
+
- SkewTransition for `skew` animations
38
+
- ClipTransition for `clip-path` animations
39
+
40
+
## Higher-order component API
41
+
### `createTransition(config: TransitionConfig)`
27
42
28
-
Additionally, all components created via `createTransition`will support all props from the `<Transition>` component from `react-transition-group` (https://reactcommunity.org/react-transition-group/transition).
43
+
The `createTransition`higher-order component returns a pre-configured `<Transition>` component that allows you to create transition components that can be used immediately, and can be configured via `props` as your animation needs change.
29
44
30
-
The components also have extended functionality and have the following base props for customizing transition properties and timings:
45
+
All components created via `createTransition` support all props from the `<Transition>` component from `react-transition-group` (https://reactcommunity.org/react-transition-group/transition).
31
46
47
+
These generated components also have extended functionality and have the following base props for customizing transition properties and timings:
32
48
```ts
33
49
typeProps= {
34
50
// a custom duration for your transition, with the ability
@@ -54,11 +70,7 @@ type Props = {
54
70
}
55
71
```
56
72
57
-
# API
58
-
### `createTransition(config:TransitionConfig)`
59
-
60
-
The `createTransition` higher-order component returns a pre-configured `<Transition>` component that allows you to create transition components that can be used immediately, and can be configured via `props` as your animation needs change. `createTransition` has the following type signature:
61
-
73
+
`createTransition` has the following type signature:
Full TypeScript typings can be found at: https://github.com/Setsun/react-transition-components/blob/master/src/types/index.ts
74
-
75
85
#### `from:React.CSSProperties|LazyCSSProperties`
76
-
The `from` property is the starting style of your transition component. This is the state where your component animation will start. If the `exit` property is not specified, this is also the style that your component will transition to when it is exiting.
86
+
The `from` property is the starting style of your transition component. This is the first state that your component animation will animate from. If the `exit` property is not specified, the `from` property is also used for the exit animation.
The `enter` property is the entering style of your transition component. This is the state where your component animation will animate to, and it's final resting state.
89
+
The `enter` property is the entering style of your transition component. This is the state where your component animation will animate to, and its final resting state.
The `exit` property is the exiting style of your transition component. This is an optional property, and can be useful for specifying a state to animate to, that isn't necessarily the same as your `from` state.
92
+
The `exit` property is the exiting style of your transition component. This is an optional propertyfor explicitly specifying a state to animate to when exiting, especially if you want an `exit` animation that is asymmetric from your `enter` animation.
0 commit comments