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

USWDS - Card: Fix $theme-card-padding-y calculations #5571

Merged
merged 1 commit into from Nov 2, 2023

Conversation

amyleadem
Copy link
Contributor

@amyleadem amyleadem commented Oct 20, 2023

Summary

Fixed a bug that prevented $theme-card-padding-y from accepting expected token values.

Breaking change

This is not a breaking change.

Related issue

Closes #5515

Related pull requests

Changelog PR

Preview link

Card component

Problem statement

When setting custom values for $theme-card-padding-y, some values that the system says are acceptable cause an error.

For example: $theme-card-padding-y: 15 results in the following error:

Error: "`7.5` is not a valid `padding` token. You should correct this. Standard `padding` tokens:  1px, 2px, 05, 1, 105, 2, 205, 3, 4, 5, 6, 7, 8, 9, 10, 15, 0"
   ╷
25 │     padding-#{$side}: get-uswds-value("padding", $value...) #{$important};
   │                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  packages/uswds-core/src/styles/mixins/utilities/_padding.scss 25:23  padding-n()
  packages/uswds-core/src/styles/mixins/utilities/_padding.scss 50:3   u-padding-bottom()
  packages/usa-card/src/styles/_usa-card.scss 81:3                     @forward
  usa-card/src/_index.scss 4:1                                         @forward
  packages/uswds/_index.scss 20:1                                      @forward
  src/stylesheets/uswds.scss 3:1                                       root stylesheet 

This problem occurs because the u-padding mixins accept only known unit tokens. The current calculations perform division on the setting value before running it through the mixin, which means that the mixins are not always receiving acceptable unit values. For example, when $theme-card-padding-y is defined with 15, the mixin receives the value of 7.5, which is not a mapped unit value.

Solution

When the padding value must be divided, we should not use u-padding mixins and instead directly define the CSS padding property.

Testing and review

  1. Confirm that the $theme-card-padding-y setting accepts all listed padding token values without error: 1px, 2px, 05, 1, 105, 2, 205, 3, 4, 5, 6, 7, 8, 9, 10, 15, 0.
  2. Confirm that all math performed on $theme-card-padding-y are not used in mixins.
  3. Confirm that the setting updates the visual presentation as expected.
  4. Confirm that there are no visual regressions.

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.

Looks good to me!

Checklist

  • Confirm that the $theme-card-padding-y setting accepts all listed padding token values without error: 1px, 2px, 05, 1, 105, 2, 205, 3, 4, 5, 6, 7, 8, 9, 10, 15, 0.
  • Confirm that all math performed on $theme-card-padding-y are not used in mixins.
  • Confirm that the setting updates the visual presentation as expected.
  • Confirm that there are no visual regressions.

@thisisdano thisisdano merged commit 8f92ea7 into develop Nov 2, 2023
5 checks passed
@thisisdano thisisdano deleted the al-card-padding-calc branch November 2, 2023 16:55
@thisisdano thisisdano mentioned this pull request Nov 9, 2023
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: Error in card padding setting
3 participants