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 - Input: Move input width classes out of usa-form package #6232

Merged
merged 13 commits into from
Dec 16, 2024

Conversation

amyleadem
Copy link
Contributor

@amyleadem amyleadem commented Nov 29, 2024

Summary

Moved .usa-input--[width] and .usa-input-group--[width] classes out of the usa-form package.
These classes are now generated in the usa-input and usa-input-prefix-suffix packages and can be used without the .usa-form parent element.

Note

This is an alternative solution to PR #5935 (Thanks @aduth!)

Breaking change

This is not a breaking change.

Related issue

Closes #5312

Related pull requests

Changelog PR

Preview link

Problem statement

As a developer, I expect that if I include the package listed on a component's documentation (e.g. Text Input), all of the usage options documented for that component are available, so that I'm not confused by styles not existing despite being documented, or be forced to include more packages than I'd otherwise need for my optimized installation.

Solution

  • Moved .usa-input--[width] and .usa-input-group--[width] class defintions into the usa-input and usa-input-prefix-suffix package, respectively.
    • Created a new $system-input-widths map in the uswds-core package so that the values can be defined in a single location
    • Used the $system-input-widths map to generate usa-input--[width] and usa-input-group--[width] classes
  • Removed the max-width: none declaration from .usa-form .usa-input and .usa-form .usa-textarea to prevent specificity overrides

Testing and review

  • Confirm the .usa-input--[width] and .usa-input-group--[width] classes match the CSS (class names and values) in develop
  • Confirm usa-input--[width] and usa-input-group--[width] classes work as expected both with AND without a .usa-form parent on the following elements:
    • usa-input
    • usa-textarea
    • usa-input-group
    • Character count input (currently accepts the usa-input--[width] classes in develop)
    • Input mask input (currently accepts the usa-input--[width] classes in develop)
  • Confirm no regressions as a result of reducing the specificity of max-width: none on .usa-form children:
    • Set $theme-input-max-width to a value less than mobile (like "card" or 15)
    • Open the local build of mailing address pattern story
    • Confirm that all elements in the form, including the zip code input, are the same width as they are in develop
  • Confirm that creating $system-input-widths in uswds-core makes sense and lives in the appropriate location

Copy link
Contributor Author

@amyleadem amyleadem Nov 29, 2024

Choose a reason for hiding this comment

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

question: Is this the best location for this file?

Copy link
Contributor

Choose a reason for hiding this comment

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

One potential alternative is to move these to the properties file, although most of these values are set using system tokens.

https://github.com/uswds/uswds/blob/c512a8d408dddac083216d5c14088e20c58e6633/packages/uswds-core/src/styles/_properties.scss

@amyleadem amyleadem marked this pull request as ready for review November 29, 2024 21:32
@amyleadem amyleadem requested a review from a team as a code owner November 29, 2024 21:32
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.

This is all looking and working pretty well @amyleadem ! I left a couple thoughts in comments but nothing that is necessarily a blocker.

Copy link
Contributor

Choose a reason for hiding this comment

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

One potential alternative is to move these to the properties file, although most of these values are set using system tokens.

https://github.com/uswds/uswds/blob/c512a8d408dddac083216d5c14088e20c58e6633/packages/uswds-core/src/styles/_properties.scss

- Prevent overrides on usa-input--[width] classes
mahoneycm
mahoneycm previously approved these changes Dec 3, 2024
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.

LGTM! No perceived regressions from develop

Testing checklist

  • Confirm the .usa-input--[width] and .usa-input-group--[width] classes match the CSS (class names and values) in develop.
  • Confirm usa-input--[width] and usa-input-group--[width] classes work as expected both with AND without a .usa-form parent on the following elements:- [ ] Confirm no regressions as a result of removing max-width: none from .usa-form . usa-input and .usa-form . usa-input
  • Confirm that creating $system-input-widths in uswds-core makes sense

mejiaj
mejiaj previously approved these changes Dec 3, 2024
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.

Nice work, the new features are a nice enhancement that avoid breaking changes. Also, shoutout to @mahoneycm for the thorough review.

I tested:

  • Updating $theme-input-max-width and ensure there aren't conflicts.
  • Different sizes for input group for input prefix/suffix.
  • Different sizes for input widths
  • Compared against develop

@amyleadem amyleadem dismissed stale reviews from mejiaj and mahoneycm via eb51128 December 3, 2024 20:42
mlloydbixal
mlloydbixal previously approved these changes Dec 4, 2024
Copy link
Contributor

@mlloydbixal mlloydbixal left a comment

Choose a reason for hiding this comment

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

Confirmed all the testing and review steps and confirmed previous requested changes look good. Approving!

@amyleadem
Copy link
Contributor Author

@mlloydbixal @mahoneycm (cc: @aduth)

I've updated the Sass to generate explicit .usa-form .usa-input--[width] classes (see related comment for details). Can you re-review and make sure it still works as expected?

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.

This is working great! Great job covering all test cases and maintaining the current behaviors.

✅ ✅ ✅

Testing checklist

  • Confirm the .usa-input--[width] and .usa-input-group--[width] classes match the CSS (class names and values) in develop
  • Confirm usa-input--[width] and usa-input-group--[width] classes work as expected both with AND without a .usa-form parent on the following elements:
    • usa-input
    • usa-textarea
    • usa-input-group
    • Character count input (currently accepts the usa-input--[width] classes in develop)
    • Input mask input (currently accepts the usa-input--[width] classes in develop)
  • Confirm no regressions as a result of removing max-width: none from .usa-form . usa-input and .usa-form . usa-input
    • Looks good. The max width from usa-form manages the max width without the need to set it individually on nested elements.
    • Should we remove range and select?
  • Confirm that creating $system-input-widths in uswds-core makes sense

@amyleadem amyleadem requested review from heymatthenry and thisisdano and removed request for aduth December 12, 2024 20:27
Copy link
Member

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

Nice work, this one got a bit complicated!

@thisisdano thisisdano merged commit 7d65c20 into develop Dec 16, 2024
5 checks passed
@thisisdano thisisdano deleted the al-input-width branch December 16, 2024 22:35
@thisisdano thisisdano mentioned this pull request Dec 18, 2024
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 - Feature: Move usa-input--[width] classes to the usa-input module
6 participants