Skip to content

Commit

Permalink
Add roll animation documentation to style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Palmer committed Oct 6, 2017
1 parent 01cd02c commit c80b3b5
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
11 changes: 11 additions & 0 deletions styleguide/components/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ const Navigation = ({ className, onLinkClick }) => (
Accessibility
</NavLink>
</li>
<li className={ css.linkListItem }>
<NavLink
exact
activeClassName={ css.linkActive }
className={ css.link }
to="/patterns/animation"
onClick={ onLinkClick }
>
Animation
</NavLink>
</li>
<li className={ css.linkListItem }>
<NavLink
exact
Expand Down
65 changes: 65 additions & 0 deletions styleguide/screens/Patterns/Animation/Animation.js
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>
);
}
}
9 changes: 9 additions & 0 deletions styleguide/screens/Patterns/Animation/Animation.test.js
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);
});
2 changes: 2 additions & 0 deletions styleguide/screens/Patterns/Patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Switch, Route } from 'react-router-dom';

import Accessibility from './Accessibility/Accessibility';
import Animation from './Animation/Animation';
import Badge from './Badge/Badge';
import Buttons from './Buttons/Buttons';
import Cards from './Cards/Cards';
Expand All @@ -20,6 +21,7 @@ import TabBar from './TabBar/TabBar';
const Patterns = () => (
<Switch>
<Route path="/patterns/accessibility" component={ Accessibility } />
<Route path="/patterns/animation" component={ Animation } />
<Route path="/patterns/badge" component={ Badge } />
<Route path="/patterns/buttons" component={ Buttons } />
<Route path="/patterns/cards" component={ Cards } />
Expand Down

0 comments on commit c80b3b5

Please sign in to comment.