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

Revamp accordion borders to fix pixel jumping #33149

Merged
merged 3 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 19 additions & 32 deletions scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
color: $accordion-button-color;
text-align: left; // Reset button style
background-color: $accordion-button-bg;
border: $accordion-border-width solid $accordion-border-color;
border: 0;
@include border-radius(0);
overflow-anchor: none;
@include transition($accordion-transition);

&.collapsed {
border-bottom-width: 0;
}

&:not(.collapsed) {
color: $accordion-button-active-color;
background-color: $accordion-button-active-bg;
box-shadow: inset 0 ($accordion-border-width * -1) 0 $accordion-border-color;

&::after {
background-image: escape-svg($accordion-button-active-icon);
Expand Down Expand Up @@ -61,33 +58,35 @@
}

.accordion-item {
margin-bottom: -$accordion-border-width;
background-color: $accordion-bg;
border: $accordion-border-width solid $accordion-border-color;

&:first-of-type {
@include border-top-radius($accordion-border-radius);

.accordion-button {
@include border-top-radius($accordion-border-radius);
@include border-top-radius($accordion-inner-border-radius);
}
}

// Only set a border-radius on the last item if the accordion is collapsed
&:last-of-type {
margin-bottom: 0;
@include border-bottom-radius($accordion-border-radius);

.accordion-button {
// Only set a border-radius on the last item if the accordion is collapsed
&.collapsed {
border-bottom-width: $accordion-border-width;
@include border-bottom-radius($accordion-border-radius);
@include border-bottom-radius($accordion-inner-border-radius);
}
}

.accordion-collapse {
border-bottom-width: $accordion-border-width;
@include border-bottom-radius($accordion-border-radius);
}
}
}

.accordion-collapse {
border: solid $accordion-border-color;
border-width: 0 $accordion-border-width;
}

.accordion-body {
padding: $accordion-body-padding-y $accordion-body-padding-x;
}
Expand All @@ -98,29 +97,17 @@
// Remove borders and border-radius to keep accordion items edge-to-edge.

.accordion-flush {
.accordion-button {
border-right: 0;
border-left: 0;
@include border-radius(0);
}

.accordion-collapse {
border-width: 0;
}

.accordion-item {
&:first-of-type {
.accordion-button {
border-top-width: 0;
@include border-top-radius(0);
}
}
@include border-radius(0);

&:last-of-type {
.accordion-button.collapsed {
border-bottom-width: 0;
@include border-bottom-radius(0);
}
.accordion-button {
border-right: 0;
border-left: 0;
@include border-radius(0);
}
}
}
3 changes: 2 additions & 1 deletion scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,11 @@ $card-group-margin: $grid-gutter-width / 2 !default;
$accordion-padding-y: 1rem !default;
$accordion-padding-x: 1.25rem !default;
$accordion-color: $body-color !default;
$accordion-bg: transparent !default;
$accordion-bg: $body-bg !default;
$accordion-border-width: $border-width !default;
$accordion-border-color: rgba($black, .125) !default;
$accordion-border-radius: $border-radius !default;
$accordion-inner-border-radius: subtract($accordion-border-radius, $accordion-border-width) !default;

$accordion-body-padding-y: $accordion-padding-y !default;
$accordion-body-padding-x: $accordion-padding-x !default;
Expand Down