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.

236 lines
5.7 KiB

7 months ago
  1. // Notes on the classes:
  2. //
  3. // 1. .carousel.pointer-event should ideally be pan-y (to allow for users to scroll vertically)
  4. // even when their scroll action started on a carousel, but for compatibility (with Firefox)
  5. // we're preventing all actions instead
  6. // 2. The .carousel-item-start and .carousel-item-end is used to indicate where
  7. // the active slide is heading.
  8. // 3. .active.carousel-item is the current slide.
  9. // 4. .active.carousel-item-start and .active.carousel-item-end is the current
  10. // slide in its in-transition state. Only one of these occurs at a time.
  11. // 5. .carousel-item-next.carousel-item-start and .carousel-item-prev.carousel-item-end
  12. // is the upcoming slide in transition.
  13. .carousel {
  14. position: relative;
  15. }
  16. .carousel.pointer-event {
  17. touch-action: pan-y;
  18. }
  19. .carousel-inner {
  20. position: relative;
  21. width: 100%;
  22. overflow: hidden;
  23. @include clearfix();
  24. }
  25. .carousel-item {
  26. position: relative;
  27. display: none;
  28. float: left;
  29. width: 100%;
  30. margin-right: -100%;
  31. backface-visibility: hidden;
  32. @include transition($carousel-transition);
  33. }
  34. .carousel-item.active,
  35. .carousel-item-next,
  36. .carousel-item-prev {
  37. display: block;
  38. }
  39. .carousel-item-next:not(.carousel-item-start),
  40. .active.carousel-item-end {
  41. transform: translateX(100%);
  42. }
  43. .carousel-item-prev:not(.carousel-item-end),
  44. .active.carousel-item-start {
  45. transform: translateX(-100%);
  46. }
  47. //
  48. // Alternate transitions
  49. //
  50. .carousel-fade {
  51. .carousel-item {
  52. opacity: 0;
  53. transition-property: opacity;
  54. transform: none;
  55. }
  56. .carousel-item.active,
  57. .carousel-item-next.carousel-item-start,
  58. .carousel-item-prev.carousel-item-end {
  59. z-index: 1;
  60. opacity: 1;
  61. }
  62. .active.carousel-item-start,
  63. .active.carousel-item-end {
  64. z-index: 0;
  65. opacity: 0;
  66. @include transition(opacity 0s $carousel-transition-duration);
  67. }
  68. }
  69. //
  70. // Left/right controls for nav
  71. //
  72. .carousel-control-prev,
  73. .carousel-control-next {
  74. position: absolute;
  75. top: 0;
  76. bottom: 0;
  77. z-index: 1;
  78. // Use flex for alignment (1-3)
  79. display: flex; // 1. allow flex styles
  80. align-items: center; // 2. vertically center contents
  81. justify-content: center; // 3. horizontally center contents
  82. width: $carousel-control-width;
  83. padding: 0;
  84. color: $carousel-control-color;
  85. text-align: center;
  86. background: none;
  87. border: 0;
  88. opacity: $carousel-control-opacity;
  89. @include transition($carousel-control-transition);
  90. // Hover/focus state
  91. &:hover,
  92. &:focus {
  93. color: $carousel-control-color;
  94. text-decoration: none;
  95. outline: 0;
  96. opacity: $carousel-control-hover-opacity;
  97. }
  98. }
  99. .carousel-control-prev {
  100. left: 0;
  101. background-image: if($enable-gradients, linear-gradient(90deg, rgba($black, .25), rgba($black, .001)), null);
  102. }
  103. .carousel-control-next {
  104. right: 0;
  105. background-image: if($enable-gradients, linear-gradient(270deg, rgba($black, .25), rgba($black, .001)), null);
  106. }
  107. // Icons for within
  108. .carousel-control-prev-icon,
  109. .carousel-control-next-icon {
  110. display: inline-block;
  111. width: $carousel-control-icon-width;
  112. height: $carousel-control-icon-width;
  113. background-repeat: no-repeat;
  114. background-position: 50%;
  115. background-size: 100% 100%;
  116. }
  117. .carousel-control-prev-icon {
  118. background-image: escape-svg($carousel-control-prev-icon-bg) #{"/*rtl:" + escape-svg($carousel-control-next-icon-bg) + "*/"};
  119. }
  120. .carousel-control-next-icon {
  121. background-image: escape-svg($carousel-control-next-icon-bg) #{"/*rtl:" + escape-svg($carousel-control-prev-icon-bg) + "*/"};
  122. }
  123. // Optional indicator pips/controls
  124. //
  125. // Add a container (such as a list) with the following class and add an item (ideally a focusable control,
  126. // like a button) with data-bs-target for each slide your carousel holds.
  127. .carousel-indicators {
  128. position: absolute;
  129. right: 0;
  130. bottom: 0;
  131. left: 0;
  132. z-index: 2;
  133. display: flex;
  134. justify-content: center;
  135. padding: 0;
  136. // Use the .carousel-control's width as margin so we don't overlay those
  137. margin-right: $carousel-control-width;
  138. margin-bottom: 1rem;
  139. margin-left: $carousel-control-width;
  140. [data-bs-target] {
  141. box-sizing: content-box;
  142. flex: 0 1 auto;
  143. width: $carousel-indicator-width;
  144. height: $carousel-indicator-height;
  145. padding: 0;
  146. margin-right: $carousel-indicator-spacer;
  147. margin-left: $carousel-indicator-spacer;
  148. text-indent: -999px;
  149. cursor: pointer;
  150. background-color: $carousel-indicator-active-bg;
  151. background-clip: padding-box;
  152. border: 0;
  153. // Use transparent borders to increase the hit area by 10px on top and bottom.
  154. border-top: $carousel-indicator-hit-area-height solid transparent;
  155. border-bottom: $carousel-indicator-hit-area-height solid transparent;
  156. opacity: $carousel-indicator-opacity;
  157. @include transition($carousel-indicator-transition);
  158. }
  159. .active {
  160. opacity: $carousel-indicator-active-opacity;
  161. }
  162. }
  163. // Optional captions
  164. //
  165. //
  166. .carousel-caption {
  167. position: absolute;
  168. right: (100% - $carousel-caption-width) * .5;
  169. bottom: $carousel-caption-spacer;
  170. left: (100% - $carousel-caption-width) * .5;
  171. padding-top: $carousel-caption-padding-y;
  172. padding-bottom: $carousel-caption-padding-y;
  173. color: $carousel-caption-color;
  174. text-align: center;
  175. }
  176. // Dark mode carousel
  177. @mixin carousel-dark() {
  178. .carousel-control-prev-icon,
  179. .carousel-control-next-icon {
  180. filter: $carousel-dark-control-icon-filter;
  181. }
  182. .carousel-indicators [data-bs-target] {
  183. background-color: $carousel-dark-indicator-active-bg;
  184. }
  185. .carousel-caption {
  186. color: $carousel-dark-caption-color;
  187. }
  188. }
  189. .carousel-dark {
  190. @include carousel-dark();
  191. }
  192. @if $enable-dark-mode {
  193. @include color-mode(dark) {
  194. @if $color-mode-type == "media-query" {
  195. .carousel {
  196. @include carousel-dark();
  197. }
  198. } @else {
  199. .carousel,
  200. &.carousel {
  201. @include carousel-dark();
  202. }
  203. }
  204. }
  205. }