Skip to content

Commit

Permalink
Update horizontal collapse class to .collapse-horizontal
Browse files Browse the repository at this point in the history
  • Loading branch information
mdo committed Jun 23, 2021
1 parent c1e54df commit 3026c26
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 53 deletions.
3 changes: 2 additions & 1 deletion js/dist/collapse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/collapse.js.map

Large diffs are not rendered by default.

66 changes: 20 additions & 46 deletions js/dist/scrollspy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/scrollspy.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const CLASS_NAME_SHOW = 'show'
const CLASS_NAME_COLLAPSE = 'collapse'
const CLASS_NAME_COLLAPSING = 'collapsing'
const CLASS_NAME_COLLAPSED = 'collapsed'
const CLASS_NAME_WIDTH = 'collapse-horizontal'

const WIDTH = 'width'
const HEIGHT = 'height'
Expand Down Expand Up @@ -266,7 +267,7 @@ class Collapse extends BaseComponent {
}

_getDimension() {
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT
return this._element.classList.contains(CLASS_NAME_WIDTH) ? WIDTH : HEIGHT
}

_getParent() {
Expand Down
2 changes: 1 addition & 1 deletion scss/_transitions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
overflow: hidden;
@include transition($transition-collapse);

&.width {
&.collapse-horizontal {
width: 0;
height: auto;
@include transition($transition-collapse-width);
Expand Down
4 changes: 2 additions & 2 deletions site/content/docs/5.0/components/collapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Generally, we recommend using a button with the `data-bs-target` attribute. Whil

## Horizontal

The collapse plugin also supports horizontal collapsing. Add the `.width` modifier class to transition the `width` instead of `height` and set a `width` on the immediate child element.
The collapse plugin also supports horizontal collapsing. Add the `.collapse-horizontal` modifier class to transition the `width` instead of `height` and set a `width` on the immediate child element.

{{< callout info >}}
Please note that while the example below has a `min-height` set to avoid excessive repaints in our docs, this is not explicitly required. **Only the `width` on the child element is required.**
Expand All @@ -55,7 +55,7 @@ Please note that while the example below has a `min-height` set to avoid excessi
</button>
</p>
<div style="min-height: 120px;">
<div class="collapse width" id="collapseWidthExample">
<div class="collapse collapse-horizontal" id="collapseWidthExample">
<div class="card card-body" style="width: 300px;">
This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
</div>
Expand Down

0 comments on commit 3026c26

Please sign in to comment.