carousel.scss 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. @use 'mixins/mixins' as *;
  2. @use 'mixins/var' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'common/var' as *;
  5. @include b(carousel) {
  6. @include set-component-css-var('carousel', $carousel);
  7. position: relative;
  8. @include m(horizontal) {
  9. overflow: hidden;
  10. }
  11. @include m(vertical) {
  12. overflow: hidden;
  13. }
  14. @include e(container) {
  15. position: relative;
  16. height: 300px;
  17. }
  18. @include e(arrow) {
  19. border: none;
  20. outline: none;
  21. padding: 0;
  22. margin: 0;
  23. height: getCssVar('carousel', 'arrow-size');
  24. width: getCssVar('carousel', 'arrow-size');
  25. cursor: pointer;
  26. transition: getCssVar('transition', 'duration');
  27. border-radius: 50%;
  28. background-color: getCssVar('carousel', 'arrow-background');
  29. color: $color-white;
  30. position: absolute;
  31. top: 50%;
  32. z-index: 10;
  33. transform: translateY(-50%);
  34. text-align: center;
  35. font-size: getCssVar('carousel', 'arrow-font-size');
  36. @include utils-inline-flex-center;
  37. @include m(left) {
  38. left: 16px;
  39. }
  40. @include m(right) {
  41. right: 16px;
  42. }
  43. &:hover {
  44. background-color: getCssVar('carousel', 'arrow-hover-background');
  45. }
  46. & i {
  47. cursor: pointer;
  48. }
  49. }
  50. @include e(indicators) {
  51. position: absolute;
  52. list-style: none;
  53. margin: 0;
  54. padding: 0;
  55. z-index: calc(#{getCssVar('index-normal')} + 1);
  56. @include m(horizontal) {
  57. bottom: 0;
  58. left: 50%;
  59. transform: translateX(-50%);
  60. }
  61. @include m(vertical) {
  62. right: 0;
  63. top: 50%;
  64. transform: translateY(-50%);
  65. }
  66. @include m(outside) {
  67. bottom: calc(
  68. getCssVar('carousel-indicator-height') +
  69. getCssVar('carousel-indicator-padding-vertical') * 2
  70. );
  71. text-align: center;
  72. position: static;
  73. transform: none;
  74. .#{$namespace}-carousel__indicator:hover button {
  75. opacity: 0.64;
  76. }
  77. button {
  78. background-color: getCssVar('carousel', 'indicator-out-color');
  79. opacity: 0.24;
  80. }
  81. }
  82. @include m(right) {
  83. right: 0;
  84. }
  85. @include m(labels) {
  86. left: 0;
  87. right: 0;
  88. transform: none;
  89. text-align: center;
  90. .#{$namespace}-carousel__button {
  91. height: auto;
  92. width: auto;
  93. padding: 2px 18px;
  94. font-size: 12px;
  95. color: $color-black;
  96. }
  97. .#{$namespace}-carousel__indicator {
  98. padding: 6px 4px;
  99. }
  100. }
  101. }
  102. @include e(indicator) {
  103. background-color: transparent;
  104. cursor: pointer;
  105. &:hover button {
  106. opacity: 0.72;
  107. }
  108. @include m(horizontal) {
  109. display: inline-block;
  110. padding: getCssVar('carousel-indicator-padding-vertical')
  111. getCssVar('carousel-indicator-padding-horizontal');
  112. }
  113. @include m(vertical) {
  114. padding: getCssVar('carousel-indicator-padding-horizontal')
  115. getCssVar('carousel-indicator-padding-vertical');
  116. .#{$namespace}-carousel__button {
  117. width: getCssVar('carousel-indicator-height');
  118. height: calc(#{getCssVar('carousel-indicator-width')} / 2);
  119. }
  120. }
  121. @include when(active) {
  122. button {
  123. opacity: 1;
  124. }
  125. }
  126. }
  127. @include e(button) {
  128. display: block;
  129. opacity: 0.48;
  130. width: getCssVar('carousel-indicator-width');
  131. height: getCssVar('carousel-indicator-height');
  132. background-color: $color-white;
  133. border: none;
  134. outline: none;
  135. padding: 0;
  136. margin: 0;
  137. cursor: pointer;
  138. transition: getCssVar('transition-duration');
  139. }
  140. }
  141. .carousel-arrow-left-enter-from,
  142. .carousel-arrow-left-leave-active {
  143. transform: translateY(-50%) translateX(-10px);
  144. opacity: 0;
  145. }
  146. .carousel-arrow-right-enter-from,
  147. .carousel-arrow-right-leave-active {
  148. transform: translateY(-50%) translateX(10px);
  149. opacity: 0;
  150. }
  151. .#{$namespace}-transitioning {
  152. filter: url('#elCarouselHorizontal');
  153. }
  154. .#{$namespace}-transitioning-vertical {
  155. filter: url('#elCarouselVertical');
  156. }