LG-3863: Remove BassCSS Responsive States module#4638
Conversation
**Why**: Toward the goal of dropping BassCSS in favor of USWDS. **Implementation Notes:** The primary challenge with this particular module is that (a) at least one class "display-none" overlaps with a class of the same name in USWDS and (b) combined with the fact that BassCSS applies these state styles using the `!important` flag. https://github.com/basscss/basscss-sass/blob/v3.0.0/_responsive-states.scss Thus, it's necessary to ensure that each instance of BassCSS responsive state class usage is not dependent upon the `!important` to override some other `display` styling. This is not problematic in most cases because the classes are typically used either in JavaScript visibility toggling, or in toggling to be visible only in specific viewport ranges, where a corresponding class(es) exist in USWDS.
| - 'not-rounded' | ||
| - 'rounded-(top|right|bottom|left)' | ||
| - '(md|lg)-hide' | ||
| - '(xs|md|lg)-show' |
There was a problem hiding this comment.
Re: Removing xs here: I may have been confused in the original technical discovery, since BassCSS at some point in time had xs- prefixes:
https://github.com/basscss/basscss/blob/8104041/modules/hide/index.css#L12
But these do not exist in the NPM module version we're using:
**Why**: Can conflict with display utility classes from USWDS. See: #4638 (comment)
| const elem = document.getElementById('select_webauthn'); | ||
| if (elem) { | ||
| elem.classList.remove('hide'); | ||
| elem.classList.remove('display-none'); |
There was a problem hiding this comment.
This is for alternative options for "Choose another authentication method", to present Security Key as an option only if the browser supports it.
Suggesting to keep this as display: none, since it's intended not to be available as an option by default.
| if (elem) { | ||
| elem.hidden = false; | ||
| elem.classList.remove('hide'); | ||
| elem.classList.remove('display-none'); |
There was a problem hiding this comment.
This is for 2FA options for signup, to present Security Key as an option only if the browser supports it.
Suggesting to keep this as display: none, since it's intended not to be available as an option by default.
|
|
||
| def html_class | ||
| 'hide' | ||
| 'display-none' |
There was a problem hiding this comment.
This corresponds to above note about 2FA options for signup, and must match the JavaScript logic for showing the option if the browser supports WebAuthn, by removing the class of the same name.
This is also how I discovered the issue described in #4638 (comment), where a screen-reader-only class could interoperate with .btn-border's own display: inline-block, but display-none would not.
| @@ -1,4 +1,4 @@ | |||
| <div id='pw-strength-cntnr' class='hide' aria-live='polite' aria-atomic='true'> | |||
| <div id='pw-strength-cntnr' class='display-none' aria-live='polite' aria-atomic='true'> | |||
There was a problem hiding this comment.
As described in a JavaScript comment, the purpose of the class is to hide the strength meter from JavaScript-disabled browsers.
Suggesting to keep this as display: none.
| </div> | ||
| </label> | ||
| <label class="btn-border col-12 mb2 hide" for="two_factor_options_form_selection_webauthn"> | ||
| <label class="btn-border col-12 mb2 display-none" for="two_factor_options_form_selection_webauthn"> |
There was a problem hiding this comment.
It's not clear to me why we hide this, but given that the content of the page appears to be static text content for a work-in-progress flow presumably copied from 2FA options page markup, I'm not too concerned about it.
| <%= label_tag "two_factor_options_form_selection_#{option.type}", | ||
| class: "btn-border col-12 mb2 #{option.html_class}", | ||
| hidden: option.html_class == 'hide' do %> | ||
| hidden: option.html_class == 'display-none' do %> |
There was a problem hiding this comment.
This should correspond to WebauthnSelectionPresenter#html_class, which it does.
| <%= label_tag "two_factor_options_form_selection_#{option.type}", | ||
| class: "btn-border col-12 mb2 #{option.html_class}", | ||
| hidden: option.html_class == 'hide' do %> | ||
| hidden: option.html_class == 'display-none' do %> |
There was a problem hiding this comment.
This should correspond to WebauthnSelectionPresenter#html_class, which it does.
Why: Toward the goal of dropping BassCSS in favor of USWDS.
Implementation Notes: The primary challenge with this module is that (a) the "display-none" class overlaps with a class of the same name in USWDS and (b) combined with the fact that BassCSS applies these state styles using the
!importantflag.https://github.com/basscss/basscss-sass/blob/v3.0.0/_responsive-states.scss
Thus, it's necessary to ensure that each instance of BassCSS responsive state class usage is not dependent upon the
!importantto override some otherdisplaystyling. This is not problematic in most cases because the classes are typically used either in JavaScript visibility toggling, or in toggling to be visible only in specific viewport ranges, where a corresponding class(es) exist in USWDS.