From a355ae8d56e1e325002be7b80222416820ae647a Mon Sep 17 00:00:00 2001 From: Laura Cabrera Date: Thu, 21 Sep 2017 11:43:43 -0700 Subject: [PATCH] feat(icon): Add fixes to render icons using new css classes --- src/components/Icon/Icon.jsx | 10 +++--- src/components/Icon/Icon.modules.scss | 32 +++++++++---------- .../__snapshots__/Icon.spec.jsx.snap | 2 +- .../Icon/__tests__/capitalize.spec.js | 9 ++++++ src/components/Icon/capitalize.js | 5 +++ 5 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 src/components/Icon/__tests__/capitalize.spec.js create mode 100644 src/components/Icon/capitalize.js diff --git a/src/components/Icon/Icon.jsx b/src/components/Icon/Icon.jsx index f71e285b9c..ff566abe91 100644 --- a/src/components/Icon/Icon.jsx +++ b/src/components/Icon/Icon.jsx @@ -2,6 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import { deprecate } from '../../warn' +import capitalize from './capitalize' import styles from './Icon.modules.scss' @@ -22,11 +23,12 @@ const Icon = ({ glyph, variant, label, fixedWidth, size, className, children, .. deprecate('Icon', '\'fixedWidth\' prop is deprecated.') } - const classes = `${styles.icon} ${styles[`iconCore${glyph.charAt(0).toUpperCase()}${glyph.slice(1)}`]}` + const classes = `${styles.icon}` + + ` ${styles[`iconCore${capitalize(glyph)}`]}` + ` ${variant ? styles[variant] : ''}` - + `${fixedWidth ? ` ${styles.fw}` : ''}` - + `${size ? ` ${styles[size]}` : ''}` - + `${className ? ` ${className}` : ''}` + + ` ${fixedWidth ? `${styles.fw}` : ''}` + + ` ${size ? `${styles[size]}` : ''}` + + ` ${className ? `${className}` : ''}` return ( renders 1`] = `