-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Transition): make
duration
prop more advanced (#1967)
* feat(Transition): make `duration` prop more advanced * feat(Transition): support string duration propType
- Loading branch information
1 parent
e350886
commit 6b66da1
Showing
16 changed files
with
180 additions
and
26 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
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
48 changes: 48 additions & 0 deletions
48
docs/app/Examples/modules/Transition/Usage/TransitionExampleDuration.js
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,48 @@ | ||
import React, { Component } from 'react' | ||
import { Form, Grid, Image, Transition } from 'semantic-ui-react' | ||
|
||
export default class TransitionExampleDuration extends Component { | ||
state = { hide: 500, show: 500, visible: true } | ||
|
||
handleChange = (e, { name, value }) => this.setState({ [name]: value }) | ||
|
||
toggleVisibility = () => this.setState({ visible: !this.state.visible }) | ||
|
||
render() { | ||
const { hide, show, visible } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column as={Form}> | ||
<Form.Input | ||
label={`Hide duration: ${hide}ms `} | ||
min={100} | ||
max={5000} | ||
name='hide' | ||
onChange={this.handleChange} | ||
step={100} | ||
type='range' | ||
value={hide} | ||
/> | ||
<Form.Input | ||
label={`Show duration: ${show}ms `} | ||
min={100} | ||
max={5000} | ||
name='show' | ||
onChange={this.handleChange} | ||
step={100} | ||
type='range' | ||
value={show} | ||
/> | ||
<Form.Button content='Run' onClick={this.toggleVisibility} /> | ||
</Grid.Column> | ||
|
||
<Grid.Column> | ||
<Transition duration={{ hide, show }} visible={visible}> | ||
<Image centered size='small' src='/assets/images/leaves/3.png' /> | ||
</Transition> | ||
</Grid.Column> | ||
</Grid> | ||
) | ||
} | ||
} |
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,21 @@ | ||
import React from 'react' | ||
|
||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const TransitionUsageExamples = () => ( | ||
<ExampleSection title='Usage'> | ||
<ComponentExample | ||
title='Duration' | ||
description={( | ||
<span> | ||
Duration of the CSS transition animation can be defined separately for <code>hide</code> and <code>show</code> | ||
animations. | ||
</span> | ||
)} | ||
examplePath='modules/Transition/Usage/TransitionExampleDuration' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default TransitionUsageExamples |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Normalizes the duration of a transition. | ||
* @param {number|object} duration The value to normalize. | ||
* @param {'hide'|'show'} type The type of transition. | ||
* @returns {number} | ||
*/ | ||
export default (duration, type) => ( | ||
(typeof duration === 'number' || typeof duration === 'string') ? duration : duration[type] | ||
) |
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 +1 @@ | ||
export { default, TransitionProps, TRANSITION_STATUSES } from './Transition'; | ||
export { default, TransitionProps, TransitionPropDuration, TRANSITION_STATUSES } from './Transition'; |
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