-
Notifications
You must be signed in to change notification settings - Fork 16
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
LG-4226: Improve support for unstyled button #191
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% comment %} | ||
This component displays an unstyled button, staged as if it has dimensions of a styled button, for | ||
the purpose of aligning button previews amongst other variants. | ||
{% endcomment %} | ||
|
||
<span class="display-block mobile-lg:display-inline-flex position-relative"> | ||
<button class="usa-button" disabled hidden style="visibility: hidden;">{{ include.text }}</button> | ||
<div class="position-absolute pin-all padding-right-1 display-flex flex-align-center flex-justify-center"> | ||
<button | ||
class="usa-button usa-button--unstyled {{ include.extra_classes }}" | ||
{{ include.extra_attributes }} | ||
> | ||
{{ include.text }} | ||
</button> | ||
</div> | ||
</span> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,50 @@ | |
} | ||
} | ||
|
||
.usa-button--unstyled { | ||
position: relative; | ||
text-underline-offset: 3px; | ||
|
||
// In USWDS, unstyled button styles are applied last to take precedence over base button styles. | ||
// Since we override base button styles, we must re-apply the unstyled button styles. | ||
&.usa-button { | ||
@include button-unstyled; | ||
} | ||
|
||
// Hover colors are already applied by USWDS via `typeset-link`, but this does not include the | ||
// button modifier classes. | ||
&:hover, | ||
&.usa-button--hover { | ||
color: color($theme-link-hover-color); | ||
} | ||
|
||
&:active, | ||
&.usa-button--active { | ||
color: color($theme-link-active-color); | ||
} | ||
|
||
&:disabled { | ||
color: color('disabled'); | ||
} | ||
|
||
&.usa-button:not([disabled]):focus, | ||
&.usa-button:not([disabled]).usa-focus { | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to clarify, this is different from the stanza as below because the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, when compiled it's the difference of: .usa-button--unstyled.usa-button:not([disabled]):focus {
/* ... these styles */
} vs. .usa-button:not([disabled]).usa-focus {
/* ... default focus styles */
} Where the intention with these styles is to unset and replace the default focus styles, only for the unstyled buttons. Ideally we could just use the default styles, but it was surprisingly difficult to reconcile the focus style box shadow + border radius, hence recreating it with a positioned pseudo-element. |
||
box-shadow: none; | ||
|
||
&::before { | ||
border-radius: .125rem; | ||
bottom: -5px; | ||
box-shadow: 0 0 0 $theme-focus-width color($theme-focus-color); | ||
content: ''; | ||
left: -5px; | ||
pointer-events: none; | ||
position: absolute; | ||
right: -5px; | ||
top: -5px; | ||
} | ||
} | ||
} | ||
|
||
.usa-button:not([disabled]):focus, | ||
.usa-button:not([disabled]).usa-focus { | ||
@include disable-default-focus-styles; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anniehirshman-gsa I noticed in the Figma that the hover and active states should be different colors. I think what we have here is the correct implementation, as far as using
$theme-link-hover-color
and$theme-link-active-color
, but it appears they're currently configured to the same color.I think it might make sense to update that globally so that the link hover and active colors are distinct, if that's the intention. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I would like to update
$theme-link-hover-color: 'primary-dark';
and$theme-link-active-color: 'primary-darker';
globally, to match the unstyled button mockups in Figma. Currently links have a hover color ofprimary-darker
and no active color. @nickttng does that sound good to you too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anniehirshman-gsa Yep, that sounds good