icons.stories.js 1.4 KB

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