Skip to content

Commit

Permalink
Remove need for lodash defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jul 25, 2022
1 parent b1128a8 commit 9ec7d9c
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/components/token/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import React, { FunctionComponent, HTMLAttributes } from 'react';
import classNames from 'classnames';
import defaults from 'lodash/defaults';
import { CommonProps } from '../common';
import { useEuiTheme, isColorDark, hexToRgb } from '../../services';

Expand Down Expand Up @@ -106,26 +105,16 @@ export const EuiToken: FunctionComponent<EuiTokenProps> = ({
finalSize = 'm';
}

const currentDisplay = {
color,
fill,
shape,
};

let finalDisplay;

// If the iconType passed is one of the prefab token types,
// grab its properties
if (typeof iconType === 'string' && iconType in TOKEN_MAP) {
const tokenDisplay = TOKEN_MAP[iconType as EuiTokenMapType];
finalDisplay = defaults(currentDisplay, tokenDisplay);
} else {
finalDisplay = currentDisplay;
}

const finalColor = finalDisplay.color || 'gray';
const finalShape = finalDisplay.shape || 'circle';
let finalFill = finalDisplay.fill || 'light';
const tokenDefaults =
typeof iconType === 'string' && iconType in TOKEN_MAP
? TOKEN_MAP[iconType as EuiTokenMapType]
: {};

const finalColor = color || tokenDefaults.color || 'gray';
const finalShape = shape || tokenDefaults.shape || 'circle';
let finalFill = fill || 'light';

const euiTheme = useEuiTheme();
const styles = euiTokenStyles(euiTheme);
Expand Down

0 comments on commit 9ec7d9c

Please sign in to comment.