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.

197 lines
6.7 KiB

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