1
1
mirror of https://github.com/primer/css.git synced 2024-12-22 13:41:34 +03:00
css/.storybook/Octicon.js

28 lines
644 B
JavaScript
Raw Normal View History

2017-09-09 03:25:21 +03:00
import React from 'react'
import {storiesOf} from '@storybook/react'
import octicons from 'octicons'
import SVGInline from 'react-svg-inline'
const Octicon = (props) => {
const {name} = props
if (name in octicons) {
return <SVGInline svg={octicons[name].toSVG(props)} />
} else {
throw new Error(`No such octicon: "${name}"!`)
}
}
2017-10-24 21:05:55 +03:00
const story = storiesOf('Octicons', module)
2017-09-09 03:25:21 +03:00
2017-10-24 21:05:55 +03:00
Object.keys(octicons).forEach(name => {
story.add(name, () => {
return (
2017-10-24 21:05:55 +03:00
<div>
<Octicon name={name} height="64" />
<Octicon name={name} height="32" />
<Octicon name={name} height="16" />
</div>
)
})
2017-10-24 21:05:55 +03:00
})