Skip to content

Commit

Permalink
feat(accordions): dark variant accordions (#1025)
Browse files Browse the repository at this point in the history
Co-authored-by: Louis-Maxime Piton <louismaxime.piton@orange.com>
Co-authored-by: Julien Déramond <julien.deramond@orange.com>
  • Loading branch information
louismaximepiton and julien-deramond authored Feb 14, 2022
1 parent 8302566 commit 6f9f286
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"path": "./dist/css/boosted.min.css",
"maxSize": "27.0 kB"
"maxSize": "27.1 kB"
},
{
"path": "./dist/js/boosted.bundle.js",
Expand Down
34 changes: 32 additions & 2 deletions scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
position: relative;
display: flex;
align-items: center;
width: add(100%, $accordion-button-padding-x * 2);
width: 100%;
padding: $accordion-button-padding-y $accordion-button-padding-x;
margin: 0 -#{$accordion-button-padding-x}; // Boosted mod
@include font-size($accordion-button-font-size); // Boosted mod
font-weight: $accordion-button-font-weight; // Boosted mod
line-height: $accordion-button-line-height; // Boosted mod
Expand Down Expand Up @@ -114,3 +113,34 @@
letter-spacing: $accordion-button-letter-spacing-lg;
}
}

// Boosted mod
.accordion-dark {
.accordion-button {
color: $accordion-dark-button-color;
background-color: $accordion-dark-button-bg;

&:not(.collapsed) {
color: $accordion-dark-button-active-color;
}

&:hover {
color: $accordion-dark-button-active-color;
}
}

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

.accordion-item {
color: $accordion-dark-color;
background-color: $accordion-dark-bg;

&:last-of-type {
border-bottom: $accordion-border-width solid $accordion-dark-border-color;
}
}
}
// End mod
25 changes: 17 additions & 8 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1404,25 +1404,34 @@ $card-footer-color: $gray-700 !default; // Boosted mod
// Accordion

// scss-docs-start accordion-variables
$accordion-padding-y: $spacer * .5 !default;
$accordion-padding-x: $spacer * .5 !default;
$accordion-padding-y: $spacer * .5 !default; // Boosted mod
$accordion-padding-x: 0 !default; // Boosted mod
$accordion-color: $body-color !default;
$accordion-bg: $body-bg !default;
$accordion-border-width: $border-width * .5 !default;
$accordion-border-color: $gray-500 !default;
$accordion-border-width: $border-width * .5 !default; // Boosted mod
$accordion-border-color: $gray-500 !default; // Boosted mod
$accordion-border-radius: $border-radius !default;
$accordion-inner-border-radius: subtract($accordion-border-radius, $accordion-border-width) !default;

$accordion-body-padding-y: $spacer !default;
$accordion-body-padding-x: $spacer !default;
$accordion-body-padding-y: $spacer !default; // Boosted mod
$accordion-body-padding-x: $spacer !default; // Boosted mod

$accordion-button-padding-y: $accordion-padding-y !default;
$accordion-button-padding-x: $accordion-padding-x !default;
$accordion-button-color: $accordion-color !default;
$accordion-button-bg: $accordion-bg !default;
$accordion-transition: $btn-transition, border-radius .15s ease !default;
$accordion-button-active-bg: null !default;
$accordion-button-active-color: $accessible-orange !default;
$accordion-button-active-bg: null !default; // Boosted mod
$accordion-button-active-color: $accessible-orange !default; // Boosted mod

// Boosted mod: dark variant
$accordion-dark-color: $white !default;
$accordion-dark-bg: $black !default;
$accordion-dark-border-color: $gray-700 !default;
$accordion-dark-button-color: $accordion-dark-color !default;
$accordion-dark-button-bg: $accordion-dark-bg !default;
$accordion-dark-button-active-color: $brand-orange !default;
// End mod

// Boosted mod: no $accordion-button-focus-*

Expand Down
45 changes: 45 additions & 0 deletions site/content/docs/5.1/components/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,51 @@ Omit the `data-bs-parent` attribute on each `.accordion-collapse` to make accord
</div>
{{< /example >}}

### Dark variant

Accordions come with a dark variant: `.accordion-dark`.

{{< example class="bg-dark" >}}
<div class="accordion accordion-dark" id="accordionPanelsDarkExample">
<div class="accordion-item">
<h2 class="accordion-header" id="panelsDark-headingOne">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsDark-collapseOne" aria-expanded="true" aria-controls="panelsDark-collapseOne">
Accordion Item #1
</button>
</h2>
<div id="panelsDark-collapseOne" class="accordion-collapse collapse show" aria-labelledby="panelsDark-headingOne" data-bs-parent="#accordionPanelsDarkExample">
<div class="accordion-body">
<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="panelsDark-headingTwo">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsDark-collapseTwo" aria-expanded="false" aria-controls="panelsDark-collapseTwo">
Accordion Item #2
</button>
</h2>
<div id="panelsDark-collapseTwo" class="accordion-collapse collapse" aria-labelledby="panelsDark-headingTwo" data-bs-parent="#accordionPanelsDarkExample">
<div class="accordion-body">
<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="panelsDark-headingThree">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsDark-collapseThree" aria-expanded="false" aria-controls="panelsDark-collapseThree">
Accordion Item #3
</button>
</h2>
<div id="panelsDark-collapseThree" class="accordion-collapse collapse" aria-labelledby="panelsDark-headingThree" data-bs-parent="#accordionPanelsDarkExample">
<div class="accordion-body">
<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</div>
</div>
</div>
</div>
{{< /example >}}

## Accessibility

Please read the [collapse accessibility section]({{< docsref "/components/collapse#accessibility" >}}) for more information.
Expand Down

0 comments on commit 6f9f286

Please sign in to comment.