Skip to content

Commit

Permalink
Docs: One more example
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Aug 31, 2018
1 parent fc84e00 commit 3faf707
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Stack.md
Expand Up @@ -105,21 +105,25 @@ You can also use it as a generic CSS Grid component:

_Available props are `alignContent`, `alignItems`, `justifyContent`, `gridGap`, `gridRowGap`, `gridColumnGap`, `gridColumn`, `gridRow`, `gridAutoFlow`, `gridAutoRows`, `gridAutoColumns`, `gridTemplateRows` and `gridTemplateColumns`. See more in [styled-system docs](https://jxnblk.com/styled-system/table)._

One more example:
Responsive buttons (full width on small screens, horizontally stacked on larger screens):

```jsx
const styled = require('styled-components').default;
const Button = styled.button({
padding: '8px 16px',
border: 0,
borderRadius: '2px',
background: 'salmon',
color: 'white',
fontSize: '1rem'
});
const Button = require('../styleguide/Button').default;
<Stack justifyContent={['', 'start']} gridAutoFlow={['', 'column']}>
<Button>Drink coffee</Button>
<Button>Buy pizza</Button>
<Button>Großes Frühstück essen</Button>
</Stack>;
```

More responsive buttons (vertically stacked on small screens, 2×2 grid on larger screens):

```jsx
const Button = require('../styleguide/Button').default;
<Stack minWidth={320}>
<Button>Buy at LeanPub</Button>
<Button>Buy at Amazon</Button>
<Button>Buy for Kindle</Button>
<Button>Read for free</Button>
</Stack>;
```
1 change: 1 addition & 0 deletions styleguide.config.js
@@ -1,6 +1,7 @@
const path = require('path');

module.exports = {
title: 'Stack Styled: stacking layouts for React',
sections: [
{
content: path.join(__dirname, 'styleguide/Intro.md'),
Expand Down
19 changes: 19 additions & 0 deletions styleguide/Button.js
@@ -0,0 +1,19 @@
import styled from 'styled-components';

const Button = styled.button`
padding: 8px 16px;
border: 0;
border-radius: 2px;
background: salmon;
color: white;
font-size: 1rem;
cursor: pointer;
&:hover,
&:active,
&:focus {
background: tomato;
}
`;

export default Button;

0 comments on commit 3faf707

Please sign in to comment.