Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Mar 15, 2023

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
Copy link
Contributor

@mahoneycm mahoneycm left a comment

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
@mejiaj mejiaj self-requested a review March 16, 2023 16:42
@mejiaj mejiaj requested a review from thisisdano March 30, 2023 18:36
@aduth
Copy link
Contributor Author

aduth commented Apr 14, 2023

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
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