Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 03c9671

Browse files
authored
fix(Icon): Color & docs update for Teams theme (#384)
* redlining colors for icons * showing disabled button with icon in Icon Usages section * removing the icon button example from Usages in Icon component. will add this as a Usage example in the Button component in a future PR * didn't mean to remove this in this PR. will remove in my next Icon PR dealing with spacing/padding * add changelog entry for icon color updates
1 parent 62dbe10 commit 03c9671

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2323
### Fixes
2424
- Fix build on Windows @jurokapsiar ([#383](https://github.com/stardust-ui/react/pull/383))
2525
- Add warning for rendering components outside provider @Bugaa92 ([#378](https://github.com/stardust-ui/react/pull/378))
26+
- Fix icon colors for Teams theme @codepretty ([#384](https://github.com/stardust-ui/react/pull/384))
2627

2728
### Features
2829
- Export `mergeThemes` @levithomason ([#285](https://github.com/stardust-ui/react/pull/285))

docs/src/examples/components/Icon/States/IconExampleDisabled.shorthand.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import { Icon } from '@stardust-ui/react'
44
const IconExampleDisabled = () => (
55
<div>
66
<Icon disabled name="umbrella" size="big" />
7-
<Icon disabled name="umbrella" size="big" variables={{ color: 'blue' }} />
8-
<Icon disabled name="umbrella" size="big" variables={{ color: 'red' }} />
9-
<Icon disabled name="umbrella" size="big" variables={{ color: 'orange' }} />
107
</div>
118
)
129

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
import { Icon } from '@stardust-ui/react'
3+
4+
const IconExampleColor = () => (
5+
<div>
6+
<Icon name="home" />
7+
<Icon name="home" variables={{ color: 'blue' }} />
8+
<Icon name="home" variables={{ color: 'red' }} />
9+
<Icon name="home" variables={{ color: 'orange' }} />
10+
</div>
11+
)
12+
13+
export default IconExampleColor

docs/src/examples/components/Icon/Variations/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ const Variations = () => (
99
description="An icon can have space before, after or on both sides. 'none' value removes the default space around the icon."
1010
examplePath="components/Icon/Variations/IconExampleSpace"
1111
/>
12+
<ComponentExample
13+
title="Color"
14+
description="An icon can have a different color"
15+
examplePath="components/Icon/Variations/IconExampleColor"
16+
/>
1217
<ComponentExample
1318
title="Size"
1419
description="An icon can vary in size."

src/themes/teams/components/Icon/iconStyles.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fontAwesomeIcons from './fontAwesomeIconStyles'
22
import { callable } from '../../../../lib'
3-
import { disabledStyle, fittedStyle } from '../../../../styles/customCSS'
3+
import { fittedStyle } from '../../../../styles/customCSS'
44
import { ComponentSlotStylesInput, ICSSInJSStyle, FontIconSpec } from '../../../types'
55
import { ResultOf } from '../../../../../types/utils'
66
import { IconXSpacing, IconProps } from '../../../../components/Icon/Icon'
@@ -30,22 +30,12 @@ const getFontStyles = (iconName: string, themeIcon?: ResultOf<FontIconSpec>): IC
3030

3131
return {
3232
fontFamily,
33-
width: '1.18em',
34-
fontStyle: 'normal',
35-
fontWeight: 400,
36-
textDecoration: 'inherit',
3733
textAlign: 'center',
38-
39-
'-webkit-font-smoothing': 'antialiased',
40-
'-moz-osx-font-smoothing': 'grayscale',
41-
backfaceVisibility: 'hidden',
42-
4334
lineHeight: 1,
35+
width: '1.18em',
4436

4537
'::before': {
4638
content,
47-
boxSizing: 'inherit',
48-
background: '0 0',
4939
},
5040
}
5141
}
@@ -67,7 +57,6 @@ const getBorderedStyles = (isFontBased, circular, borderColor, color): ICSSInJSS
6757
return {
6858
...getPaddedStyle(isFontBased),
6959

70-
// TODO: "black" here should actually match the Icon's fill or text color
7160
boxShadow: `0 0 0 0.05em ${borderColor || color || 'black'} inset`,
7261
...(circular ? { borderRadius: '50%' } : {}),
7362
}
@@ -87,43 +76,51 @@ const iconStyles: ComponentSlotStylesInput<IconProps, any> = {
8776
}): ICSSInJSStyle => {
8877
const iconSpec = theme.icons[name]
8978
const isFontBased = !iconSpec || !iconSpec.isSvg
79+
const iconColor = v.color || 'currentColor'
9080

9181
return {
82+
backgroundColor: v.backgroundColor,
9283
display: 'inline-block',
9384
fontSize: getSize(size),
94-
85+
margin: v.margin,
86+
speak: 'none',
87+
verticalAlign: 'middle',
88+
overflow: 'hidden',
9589
width: '1em',
9690
height: '1em',
9791

9892
...(isFontBased &&
9993
getFontStyles(name, callable(iconSpec && (iconSpec.icon as FontIconSpec))())),
10094

101-
...(isFontBased && { color: v.color }),
102-
backgroundColor: v.backgroundColor,
95+
...(isFontBased && {
96+
color: iconColor,
10397

104-
opacity: 1,
105-
margin: v.margin,
98+
...(disabled && {
99+
color: v.disabledColor,
100+
}),
101+
}),
106102

107-
speak: 'none',
103+
...(!isFontBased && {
104+
fill: iconColor,
108105

109-
verticalAlign: 'middle',
110-
overflow: 'hidden',
106+
...(disabled && {
107+
fill: v.disabledColor,
108+
}),
109+
}),
111110

112111
...getXSpacingStyles(xSpacing, v.horizontalSpace),
113112

114113
...((bordered || v.borderColor || circular) &&
115114
getBorderedStyles(isFontBased, circular, v.borderColor, v.color)),
116-
117-
...(disabled && disabledStyle),
118115
}
119116
},
120117

121118
svg: getSvgStyle('svg'),
122119

123120
g: getSvgStyle('g'),
124121

125-
/* additional SVG styles for different paths could be added/used in the same way */
126122
path: getSvgStyle('path'),
123+
127124
secondaryPath: getSvgStyle('secondaryPath'),
128125
}
129126

src/themes/teams/components/Icon/iconVariables.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ export interface IconVariables {
99
horizontalSpace: string
1010
margin: string
1111
secondaryColor: string
12+
disabledColor: string
1213
}
1314

14-
export default (): IconVariables => ({
15+
export default (siteVars): IconVariables => ({
1516
color: undefined,
16-
// TODO move initial variable discovery to JSON files
17-
// similar to how components have an info.json file
1817
backgroundColor: undefined,
1918
borderColor: undefined,
2019
horizontalSpace: pxToRem(10),
2120
margin: '0 0.25em 0 0',
22-
secondaryColor: 'white',
21+
secondaryColor: siteVars.white,
22+
disabledColor: siteVars.gray06,
2323
})

0 commit comments

Comments
 (0)