2017-09-09 03:25:21 +03:00
|
|
|
import React from 'react'
|
|
|
|
import {storiesOf} from '@storybook/react'
|
|
|
|
import octicons from 'octicons'
|
|
|
|
|
2017-09-12 23:09:56 +03:00
|
|
|
export const Octicon = (props) => {
|
2017-09-09 03:25:21 +03:00
|
|
|
const {name} = props
|
|
|
|
if (name in octicons) {
|
2017-10-27 20:05:04 +03:00
|
|
|
const svg = octicons[name].toSVG(props)
|
|
|
|
return <span dangerouslySetInnerHTML={ {__html: svg } } />
|
2017-09-09 03:25:21 +03:00
|
|
|
} else {
|
|
|
|
throw new Error(`No such octicon: "${name}"!`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 20:53:29 +03:00
|
|
|
const story = storiesOf('Octicons', module)
|
2017-09-09 03:25:21 +03:00
|
|
|
|
|
|
|
Object.keys(octicons).forEach(name => {
|
2017-10-24 21:05:55 +03:00
|
|
|
story.add(name, () => {
|
2017-10-10 01:54:30 +03:00
|
|
|
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-10 01:54:30 +03:00
|
|
|
)
|
|
|
|
})
|
2017-09-09 03:25:21 +03:00
|
|
|
})
|