svg.stories.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import centered from '@storybook/addon-centered/react';
  3. import { storiesOf } from '@storybook/react';
  4. import importAll from '../../src/utils/importAll';
  5. import parsePathToName from '../../src/utils/parsePathToName';
  6. import ColumnsLayout from '../../src/components/ColumnsLayout';
  7. const iconStyle = { height: '50vh', maxWidth: '100%' };
  8. const iconsList = require.context('../../src/assets/svg', false, /\.(png|jpe?g|svg)$/);
  9. const icons = importAll(iconsList);
  10. const stories = storiesOf('Assets|Icons', module);
  11. stories.addDecorator(centered);
  12. stories.addParameters({
  13. backgrounds: [{ name: 'silver', value: '#cacaca', default: true }],
  14. });
  15. stories.add('_all', () => {
  16. return (
  17. <ColumnsLayout columnsCount={4} style={{ padding: '20px' }}>
  18. {icons.map((icon, i) => {
  19. const Icon = icon.ReactComponent;
  20. return (
  21. <div
  22. key={iconsList.keys()[i]}
  23. style={{
  24. display: 'flex',
  25. flexDirection: 'column',
  26. justifyContent: 'center',
  27. alignItems: 'center',
  28. textAlign: 'center',
  29. }}
  30. >
  31. <Icon style={{ maxHeight: '200px', width: '100%' }} />
  32. <p style={{ marginTop: '12px' }}>{parsePathToName(iconsList.keys()[i])}</p>
  33. </div>
  34. );
  35. })}
  36. </ColumnsLayout>
  37. );
  38. });
  39. icons.forEach((icon, i) => {
  40. const Icon = icon.ReactComponent;
  41. stories.add(`${parsePathToName(iconsList.keys()[i])}`, () => <Icon style={iconStyle} />);
  42. });