icons.stories.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import {storiesOf} from '@storybook/react';
  3. import {withInfo} from '@storybook/addon-info';
  4. import styled from 'react-emotion';
  5. import {Flex} from 'grid-emotion';
  6. import InlineSvg from 'app/components/inlineSvg';
  7. storiesOf('Style|Icons', module).add(
  8. 'SVG',
  9. withInfo('All SVG icons, to be used with `InlineSvg`')(() => {
  10. const context = require.context('app/icons', true, /\.svg/);
  11. const icons = context.keys().map(key => key.replace('./', '').replace('.svg', ''));
  12. return (
  13. <Flex wrap="wrap">
  14. {icons.map(icon => (
  15. <Swatch key={icon} align="center" justify="center">
  16. <Flex flex={1} align="center" justify="center">
  17. <InlineSvg height={20} width={20} src={icon} />
  18. </Flex>
  19. <Text>{icon.replace('icon-', '')}</Text>
  20. </Swatch>
  21. ))}
  22. </Flex>
  23. );
  24. })
  25. );
  26. const Swatch = styled(Flex)`
  27. flex-direction: column;
  28. background-color: white;
  29. border: 1px solid ${p => p.theme.borderLight};
  30. color: ${p => p.theme.gray5};
  31. width: 80px;
  32. height: 80px;
  33. margin: 8px;
  34. padding: 8px;
  35. text-align: center;
  36. word-break: break-all;
  37. line-height: 1.4em;
  38. `;
  39. const Text = styled('div')`
  40. font-size: 10px;
  41. white-space: nowrap;
  42. `;