-
Notifications
You must be signed in to change notification settings - Fork 99
refactor(button): style with pseudo-private custom properties #1038
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2d8165d
refactor(button): style with pseudo-private custom properties
dancormier 3a21409
Merge branch 'develop' into dcormier/btn-css-refactor
dancormier ac9a78d
refactor(btn): increase badge opacity
dancormier 6d871c2
Merge branch 'develop' into dcormier/btn-css-refactor
dancormier 50c8608
Merge branch 'develop' into dcormier/btn-css-refactor
dancormier d58b22b
Merge branch 'develop' into dcormier/btn-css-refactor
dancormier 62d59fc
refactor(button-group): add radio layout (#1135)
dancormier d00b522
Merge branch 'dcormier/btn-css-refactor' of https://github.com/StackE…
dancormier 8f6e4d5
Conform btn styles to standard
dancormier 1a3be55
Prefix component custom properties
dancormier 3276510
Fix --radio selector
dancormier 76e7f17
match styles to template (mostly)
dancormier 3abf5ef
Ensure unset docs buttons have base class
dancormier acef3c4
Move contextual styles within variants
dancormier ae587ec
Remove unneeded todo
dancormier 0183a3e
Improve radio-based button styling
dancormier 44458a1
fix muted filled interactive background colors
dancormier 4e14d2b
Match PPCP format
dancormier 6f35c09
Ensure btn groups have correct hover styling
dancormier 73790a3
Adjust button group styling
dancormier de2e267
drop trailing whitespace
b-kelly 4bf095c
Remove commented code
dancormier e946105
Fix radio button group focus
dancormier 857d311
typo fixes
b-kelly e519ab4
Fix primary variant dark mode interaction bg colors
dancormier 77c425c
Compensate for form wrappers within button group buttons
dancormier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,90 +1,80 @@ | ||
| .s-btn-group { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| margin-bottom: 1px; // Compensate for buttons having a margin bottom of -1px to account for row wrapping | ||
|
|
||
| .s-btn { | ||
| margin-bottom: -1px; // When wrapping we need to account for the border | ||
| white-space: nowrap; // When the buttons wrap, they get super tall and mess up the whole layout | ||
| // CONTEXTUAL STYLES | ||
| #stacks-internals #screen-sm({ | ||
| .s-btn { | ||
| &.s-btn__dropdown { | ||
| padding-right: 1.2em; | ||
|
|
||
| // If it isn't the last button, we should slide the button over to account for border thickness | ||
| &:not(:last-child) { | ||
| margin-right: -1px; | ||
| } | ||
| &:after { | ||
| right: 0.4em; | ||
| } | ||
| } | ||
|
|
||
| // We don't want border-radii on interior buttons | ||
| &:not(:first-child):not(:last-child) { | ||
| border-radius: 0; | ||
| padding-left: 0.4em; | ||
| padding-right: 0.4em; | ||
| } | ||
| }, @force-selector: true); | ||
|
|
||
| // Kill the right border radius on the first button | ||
| &:first-child:not(:only-child) { | ||
| border-top-right-radius: 0; | ||
| border-bottom-right-radius: 0; | ||
| } | ||
| // VARIANTS | ||
| &:not(&--radio) .s-btn:not(:first-child):not(:last-child), | ||
| &&--radio .s-btn:not(:first-of-type):not(:last-of-type) { | ||
| border-radius: 0; | ||
| } | ||
|
|
||
| // Kill the left border radius on the last button | ||
| &:last-child:not(:only-child) { | ||
| border-top-left-radius: 0; | ||
| border-bottom-left-radius: 0; | ||
| } | ||
| &:not(&--radio) .s-btn:first-child:not(:only-child), | ||
| &&--radio .s-btn:first-of-type:not(:last-of-type) { | ||
| border-top-right-radius: 0; | ||
| border-bottom-right-radius: 0; | ||
| } | ||
|
|
||
| // When the button is active or selected, it should pop above its siblings | ||
| &.is-selected { | ||
| z-index: var(--zi-selected); | ||
| } | ||
| &:not(&--radio) .s-btn:last-child:not(:only-child), | ||
| &&--radio .s-btn:last-of-type:not(:first-of-type) { | ||
| border-top-left-radius: 0; | ||
| border-bottom-left-radius: 0; | ||
| } | ||
|
|
||
| .highcontrast-mode({ | ||
| &.is-selected { | ||
| background-color: var(--black-400); | ||
| color: var(--white); | ||
| &:not(&--radio) .s-btn:not(:last-child), | ||
| &&--radio .s-btn:not(:last-of-type) { | ||
| margin-right: calc(var(--su-static1) * -1); | ||
| } | ||
|
|
||
| .s-btn--number { | ||
| color: var(--black); | ||
| } | ||
| // CHILD ELEMENTS | ||
| form { | ||
| &:not(:first-child):not(:last-child) { | ||
| .s-btn { | ||
| border-radius: 0; | ||
| } | ||
| }); | ||
|
|
||
| &:active { | ||
| z-index: var(--zi-active); | ||
| } | ||
|
|
||
| #stacks-internals #screen-sm({ | ||
| padding-left: 0.4em; | ||
| padding-right: 0.4em; | ||
| }, @force-selector: true); | ||
| } | ||
|
|
||
| #stacks-internals #screen-sm({ | ||
| .s-btn.s-btn__dropdown { | ||
| padding-right: 1.2em; | ||
|
|
||
| &:after { | ||
| right: 0.4em; | ||
| &:last-child:not(:only-child) { | ||
| .s-btn:not(:last-child) { | ||
| border-radius: 0; | ||
| } | ||
| } | ||
| &:first-child:not(:only-child) { | ||
| .s-btn:not(:first-child) { | ||
| border-radius: 0; | ||
| } | ||
| } | ||
| }, @force-selector: true); | ||
|
|
||
| .s-btn-group--container { | ||
| display: flex; | ||
| margin-right: calc(var(--su-static1) * -1); // -1px | ||
| } | ||
|
|
||
| .s-btn { | ||
| margin-right: -1px; // We should slide buttons over to account for border thickness | ||
| .s-btn { | ||
| &:active { | ||
| z-index: var(--zi-active); | ||
| } | ||
|
|
||
| &:not(:first-child):not(:last-child) .s-btn { | ||
| border-radius: 0; | ||
| &.is-selected, | ||
| &--radio:checked + .s-btn { | ||
| z-index: var(--zi-selected); // When the button is active or selected, it should pop above its siblings | ||
| } | ||
|
|
||
| &:first-child .s-btn { | ||
| border-top-right-radius: 0; | ||
| border-bottom-right-radius: 0; | ||
| margin-left: 0; | ||
| } | ||
|
|
||
| &:last-child .s-btn { | ||
| border-top-left-radius: 0; | ||
| border-bottom-left-radius: 0; | ||
| } | ||
| margin-bottom: calc(var(--su-static1) * -1); // When wrapping we need to account for the border | ||
| white-space: nowrap; // When the buttons wrap, they get super tall and mess up the whole layout | ||
| } | ||
|
|
||
| // STATIC COMPONENT STYLES | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| margin-bottom: var(--su-static1); // Compensate for buttons having a margin bottom of -1px to account for row wrapping | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks like this is a breaking change. How should we handle this?
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.
So, I originally intended this to be a non-breaking change, but a deprecation. In 77c425c, I've targeted the
formelement and once again made this a deprecation. Basically with the PR as it is now, the changes should be backwards compatible.Should we reintroduce
.s-btn-group--container? I know targeting a HTML tag feels a little icky but it doesn't feel totally wrong here. That said, I'm fine with targeting that class and punting on any of this and FWIW it's pretty low stakes since I only found it used in one place in Core.PS:
.s-btn-group--containerpreviously just set any nested button border radius to 0. That means if the button was at the start or end of the button group, it would get squared off. I've addressed this in 77c425c.