diff options
| author | Mark Otto <[email protected]> | 2016-12-28 13:45:07 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-12-28 15:13:43 -0800 |
| commit | f228802fd0ea6914da982bdab7d8f9c9364d1bc3 (patch) | |
| tree | bd288a0bb20657d0b91b0c7c38f9297624eaf2fe /scss/_list-group.scss | |
| parent | 9ce5fb58178aadb3b1907d7005aadeb1ae63ba53 (diff) | |
| download | bootstrap-f228802fd0ea6914da982bdab7d8f9c9364d1bc3.tar.xz bootstrap-f228802fd0ea6914da982bdab7d8f9c9364d1bc3.zip | |
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.
Diffstat (limited to 'scss/_list-group.scss')
| -rw-r--r-- | scss/_list-group.scss | 131 |
1 files changed, 65 insertions, 66 deletions
diff --git a/scss/_list-group.scss b/scss/_list-group.scss index 4d78d95c0..ec813c807 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 `<button>`s (anchors become 100% by default though) + color: $list-group-link-color; + text-align: inherit; // For `<button>`s (anchors inherit) + + .list-group-item-heading { + color: $list-group-link-heading-color; + } + + // Hover state + @include hover-focus { + color: $list-group-link-hover-color; + text-decoration: none; + background-color: $list-group-hover-bg; + } + + &:active { + color: $list-group-link-active-color; + background-color: $list-group-link-active-bg; + } +} + + // Individual list items // // Use on `li`s or `div`s within the `.list-group` parent. @@ -36,43 +64,51 @@ @include border-bottom-radius($list-group-border-radius); } - &.disabled { - @include plain-hover-focus { - color: $list-group-disabled-color; - cursor: $cursor-disabled; - background-color: $list-group-disabled-bg; - - // Force color to inherit for custom content - .list-group-item-heading { - color: inherit; - } - .list-group-item-text { - color: $list-group-disabled-text-color; - } + @include hover-focus { + text-decoration: none; + } + + &.disabled, + &:disabled { + color: $list-group-disabled-color; + cursor: $cursor-disabled; + background-color: $list-group-disabled-bg; + + // Force color to inherit for custom content + .list-group-item-heading { + color: inherit; + } + .list-group-item-text { + color: $list-group-disabled-text-color; } } + // Include both here for `<a>`s and `<button>`s &.active { - @include plain-hover-focus { - z-index: 2; // Place active items above their siblings for proper border styling - color: $list-group-active-color; - text-decoration: none; // Repeat here because it inherits global a:hover otherwise - background-color: $list-group-active-bg; - border-color: $list-group-active-border; - - // Force color to inherit for custom content - .list-group-item-heading, - .list-group-item-heading > small, - .list-group-item-heading > .small { - color: inherit; - } - .list-group-item-text { - color: $list-group-active-text-color; - } + z-index: 2; // Place active items above their siblings for proper border styling + color: $list-group-active-color; + background-color: $list-group-active-bg; + border-color: $list-group-active-border; + + // Force color to inherit for custom content + .list-group-item-heading, + .list-group-item-heading > small, + .list-group-item-heading > .small { + color: inherit; + } + + .list-group-item-text { + color: $list-group-active-text-color; } } } + +// Flush list items +// +// Remove borders and border-radius to keep list group items edge-to-edge. Most +// useful within other components (e.g., cards). + .list-group-flush { .list-group-item { border-right: 0; @@ -94,29 +130,6 @@ } -// 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 `<button>`s (anchors become 100% by default though) - color: $list-group-link-color; - text-align: inherit; // For `<button>`s (anchors inherit) - - .list-group-item-heading { - color: $list-group-link-heading-color; - } - - // Hover state - @include hover-focus { - color: $list-group-link-hover-color; - text-decoration: none; - background-color: $list-group-hover-bg; - } -} - - // Contextual variants // // Add modifier classes to change text and background color on individual items. @@ -126,17 +139,3 @@ @include list-group-item-variant(info, $state-info-bg, $state-info-text); @include list-group-item-variant(warning, $state-warning-bg, $state-warning-text); @include list-group-item-variant(danger, $state-danger-bg, $state-danger-text); - - -// Custom content options -// -// Extra classes for creating well-formatted content within `.list-group-item`s. - -.list-group-item-heading { - margin-top: 0; - margin-bottom: $list-group-item-heading-margin-bottom; -} -.list-group-item-text { - margin-bottom: 0; - line-height: 1.3; -} |
