-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
- remove classnames lib dependency - add inverted variant - add three sizes - deprecate fixedWidth - migrate CSS to a module
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import classNames from 'classnames' | ||
import styles from './Icon.modules.scss' | ||
|
||
const Icon = ({ glyph, variant, fixedWidth, size, className, children, ...rest }) => { | ||
const classes = classNames( | ||
'icon', | ||
`icon-core-${glyph}`, | ||
className, | ||
{ | ||
'icon--fw': fixedWidth, | ||
[`icon--${variant}`]: variant, | ||
'icon--large': size | ||
} | ||
) | ||
const classes = ` | ||
${styles.icon} | ||
${styles[`icon-core-${glyph}`]} | ||
${variant ? styles[`icon-color--${variant}`] : styles['icon-color--inherit']} | ||
${fixedWidth ? styles['icon--fw'] : ''} | ||
${size ? styles[`icon--${size}`] : ''} | ||
${className} | ||
` | ||
|
||
return ( | ||
<i {...rest} className={classes}> | ||
|
@@ -44,21 +42,26 @@ Icon.propTypes = { | |
]).isRequired, | ||
/** | ||
* The appearance of the Icon. | ||
* | ||
* **Note**: when no variant is specified, the icon's colour is inherited from parent element. | ||
*/ | ||
variant: PropTypes.oneOf([ | ||
'primary', | ||
'secondary', | ||
'disabled', | ||
'inverted', | ||
'error' | ||
]), | ||
/** | ||
* Whether or not to give the icon a fixed width. | ||
* | ||
* @deprecated please use [Unordered Lists](#unorderedlist) to | ||
This comment has been minimized.
Sorry, something went wrong. |
||
* display icons uniformly within a column. | ||
*/ | ||
fixedWidth: PropTypes.bool, | ||
/** | ||
* @ignore | ||
* | ||
*/ | ||
size: PropTypes.oneOf(['large']), | ||
size: PropTypes.oneOf(['small', 'medium', 'large']), | ||
/** | ||
* One or more CSS class names separated by spaces to append onto the icon. | ||
* Don't advertise as we plan on removing this feature soon. | ||
|
@@ -75,9 +78,9 @@ Icon.propTypes = { | |
children: PropTypes.node | ||
} | ||
Icon.defaultProps = { | ||
variant: null, | ||
variant: undefined, | ||
fixedWidth: false, | ||
size: null, | ||
size: 'medium', | ||
This comment has been minimized.
Sorry, something went wrong.
lzcabrera
Member
|
||
className: '', | ||
children: null | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@import '../../scss/settings/icons'; | ||
@import '../../scss/settings/colours'; | ||
@import '../../scss/utility/icons-utility'; | ||
|
||
@font-face { | ||
font-family: "TELUS Core Icons"; | ||
src: url('#{$icon-font-prefix}/core-icons.eot'); | ||
src: | ||
url('#{$icon-font-prefix}/core-icons.woff2') format('woff2'), | ||
url('#{$icon-font-prefix}/core-icons.woff') format('woff'), | ||
url('#{$icon-font-prefix}/core-icons.ttf') format('truetype'), | ||
url('#{$icon-font-prefix}/core-icons.eot?#iefix') format('eot'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
ryanoglesby08
Contributor
|
||
|
||
.icon { | ||
@include core-icon; | ||
|
||
transition: color .1s linear; | ||
|
||
&--primary { | ||
color: $color-icon-primary; | ||
} | ||
|
||
&--secondary { | ||
color: $color-icon-secondary; | ||
} | ||
|
||
&--error { | ||
color: $color-cardinal; | ||
} | ||
|
||
&--disabled { | ||
color: $color-icon-disabled; | ||
} | ||
|
||
&--fw { | ||
width: 1.09rem; | ||
text-align: center; | ||
} | ||
|
||
&--small { | ||
font-size: 1 rem; | ||
} | ||
|
||
&--medium { | ||
font-size: 1.5rem; | ||
} | ||
|
||
&--large { | ||
font-size: 3rem; | ||
} | ||
} | ||
|
||
@each $name, $codepoint in $core-icon-codepoints { | ||
.icon-core-#{$name}::before { | ||
content: $codepoint; | ||
} | ||
} | ||
|
||
// Variants | ||
.icon-color--inherit { | ||
color: inherit; | ||
} | ||
|
||
.icon-color--primary { | ||
color: $color-primary; | ||
} | ||
|
||
.icon-color--secondary { | ||
color: $color-secondary; | ||
} | ||
|
||
.icon-color--inverted { | ||
color: $color-white; | ||
} | ||
|
||
.icon-color--error { | ||
color: $color-icon-error; | ||
} | ||
|
||
.icon-core-left-chevron { | ||
@include core-icon(chevron); | ||
|
||
&::before { | ||
display: inline-block; | ||
transform: rotate(-180deg) translateY(1.5px); | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
ryanoglesby08
Contributor
|
Note: Currently UnorderedList doesn't have the ability to display different icons within the same list.