-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
310 additions
and
227 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
62 changes: 45 additions & 17 deletions
62
packages/demo/src/components/Transition/demo/CSSTransition.tsx
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,26 +1,54 @@ | ||
import { CSSTransiton as MyCSSTransition } from 'pivot-design'; | ||
import { Button, CSSTransiton } from 'pivot-design'; | ||
import React, { useState } from 'react'; | ||
|
||
import './index.scss'; | ||
|
||
// const App: React.FC = () => {}; | ||
|
||
const App: React.FC = () => { | ||
const [inProp, setInProp] = useState(false); | ||
const [showButton, setShowButton] = useState(true); | ||
const [showMessage, setShowMessage] = useState(false); | ||
return ( | ||
<> | ||
<MyCSSTransition in={inProp} timeout={2000} classNames="my-node"> | ||
<div id="test">{"I'll receive my-node-* classes"}</div> | ||
</MyCSSTransition> | ||
<button type="button" onClick={() => setInProp(!inProp)}> | ||
Click to Enter | ||
</button> | ||
{showButton && ( | ||
<Button onClick={() => setShowMessage(true)} size="middle"> | ||
点击展示 | ||
</Button> | ||
)} | ||
<CSSTransiton | ||
in={showMessage} | ||
timeout={500} | ||
classNames="css-show-box" | ||
unmountOnExit | ||
onEnter={() => setShowButton(false)} | ||
onExited={() => setShowButton(true)} | ||
> | ||
<div> | ||
<text>出现的标题</text> | ||
<p>文本内容在消失时会自动卸载,出现时挂载</p> | ||
<Button onClick={() => setShowMessage(false)}>点击隐藏</Button> | ||
</div> | ||
</CSSTransiton> | ||
</> | ||
); | ||
}; | ||
// 第一次点击按钮时 ,通过审查元素可以看到 div#test 标签的类名发生了变化, | ||
// 依次为 “my-node-enter”、“my-node-enter my-node-enter-active” >>>(2s later) “my-node-enter-done” | ||
|
||
// 第二次点击按钮时,通过审查元素可以看到 div#test 标签的类名发生了变化, | ||
// 依次为 “my-node-exit”、“my-node-exit my-node-exit-active” >>> (2s later) “my-node-exit-done” | ||
export default App; | ||
|
||
/** css样式 | ||
.show-box { | ||
opacity: 0; | ||
&-enter { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
} | ||
&-enter-active { | ||
opacity: 1; | ||
transform: translateX(0); | ||
transition: opacity 500ms, transform 500ms; | ||
} | ||
&-exit { | ||
opacity: 1; | ||
} | ||
&-exit-active { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
transition: opacity 500ms, transform 500ms; | ||
} | ||
} | ||
*/ |
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,13 +1,26 @@ | ||
@import '../../common.scss'; | ||
|
||
button { | ||
margin: 20px; | ||
padding: 3px 15px; | ||
background-color: #fff; | ||
border: 1px solid black; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
.show-box { | ||
height: 20px; | ||
} | ||
|
||
.css-show-box { | ||
opacity: 0; | ||
&-enter { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
} | ||
&-enter-active { | ||
opacity: 1; | ||
transform: translateX(0); | ||
transition: opacity 500ms, transform 500ms; | ||
} | ||
&-exit { | ||
opacity: 1; | ||
} | ||
&-exit-active { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
transition: opacity 500ms, transform 500ms; | ||
} | ||
} |
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
Oops, something went wrong.