carousel.scss 3.7 KB

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