Visitar URL original
Alert: Remove invalid and redundant alert height style by aduth · Pull Request #5187 · uswds/uswds · GitHub
Skip to content

Alert: Remove invalid and redundant alert height style - #5187

Merged
thisisdano merged 1 commit into
uswds:developfrom
aduth:aduth-rm-alert-icon-height
Apr 14, 2023
Merged

thisisdano merged 1 commit into
uswds:developfrom
aduth:aduth-rm-alert-icon-height

Conversation

@aduth

@aduth aduth commented Mar 15, 2023 •

Copy link
Copy Markdown
Contributor

Summary

Removes an unnecessary assignment of height styling in the add-alert-icon mixin.

  • This produces invalid styles because $theme-alert-icon-size is a unitless number (e.g. 2) and should be wrapped with the unit function
  • This is redundant anyways because the height is already assigned by the inclusion of add-color-icon mixin above using the height value from $this-icon-object

Testing and review

Observe the issue by inspecting the ::before pseudo-element of .usa-alert__body in the Alert component preview page.

Screen Shot 2023-03-15 at 9 33 24 AM

The changes proposed in this pull request will cause the second (invalid) highlighted height style to be removed.

- This produces invalid styles because `$theme-alert-icon-size` is a unitless number (e.g. `2`) and should be wrapped with the `unit` function
- This is redundant anyways because the `height` is already assigned by the inclusion of `add-color-icon` mixin above using the `height` value from `$this-ico-object`
@mejiaj
mejiaj requested a review from mahoneycm March 15, 2023 14:13
@aduth aduth changed the title Alert: Remove incorrect and redundant alert height style Alert: Remove invalid and redundant alert height style Mar 15, 2023

@mahoneycm mahoneycm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirming this effectively removes the redundant height definition from the alert icon!

The icon height is still defined through $theme-alert-icon-size via $this-icon-object directly above in the CSS. Removing the height definition from $theme-icon-object also does not use the height defined within the &::before selector so we can safely remove.

@mejiaj mejiaj added this to the uswds 3.5.0 milestone Mar 16, 2023
@mejiaj mejiaj linked an issue Mar 16, 2023 that may be closed by this pull request
2 tasks done
@mejiaj
mejiaj self-requested a review March 16, 2023 16:42
@mejiaj
mejiaj requested a review from thisisdano March 30, 2023 18:36
@aduth

aduth commented Apr 14, 2023 •

Copy link
Copy Markdown
Contributor Author

This issue might not actually be so harmless in all cases, since some CSS post-processors may try to correct the style by adding a missing unit.

For example, Lightning CSS will change the 4 to 4px, which will have an impact on the rendered style of the alert.

$ node -p "require('lightningcss').transform({ code: Buffer.from('body { height: 4; }') }).code.toString()"
body {
  height: 4px;
}

Edit: See example impact at 18F/identity-idp#8093 (comment)

@thisisdano
thisisdano merged commit 29eebc4 into uswds:develop Apr 14, 2023
@aduth
aduth deleted the aduth-rm-alert-icon-height branch April 14, 2023 20:47
@mahoneycm

Copy link
Copy Markdown
Contributor

Created change log PR for site: uswds/uswds-site#2094

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.

USWDS - Bug: Alert icon CSS height not using actual value

4 participants