Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add icons stories #1524

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/icons/Icons.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { withKnobs, text, number, color } from '@storybook/addon-knobs'

const requireContext = require.context('.', true, /\.js?$/)
const modules = requireContext.keys().filter((c) => !c.includes('.stories'))
const icons = modules.map(m => ({
name: m.replace('./', '').replace('.js', ''),
Icon: requireContext(m).default
}))

const filterByTextQuery = (icon) => {
const searchQuery = text('Search', '')
return icon.name.includes(searchQuery)
}

storiesOf('Icons', module)
.addDecorator(withKnobs)
.add('List', () => {
const size = number('Size', 32, { range: true, min: 1, max: 200, step: 1 })
const fill = color('Fill', undefined)
const stroke = color('Stroke', undefined)

return (
<div className="flex w-100 flex-wrap">
{icons.filter(filterByTextQuery).map(({ Icon, name }) => (
<div className="flex items-center flex-column ma3">
<Icon fill={fill} stroke={stroke} width={size} height={size} className="transition-all" />
<span>{ name }</span>
</div>)
)}
</div>
)
})