Skip to content

Add better support for custom icon colors #4079

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

Merged
merged 13 commits into from
Mar 12, 2021
Merged

Add better support for custom icon colors #4079

merged 13 commits into from
Mar 12, 2021

Conversation

thisisdano
Copy link
Contributor

@thisisdano thisisdano commented Mar 11, 2021

Fixes #4064

  • Support automatic icon color in alerts
  • Fix color icon mixin to better support IE variants
  • Uses new icon set in thew banner

top: 0;
width: units($theme-alert-bar-width);
}
border-left: units($theme-alert-bar-width) solid color("base-light");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change alert bar to a border for simplicity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this up before position: relative.

@@ -1,3 +1,39 @@
$alert-slim-icon-size: units(3);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be adding this icon with a :before block and the mask technique instead of a background image on the alert itself, so some vars and calculations need to change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need a $alert-slim-icon-padding. The icon on slim variation stays the same but the padding varies when the icon size is updated.

For example, change $theme-alert-icon-size to 6.

image

}

.usa-alert__body {
display: table-cell;
vertical-align: top;
@include u-padding-x($theme-alert-padding-x);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the weird table-related styling

@@ -2,23 +2,20 @@
$bgcolor: if($name != "emergency", "#{$name}-lighter", $name);
$banner-text-color-token: get-color-token-from-bg(
$bgcolor,
$context: "Alert text"
$theme-alert-text-reverse-color,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use theme colors

Comment on lines 119 to 128
$ie11-variant: get-color-token-from-bg($contrast-bg, "white", "black");
$filename-ie11: if(
$ie11-variant == "white",
"usa-icons-bg/#{$filename-base}--white.svg",
"usa-icons/#{$filename-base}.svg"
);

$image-props: url("#{$path}/#{$filename}") no-repeat center / #{$width} #{$height};
$mask-props: url("#{$path}/#{$filename-base}.svg") no-repeat center / #{$width}
#{$height};
$image-props: url("#{$path}/#{$filename-ie11}") no-repeat center / #{$width} #{$height};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this code so it pulls the right --white variant from usa-icons-bg for IE support

@@ -27,6 +27,7 @@ $theme-alert-bar-width: 1 !default;
$theme-alert-font-family: "ui" !default;
$theme-alert-icon-size: 5 !default;
$theme-alert-padding-x: 2.5 !default;
$theme-alert-padding-y: 2 !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add explicit padding-y setting instead of calculating it from padding-x, which isn't expected.

Comment on lines +18 to +26
// Position centered in the alert
bottom: 0;
content: "";
display: block;
// padding - optical spacing value
left: $alert-icon-optical-padding;
position: absolute;
height: auto;
top: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the icon positioning a bit, so the icon is vertically centered on the alert.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE11 doesn't support calc() on generated content.

Maybe we should try a left value before this one or something like:

// Some left value for ie11
left: 1rem;

// Calc for modern browsers
@supports (left: $alert-icon-optical-padding) {
  left: $alert-icon-optical-padding;
}

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like the calc() is working for the content padding-left either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removed the calc()s and used Sass math instead

@thisisdano thisisdano requested a review from mejiaj March 11, 2021 00:53
@thisisdano thisisdano linked an issue Mar 11, 2021 that may be closed by this pull request
@thisisdano thisisdano changed the title Add better support for custom icons Add better support for custom icon colors Mar 11, 2021
Comment on lines 31 to 32
$theme-alert-text-color: default !default;
$theme-alert-text-reverse-color: default !default;
Copy link
Contributor

@mejiaj mejiaj Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we deprecate these?

We could use the defaults instead. I know they're set to default, but I wonder if these are even used.

$theme-text-color
$theme-text-reverse-color

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're maybe a little edge-y but if you wanted a different color for alerts or reverse alerts it would be helpful. I'd prefer not to deprecate them one release after introducing them, I guess. 😬

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a few issues, 1 on IE11 and another with the validation variant.

@mejiaj mejiaj merged commit 5eaf9de into uswds-2.11.0 Mar 12, 2021
@mejiaj mejiaj deleted the dw-color-icons branch March 12, 2021 22:28
This was referenced Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide better support for color icons that adapt to theme settings
2 participants