Skip to content

Commit

Permalink
Add Nested stories to showcase babel-emotion-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Q committed Oct 14, 2018
1 parent 5bfe518 commit 791d545
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 7 deletions.
7 changes: 2 additions & 5 deletions .storybook/.babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"presets": [
"env",
"react",
"flow"
],
"presets": ["env", "react", "flow"],
"plugins": [
"emotion",
"transform-class-properties",
"transform-flow-strip-types",
"transform-object-rest-spread"
Expand Down
136 changes: 134 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@storybook/addons": "^3.4.3",
"@storybook/cli": "^3.4.11",
"@storybook/react": "^3.4.3",
"babel-plugin-emotion": "^9.2.11",
"coveralls": "3.0.0",
"enzyme": "2.9.1",
"np": "2.20.1",
Expand Down
60 changes: 60 additions & 0 deletions stories/Nested.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react'
import {storiesOf} from '@storybook/react'
import styled from '../src'

const stories = storiesOf('Nested', module)

stories.add('Targeting another emotion component', () => {
const Child = styled('div')`
color: red;
`

const Parent = styled('div')`
${Child} {
color: green;
}
`
return (
<div>
<h3>
Note:{' '}
<a href="https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin-emotion">
babel-plugin-emotion
</a>{' '}
is required for this.
</h3>
<Parent>
<Child>green</Child>
</Parent>
<Child>red</Child>
</div>
)
})

stories.add('Object styles', () => {
const Child = styled('div')({
color: 'red',
})

const Parent = styled('div')({
[Child]: {
color: 'green',
},
})

return (
<div>
<h3>
Note:{' '}
<a href="https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin-emotion">
babel-plugin-emotion
</a>{' '}
is required for this.
</h3>
<Parent>
<Child>green</Child>
</Parent>
<Child>red</Child>
</div>
)
})

0 comments on commit 791d545

Please sign in to comment.