|
8 | 8 |
|
9 | 9 | import React, { FunctionComponent, HTMLAttributes } from 'react'; |
10 | 10 | import classNames from 'classnames'; |
11 | | -import defaults from 'lodash/defaults'; |
12 | 11 | import { CommonProps } from '../common'; |
13 | 12 | import { useEuiTheme, isColorDark, hexToRgb } from '../../services'; |
14 | 13 |
|
@@ -106,26 +105,16 @@ export const EuiToken: FunctionComponent<EuiTokenProps> = ({ |
106 | 105 | finalSize = 'm'; |
107 | 106 | } |
108 | 107 |
|
109 | | - const currentDisplay = { |
110 | | - color, |
111 | | - fill, |
112 | | - shape, |
113 | | - }; |
114 | | - |
115 | | - let finalDisplay; |
116 | | - |
117 | 108 | // If the iconType passed is one of the prefab token types, |
118 | 109 | // grab its properties |
119 | | - if (typeof iconType === 'string' && iconType in TOKEN_MAP) { |
120 | | - const tokenDisplay = TOKEN_MAP[iconType as EuiTokenMapType]; |
121 | | - finalDisplay = defaults(currentDisplay, tokenDisplay); |
122 | | - } else { |
123 | | - finalDisplay = currentDisplay; |
124 | | - } |
125 | | - |
126 | | - const finalColor = finalDisplay.color || 'gray'; |
127 | | - const finalShape = finalDisplay.shape || 'circle'; |
128 | | - let finalFill = finalDisplay.fill || 'light'; |
| 110 | + const tokenDefaults = |
| 111 | + typeof iconType === 'string' && iconType in TOKEN_MAP |
| 112 | + ? TOKEN_MAP[iconType as EuiTokenMapType] |
| 113 | + : {}; |
| 114 | + |
| 115 | + const finalColor = color || tokenDefaults.color || 'gray'; |
| 116 | + const finalShape = shape || tokenDefaults.shape || 'circle'; |
| 117 | + let finalFill = fill || 'light'; |
129 | 118 |
|
130 | 119 | const euiTheme = useEuiTheme(); |
131 | 120 | const styles = euiTokenStyles(euiTheme); |
|
0 commit comments