Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiIcon] Fix color prop for custom colors #4104

Merged
merged 6 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added `max-width: 100%` to `EuiKeyPadMenu` to allow it to shrink when its container is smaller than its fixed width ([ #4092](https://github.com/elastic/eui/pull/4092))
- Changed `EuiIcon` test mock to render as `span` instead of `div` ([#4099](https://github.com/elastic/eui/pull/4099))
- Added `scripts/docker-puppeteer` as the new home for test-related Docker images ([#4062](https://github.com/elastic/eui/pull/4062))
- Change `fill` to `color` CSS property for custom color in `EuiIcon`, add fully mono supprt when custom color is provided ([#4104](https://github.com/elastic/eui/pull/4104))
cchaos marked this conversation as resolved.
Show resolved Hide resolved

**Bug fixes**

cchaos marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
17 changes: 14 additions & 3 deletions src-docs/src/views/icon/icon_colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default () => (
<EuiSpacer />

<EuiFlexGrid columns={4}>
<EuiFlexItem className="guideDemo__icon" style={{ width: '340px' }}>
<EuiFlexItem className="guideDemo__icon" style={{ width: '255px' }}>
<EuiPanel>
<EuiIcon type="gisApp" size="xl" />
<EuiText size="s">
Expand All @@ -82,7 +82,7 @@ export default () => (
</EuiText>
</EuiPanel>
</EuiFlexItem>
<EuiFlexItem className="guideDemo__icon" style={{ width: '340px' }}>
<EuiFlexItem className="guideDemo__icon" style={{ width: '255px' }}>
<EuiPanel>
<EuiIcon type="gisApp" color="text" size="xl" />
<EuiText size="s">
Expand All @@ -93,7 +93,7 @@ export default () => (
</EuiText>
</EuiPanel>
</EuiFlexItem>
<EuiFlexItem className="guideDemo__icon" style={{ width: '340px' }}>
<EuiFlexItem className="guideDemo__icon" style={{ width: '255px' }}>
<EuiPanel>
<EuiIcon type="createAdvancedJob" color="primary" size="xl" />
<EuiText size="s">
Expand All @@ -104,6 +104,17 @@ export default () => (
</EuiText>
</EuiPanel>
</EuiFlexItem>
<EuiFlexItem className="guideDemo__icon" style={{ width: '255px' }}>
<EuiPanel>
<EuiIcon type="createAdvancedJob" color="#DA8B45" size="xl" />
<EuiText size="s">
<p>
<strong>Special:</strong> the custom color makes{' '}
cchaos marked this conversation as resolved.
Show resolved Hide resolved
<strong>App</strong> icons fully that color
</p>
</EuiText>
</EuiPanel>
</EuiFlexItem>
</EuiFlexGrid>
</div>
);
16 changes: 8 additions & 8 deletions src/components/icon/__snapshots__/icon.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ exports[`EuiIcon is rendered 1`] = `
exports[`EuiIcon props color #885522 is rendered 1`] = `
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon-isLoaded"
class="euiIcon euiIcon--medium euiIcon-isCustomColor euiIcon-isLoaded"
focusable="false"
height="16"
role="img"
style="fill: #885522;"
style="color: rgb(136, 85, 34);"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -39,11 +39,11 @@ exports[`EuiIcon props color #885522 is rendered 1`] = `
exports[`EuiIcon props color #fde is rendered 1`] = `
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon-isLoaded"
class="euiIcon euiIcon--medium euiIcon-isCustomColor euiIcon-isLoaded"
focusable="false"
height="16"
role="img"
style="fill: #fde;"
style="color: rgb(255, 221, 238);"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -125,11 +125,11 @@ exports[`EuiIcon props color ghost is rendered 1`] = `
exports[`EuiIcon props color hsla(270, 60%, 70%, 0.9) is rendered 1`] = `
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon-isLoaded"
class="euiIcon euiIcon--medium euiIcon-isCustomColor euiIcon-isLoaded"
focusable="false"
height="16"
role="img"
style="fill: hsla(270, 60%, 70%, 0.9);"
style="color: hsla(270, 60%, 70%, 0.9);"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -160,11 +160,11 @@ exports[`EuiIcon props color primary is rendered 1`] = `
exports[`EuiIcon props color rgb(100, 150, 200) is rendered 1`] = `
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon-isLoaded"
class="euiIcon euiIcon--medium euiIcon-isCustomColor euiIcon-isLoaded"
focusable="false"
height="16"
role="img"
style="fill: rgb(100, 150, 200);"
style="color: rgb(100, 150, 200);"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
Expand Down
3 changes: 2 additions & 1 deletion src/components/icon/_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
// App icon special cases for fully mono
.euiIcon--text,
.euiIcon--subdued,
.euiIcon--primary {
.euiIcon--primary,
.euiIcon-isCustomColor {
&,
.euiIcon__fillSecondary {
fill: currentColor;
Expand Down
3 changes: 2 additions & 1 deletion src/components/icon/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ export class EuiIcon extends PureComponent<EuiIconProps, State> {
if (isNamedColor(color)) {
optionalColorClass = colorToClassMap[color];
} else {
optionalCustomStyles = { fill: color };
optionalCustomStyles = { color: color };
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -691,6 +691,7 @@ export class EuiIcon extends PureComponent<EuiIconProps, State> {
optionalColorClass,
{
'euiIcon--app': isAppIcon,
'euiIcon-isCustomColor': optionalCustomStyles,
cchaos marked this conversation as resolved.
Show resolved Hide resolved
'euiIcon-isLoading': isLoading,
'euiIcon-isLoaded': !isLoading && neededLoading,
},
Expand Down