-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathicons.js
43 lines (39 loc) · 1.04 KB
/
icons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { mapValues } from 'lodash';
import images from './images/_index';
/**
* This module outputs icon objects with the following shape:
*
* {
* image: <svg>...</svg>,
* ...props
* }
*
* `props` here are config properties defined in this file for specific icons.
* For example, an icon may face a specific direction, and the Icon component
* accepts a `direction` prop to rotate directional icons, which relies on
* defining the default direction here.
*/
/**
* Configuration for individual icons.
*/
const config = {
'arrow': {
direction: 'left',
},
'chevron': {
direction: 'down',
},
'chevron-double': {
direction: 'down',
}
};
/**
* Map icon definition objects - imported object of images simply maps the icon
* name to the raw svg, so we move that to the `image` property of the
* definition object and set any additional configured properties for each icon.
*/
const icons = mapValues(images, (image, name) => {
const props = config[name] || {};
return { image, ...props };
});
export default icons;