|
1 | 1 | import React from 'react';
|
2 | 2 | import styled from '@emotion/styled';
|
3 | 3 | import { Switch, Route } from 'react-router-dom';
|
| 4 | +import { ThemeProvider } from 'emotion-theming'; |
4 | 5 | import * as UIKit from 'ui-kit';
|
5 | 6 | import { Suite, Spec } from '../../../test/percy';
|
6 | 7 |
|
@@ -28,54 +29,74 @@ const IconContainer = styled.div`
|
28 | 29 | const icons = Object.keys(UIKit).filter(thing => thing.endsWith('Icon'));
|
29 | 30 |
|
30 | 31 | const sizes = ['small', 'medium', 'big', 'scale'];
|
31 |
| -const themes = [ |
32 |
| - 'black', |
33 |
| - 'grey', |
34 |
| - 'white', |
35 |
| - 'blue', |
36 |
| - 'green', |
37 |
| - 'green-light', |
38 |
| - 'orange', |
39 |
| - 'red', |
| 32 | + |
| 33 | +const colors = [ |
| 34 | + 'solid', |
| 35 | + 'neutral60', |
| 36 | + 'surface', |
| 37 | + 'info', |
| 38 | + 'primary', |
| 39 | + 'primary40', |
| 40 | + 'warning', |
| 41 | + 'error', |
40 | 42 | ];
|
41 | 43 |
|
42 | 44 | export const routePath = '/icons';
|
43 | 45 |
|
44 |
| -const renderIcon = (iconName, theme, size) => { |
| 46 | +const renderIcon = (iconName, color, size) => { |
45 | 47 | const Icon = UIKit[iconName];
|
46 | 48 | return (
|
47 | 49 | <IconItem key={iconName}>
|
48 | 50 | <IconContainer big={size === 'scale'}>
|
49 |
| - <Icon theme={theme} size={size} /> |
| 51 | + <Icon color={color} size={size} /> |
50 | 52 | </IconContainer>
|
51 | 53 | <UIKit.Text.Body>{iconName}</UIKit.Text.Body>
|
52 | 54 | </IconItem>
|
53 | 55 | );
|
54 | 56 | };
|
55 | 57 |
|
56 |
| -export const component = () => ( |
| 58 | +export const component = ({ themes }) => ( |
57 | 59 | <Switch>
|
58 |
| - {themes.map(theme => ( |
| 60 | + {colors.map(color => ( |
59 | 61 | <Route
|
60 |
| - key={theme} |
61 |
| - path={`${routePath}/${theme}`} |
| 62 | + key={color} |
| 63 | + path={`${routePath}/${color}`} |
62 | 64 | exact
|
63 | 65 | render={() => (
|
64 | 66 | <Suite>
|
65 | 67 | {sizes.map(size => (
|
66 | 68 | <Spec
|
67 | 69 | key={size}
|
68 |
| - label={`All Icons - Theme: ${theme} / Size: ${size}`} |
| 70 | + label={`All Icons - Color: ${color} / Size: ${size}`} |
69 | 71 | omitPropsList
|
70 | 72 | >
|
71 | 73 | <IconList>
|
72 |
| - {icons.map(iconName => renderIcon(iconName, theme, size))} |
| 74 | + {icons.map(iconName => renderIcon(iconName, color, size))} |
73 | 75 | </IconList>
|
74 | 76 | </Spec>
|
75 | 77 | ))}
|
76 | 78 | </Suite>
|
77 | 79 | )}
|
78 | 80 | />
|
79 | 81 | ))}
|
| 82 | + <Route |
| 83 | + exact |
| 84 | + path={`${routePath}/theme`} |
| 85 | + render={() => ( |
| 86 | + <Suite> |
| 87 | + <ThemeProvider theme={themes.darkTheme}> |
| 88 | + {colors.map(color => ( |
| 89 | + <Spec |
| 90 | + key={color} |
| 91 | + label={`Themed Icons - Color: ${color}`} |
| 92 | + omitPropsList |
| 93 | + > |
| 94 | + <IconList>{renderIcon('ClockIcon', color, 'big')}</IconList> |
| 95 | + </Spec> |
| 96 | + ))} |
| 97 | + </ThemeProvider> |
| 98 | + </Suite> |
| 99 | + )} |
| 100 | + /> |
80 | 101 | </Switch>
|
81 | 102 | );
|
0 commit comments