-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add roll animation documentation to style guide
- Loading branch information
Richard Palmer
committed
Oct 6, 2017
1 parent
01cd02c
commit c80b3b5
Showing
4 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { Component } from 'react'; | ||
import dedent from 'dedent'; | ||
|
||
import Specimen from '../../../components/Specimen/Specimen'; | ||
import { D, H, T, C } from '../../../components/Scaffold/Scaffold'; | ||
|
||
import Btn from '../../../../components/Btn/Btn'; | ||
import Roll from '../../../../components/Animate/Roll'; | ||
|
||
import m from '../../../../globals/modifiers.css'; | ||
|
||
export default class Animation extends Component { | ||
state = { | ||
roll: false, | ||
}; | ||
|
||
toggleRoll = () => { | ||
this.setState(({ roll }) => ({ | ||
roll: !roll, | ||
})); | ||
}; | ||
|
||
render() { | ||
const { roll } = this.state; | ||
|
||
return ( | ||
<div> | ||
<H level={ 1 }>Animation</H> | ||
<D> | ||
<H level={ 2 }>Roll</H> | ||
<T elm="p" className={ m.mtr }> | ||
<C>Roll</C> allows us to transition between two elements, pushing one | ||
out, while pushing another in. This can be useful for highlighting a | ||
change of state, where the resulting interface change is not obvious. | ||
</T> | ||
<Specimen | ||
classNames={ { | ||
root: m.mtr, | ||
specimenContainer: m.par, | ||
} } | ||
code={ dedent` | ||
<Btn onClick={ this.toggleRoll }> | ||
<Roll width="10rem"> | ||
{ this.state.showMap | ||
? <span id="list">Show list</span> | ||
: <span id="map">Show map</span> | ||
} | ||
</Roll> | ||
</Btn> | ||
` } | ||
> | ||
<Btn onClick={ this.toggleRoll }> | ||
<Roll width="10rem"> | ||
{ roll | ||
? <span id="list">Show list</span> | ||
: <span id="map">Show map</span> | ||
} | ||
</Roll> | ||
</Btn> | ||
</Specimen> | ||
</D> | ||
</div> | ||
); | ||
} | ||
} |
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 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
|
||
import Animation from './Animation'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
render(<Animation />, div); | ||
}); |
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