Skip to content

LG-3863: Remove BassCSS Responsive States module#4638

Merged
aduth merged 3 commits intomasterfrom
aduth-lg-3863-responsive-states
Feb 4, 2021
Merged

LG-3863: Remove BassCSS Responsive States module#4638
aduth merged 3 commits intomasterfrom
aduth-lg-3863-responsive-states

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Feb 2, 2021

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

**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'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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:

https://github.com/basscss/basscss-sass/blob/v3.0.0/_responsive-states.scss#L66-L105

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

**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');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

This should correspond to WebauthnSelectionPresenter#html_class, which it does.

@aduth aduth changed the title Remove BassCSS Responsive States module LG-3863: Remove BassCSS Responsive States module Feb 4, 2021
@aduth aduth merged commit 226fe41 into master Feb 4, 2021
@aduth aduth deleted the aduth-lg-3863-responsive-states branch February 4, 2021 13:30
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.

2 participants