Skip to content

Commit

Permalink
add .outline-fix class for .btn-group
Browse files Browse the repository at this point in the history
This class replaces bootstraps default strategy of using negative margins to hide double borders with specific css-selectors that hide and show specific borders.
  • Loading branch information
fekoch committed Jan 22, 2024
1 parent 0b2b04a commit 2f27865
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<input type="hidden" name="answer_id" value="{{ answer.id }}" />

<div class="btn-group btn-group-sm" role="group">
<div class="btn-group btn-group-sm outline-fix" role="group">
<input type="radio" class="btn-check" name="action" value="publish" id="{{ answer.id }}-radio-publish" autocomplete="off" {% if answer.will_be_public %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-publish">{% trans 'Publish' %}</label>

Expand Down
22 changes: 22 additions & 0 deletions evap/static/scss/components/_button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,25 @@ div.vote-inputs > textarea {
div.vote-inputs label.choice-error {
border-color: $evap-red;
}

// Change .btn-group outlined border style to fix double borders with outlined button style
// see https://github.com/twbs/bootstrap/issues/25888
.btn-group.outline-fix {

// If .btn is not the last element in the group, remove the right border.
// Also uses :has to not remove the right border if the next element is a disabled input
.btn:not(:last-child):not(.dropdown-toggle):has(+ :not(.btn-check[disabled])), .btn-group:not(:last-child) > .btn {
border-right: 0;
}

// Explicitly disable the left border of disabled .btn's to use the right border of the previous button.
.btn-check[disabled] + .btn {
border-left: 0;
}

// Revert Bootstrap (Prevent double borders when buttons are next to each other)
> :not(.btn-check:first-child) + .btn,
> .btn-group:not(:first-child) {
margin-left: unset;
}
}

0 comments on commit 2f27865

Please sign in to comment.