From f228802fd0ea6914da982bdab7d8f9c9364d1bc3 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Wed, 28 Dec 2016 13:45:07 -0800 Subject: [PATCH] Revamp list group states and docs to match - Overhauls the states, including the link/button variants, for list groups to better match how we handle .btn states. - Moved the .list-group-item-action styles before the .list-group-item so that we don't have to do as much overriding. - Removed the plain-hover-focus mixins from the disabled and active states since they're unnecessary. - Added support for :active states on the .list-group-item-action variant (for the current click state). - Removed the heading and text classes and variables since we can accomplish the same thing with utilities. - Added support for :disabled on the .list-group-item-action as well since we can use those with button elements. - Rearranged docs to reflect all the above changes. - Reformatted some Sass variables. --- docs/components/list-group.md | 89 ++++++++++++++---------- scss/_list-group.scss | 127 +++++++++++++++++----------------- scss/_variables.scss | 35 +++++----- 3 files changed, 133 insertions(+), 118 deletions(-) diff --git a/docs/components/list-group.md b/docs/components/list-group.md index 0e06d3a7f2..3def6e7923 100644 --- a/docs/components/list-group.md +++ b/docs/components/list-group.md @@ -5,7 +5,7 @@ description: Learn about Bootstrap's list group component for rendering series o group: components --- -List groups are a flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content. +List groups are a flexible and powerful component for displaying a series of content. List group items can be modified and extended to support just about any content within. They can also be used as navigation with the right modifier class. ## Contents @@ -13,7 +13,7 @@ List groups are a flexible and powerful component for displaying not only simple {:toc} ## Basic example -The most basic list group is simply an unordered list with list items, and the proper classes. Build upon it with the options that follow, or your own CSS as needed. +The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed. {% example html %} {% endexample %} -## Badge +## Active items -Add badges to any list group item to show unread counts, activity, and more with the help of some utilities. Note the [`justify-content-between` utility class]({{ site.baseurl }}/layout/grid/#horizontal-alignment), the badge's placement, and the lack of a float and margin utilities on the badges. +Add `.active` to a `.list-group-item` to indicate the current active selection. -{% highlight html %} +{% example html %} -{% endhighlight %} - +{% endexample %} ## Disabled items -Add `.disabled` to a `.list-group-item` to gray it out to appear disabled. +Add `.disabled` to a `.list-group-item` to make it _appear_ disabled. Note that some elements with `.disabled` will also require custom JavaScript to fully disable their click events (e.g., links). {% example html %} -
- - Cras justo odio - - Dapibus ac facilisis in - Morbi leo risus - Porta ac consectetur ac - Vestibulum at eros -
+ {% endexample %} -## Anchors and buttons +## Links and buttons -Use anchors or buttons to create actionable list group items with hover, disabled, and active states by adding `.list-group-item-action`. This separate class contains a few overrides to add compatibility for ``s and ` - + {% endexample %} @@ -109,6 +101,27 @@ Use contextual classes to style list items, default or linked. Also includes `.a {% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} {{ callout-include | markdownify }} +## With badges + +Add badges to any list group item to show unread counts, activity, and more with the help of some utilities. Note the [`justify-content-between` utility class]({{ site.baseurl }}/layout/grid/#horizontal-alignment) and the badge's placement. + +{% example html %} + +{% endexample %} + ## Custom content Add nearly any HTML within, even for linked list groups like the one below. @@ -116,16 +129,16 @@ Add nearly any HTML within, even for linked list groups like the one below. {% example html %}
-
List group item heading
-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

+
List group item heading
+ Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
-
List group item heading
-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

+
List group item heading
+ Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
-
List group item heading
-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

+
List group item heading
+ Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
{% endexample %} diff --git a/scss/_list-group.scss b/scss/_list-group.scss index 4d78d95c0e..ec813c807e 100644 --- a/scss/_list-group.scss +++ b/scss/_list-group.scss @@ -12,6 +12,34 @@ } +// Interactive list items +// +// Use anchor or button elements instead of `li`s or `div`s to create interactive +// list items. Includes an extra `.active` modifier class for selected items. + +.list-group-item-action { + width: 100%; // For `