You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.4 KiB

  1. // Base class
  2. //
  3. // Easily usable on <ul>, <ol>, or <div>.
  4. .list-group {
  5. display: flex;
  6. flex-direction: column;
  7. // No need to set list-style: none; since .list-group-item is block level
  8. padding-left: 0; // reset padding because ul and ol
  9. margin-bottom: 0;
  10. @include border-radius($list-group-border-radius);
  11. }
  12. .list-group-numbered {
  13. list-style-type: none;
  14. counter-reset: section;
  15. > li::before {
  16. // Increments only this instance of the section counter
  17. content: counters(section, ".") ". ";
  18. counter-increment: section;
  19. }
  20. }
  21. // Interactive list items
  22. //
  23. // Use anchor or button elements instead of `li`s or `div`s to create interactive
  24. // list items. Includes an extra `.active` modifier class for selected items.
  25. .list-group-item-action {
  26. width: 100%; // For `<button>`s (anchors become 100% by default though)
  27. color: $list-group-action-color;
  28. text-align: inherit; // For `<button>`s (anchors inherit)
  29. // Hover state
  30. &:hover,
  31. &:focus {
  32. z-index: 1; // Place hover/focus items above their siblings for proper border styling
  33. color: $list-group-action-hover-color;
  34. text-decoration: none;
  35. background-color: $list-group-hover-bg;
  36. }
  37. &:active {
  38. color: $list-group-action-active-color;
  39. background-color: $list-group-action-active-bg;
  40. }
  41. }
  42. // Individual list items
  43. //
  44. // Use on `li`s or `div`s within the `.list-group` parent.
  45. .list-group-item {
  46. position: relative;
  47. display: block;
  48. padding: $list-group-item-padding-y $list-group-item-padding-x;
  49. color: $list-group-color;
  50. text-decoration: if($link-decoration == none, null, none);
  51. background-color: $list-group-bg;
  52. border: $list-group-border-width solid $list-group-border-color;
  53. &:first-child {
  54. @include border-top-radius(inherit);
  55. }
  56. &:last-child {
  57. @include border-bottom-radius(inherit);
  58. }
  59. &.disabled,
  60. &:disabled {
  61. color: $list-group-disabled-color;
  62. pointer-events: none;
  63. background-color: $list-group-disabled-bg;
  64. }
  65. // Include both here for `<a>`s and `<button>`s
  66. &.active {
  67. z-index: 2; // Place active items above their siblings for proper border styling
  68. color: $list-group-active-color;
  69. background-color: $list-group-active-bg;
  70. border-color: $list-group-active-border-color;
  71. }
  72. & + & {
  73. border-top-width: 0;
  74. &.active {
  75. margin-top: -$list-group-border-width;
  76. border-top-width: $list-group-border-width;
  77. }
  78. }
  79. }
  80. // Horizontal
  81. //
  82. // Change the layout of list group items from vertical (default) to horizontal.
  83. @each $breakpoint in map-keys($grid-breakpoints) {
  84. @include media-breakpoint-up($breakpoint) {
  85. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  86. .list-group-horizontal#{$infix} {
  87. flex-direction: row;
  88. > .list-group-item {
  89. &:first-child {
  90. @include border-bottom-start-radius($list-group-border-radius);
  91. @include border-top-end-radius(0);
  92. }
  93. &:last-child {
  94. @include border-top-end-radius($list-group-border-radius);
  95. @include border-bottom-start-radius(0);
  96. }
  97. &.active {
  98. margin-top: 0;
  99. }
  100. + .list-group-item {
  101. border-top-width: $list-group-border-width;
  102. border-left-width: 0;
  103. &.active {
  104. margin-left: -$list-group-border-width;
  105. border-left-width: $list-group-border-width;
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. // Flush list items
  113. //
  114. // Remove borders and border-radius to keep list group items edge-to-edge. Most
  115. // useful within other components (e.g., cards).
  116. .list-group-flush {
  117. @include border-radius(0);
  118. > .list-group-item {
  119. border-width: 0 0 $list-group-border-width;
  120. &:last-child {
  121. border-bottom-width: 0;
  122. }
  123. }
  124. }
  125. // scss-docs-start list-group-modifiers
  126. // List group contextual variants
  127. //
  128. // Add modifier classes to change text and background color on individual items.
  129. // Organizationally, this must come after the `:hover` states.
  130. @each $state, $value in $theme-colors {
  131. $list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
  132. $list-group-variant-color: shift-color($value, $list-group-item-color-scale);
  133. @if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
  134. $list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
  135. }
  136. @include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
  137. }
  138. // scss-docs-end list-group-modifiers