-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2d7bac
commit e9c7d05
Showing
11 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ListTransition | ||
|
||
## Example | ||
|
||
```tsx | ||
<ul> | ||
<ListTransition list={list}> | ||
{(item, { simpleStatus }) => ( | ||
<li | ||
style={{ | ||
transition: '.3s', | ||
opacity: simpleStatus === 'enter' ? 1 : 0, | ||
transform: { | ||
from: 'translateX(-100%) scale(1.2)', | ||
enter: 'translateX(0)', | ||
leave: 'translateX(100%) scale(0)', | ||
}[simpleStatus], | ||
}} | ||
> | ||
{item} | ||
</li> | ||
)} | ||
</ListTransition> | ||
</ul> | ||
``` | ||
|
||
## Type | ||
|
||
```ts | ||
function ListTransition<T>(props: ListTransitionProps<T>): JSX.Element | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SwitchTransition | ||
|
||
## Example | ||
|
||
```tsx | ||
<SwitchTransition state={count} timeout={300} mode="default"> | ||
{(state, { simpleStatus }) => ( | ||
<h1 | ||
style={{ | ||
transition: '.3s', | ||
opacity: simpleStatus === 'enter' ? 1 : 0, | ||
transform: { | ||
from: 'translateX(-100%) scale(1.2)', | ||
enter: 'translateX(0)', | ||
leave: 'translateX(100%) scale(0)', | ||
}[simpleStatus], | ||
}} | ||
> | ||
{state} {simpleStatus} hello | ||
</h1> | ||
)} | ||
</SwitchTransition> | ||
``` | ||
|
||
## Type | ||
|
||
```ts | ||
function SwitchTransition<T>(props: SwitchTransitionProps<T>): JSX.Element | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Transition | ||
|
||
## Example | ||
|
||
```tsx | ||
const [onOff, setOnOff] = useState(true) | ||
|
||
return ( | ||
<div> | ||
<button onClick={() => setOnOff(!onOff)}>toggle</button> | ||
<Transition state={onOff} timeout={300}> | ||
{({ simpleStatus, shouldMount }) => shouldMount && ( | ||
<p style={{ | ||
transition: '.3s', | ||
opacity: simpleStatus === 'enter' ? 1 : 0, | ||
}} | ||
> | ||
I'm fading | ||
</p> | ||
)} | ||
</Transition> | ||
</div> | ||
) | ||
|
||
``` | ||
|
||
## Type | ||
|
||
```ts | ||
function Transition(props: TransitionProps): React.ReactNode | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import type { ListRenderCallback, ListTransitionOptions } from '../hooks/useListTransition' | ||
import { useListTransition } from '../hooks/useListTransition' | ||
|
||
interface SwitchTransitionProps<T> { | ||
interface ListTransitionProps<T> { | ||
list: T[] | ||
transitionOptions?: ListTransitionOptions<T> | ||
children: ListRenderCallback<T> | ||
} | ||
|
||
export function SwitchTransition<T>(props: SwitchTransitionProps<T>) { | ||
export function ListTransition<T>(props: ListTransitionProps<T>) { | ||
const { transitionList } = useListTransition(props.list, props.transitionOptions) | ||
|
||
return transitionList(props.children) | ||
return <>{transitionList(props.children)}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters