diff options
| author | Mark Otto <[email protected]> | 2019-01-06 17:01:36 -0800 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-01-07 03:01:36 +0200 |
| commit | e6b1eefc7392478c4acedaebc3c6b27a47e586c4 (patch) | |
| tree | 72f9b8959bb5ce2cd3ea0a9ca5819ad5d79b830a | |
| parent | 42bed436e86103ba85e56ea76a1c6cc6d16218ba (diff) | |
| download | bootstrap-e6b1eefc7392478c4acedaebc3c6b27a47e586c4.tar.xz bootstrap-e6b1eefc7392478c4acedaebc3c6b27a47e586c4.zip | |
Add horizontal list group modifier (#27970)
Alternate take to #27683 that builds the modifier class based on min-width, such that list groups are stacked until the class's breakpoint is reached. This is less verbose, matches our primary responsive approach, and prevents an extra class. Unfortunately, I believe supporting flush list groups is too much code here, so I've skipped that and made a note in the docs.
Also added examples generate from our breakpoints data file with a protip for how to do equal width items.
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | scss/_list-group.scss | 33 | ||||
| -rw-r--r-- | scss/mixins/_border-radius.scss | 12 | ||||
| -rw-r--r-- | site/docs/4.2/assets/scss/_component-examples.scss | 3 | ||||
| -rw-r--r-- | site/docs/4.2/components/list-group.md | 16 |
5 files changed, 66 insertions, 2 deletions
diff --git a/package.json b/package.json index 6139ce331..2670085e6 100644 --- a/package.json +++ b/package.json @@ -174,11 +174,11 @@ }, { "path": "./dist/css/bootstrap.css", - "maxSize": "25 kB" + "maxSize": "25.5 kB" }, { "path": "./dist/css/bootstrap.min.css", - "maxSize": "22.7 kB" + "maxSize": "23.5 kB" }, { "path": "./dist/js/bootstrap.bundle.js", diff --git a/scss/_list-group.scss b/scss/_list-group.scss index 796cc461f..e688f959f 100644 --- a/scss/_list-group.scss +++ b/scss/_list-group.scss @@ -80,6 +80,39 @@ } +// Horizontal +// +// Change the layout of list group items from vertical (default) to horizontal. + +@each $breakpoint in map-keys($grid-breakpoints) { + @include media-breakpoint-up($breakpoint) { + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); + + @each $value in $displays { + .list-group-horizontal#{$infix} { + flex-direction: row; + + .list-group-item { + margin-right: -$list-group-border-width; + margin-bottom: 0; + + &:first-child { + @include border-left-radius($list-group-border-radius); + @include border-top-right-radius(0); + } + + &:last-child { + margin-right: 0; + @include border-right-radius($list-group-border-radius); + @include border-bottom-left-radius(0); + } + } + } + } + } +} + + // Flush list items // // Remove borders and border-radius to keep list group items edge-to-edge. Most diff --git a/scss/mixins/_border-radius.scss b/scss/mixins/_border-radius.scss index f32feca90..3dbc3a6cc 100644 --- a/scss/mixins/_border-radius.scss +++ b/scss/mixins/_border-radius.scss @@ -37,3 +37,15 @@ border-bottom-left-radius: $radius; } } + +@mixin border-top-right-radius($radius) { + @if $enable-rounded { + border-top-right-radius: $radius; + } +} + +@mixin border-bottom-left-radius($radius) { + @if $enable-rounded { + border-bottom-left-radius: $radius; + } +} diff --git a/site/docs/4.2/assets/scss/_component-examples.scss b/site/docs/4.2/assets/scss/_component-examples.scss index c50876420..ac65e128c 100644 --- a/site/docs/4.2/assets/scss/_component-examples.scss +++ b/site/docs/4.2/assets/scss/_component-examples.scss @@ -246,6 +246,9 @@ .bd-example > .list-group { max-width: 400px; } +.bd-example > [class*="list-group-horizontal"] { + max-width: 100%; +} // Navbars .bd-example { diff --git a/site/docs/4.2/components/list-group.md b/site/docs/4.2/components/list-group.md index d3becaefb..251dae672 100644 --- a/site/docs/4.2/components/list-group.md +++ b/site/docs/4.2/components/list-group.md @@ -100,6 +100,22 @@ Add `.list-group-flush` to remove some borders and rounded corners to render lis {% endcapture %} {% include example.html content=example %} +## Horizontal + +Add `.list-group-horizontal` to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant `.list-group-horizontal-{sm|md|lg|xl}` to make a list group horizontal starting at that breakpoint's `min-width`. Currently **horizontal list groups cannot be combined with flush list groups.** + +**ProTip:** Want equal-width list group items when horizontal? Add `.flex-fill` to each list group item. + +{% for bp in site.data.breakpoints %} +{% capture example %} +<ul class="list-group list-group-horizontal{{ bp.abbr }}"> + <li class="list-group-item">Cras justo odio</li> + <li class="list-group-item">Dapibus ac facilisis in</li> + <li class="list-group-item">Morbi leo risus</li> +</ul> +{% endcapture %} +{% include example.html content=example %}{% endfor %} + ## Contextual classes Use contextual classes to style list items with a stateful background and color. |
