input-number.scss 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. @use 'sass:math';
  2. @use 'sass:map';
  3. @use 'mixins/mixins' as *;
  4. @use 'common/var' as *;
  5. @include b(input-number) {
  6. position: relative;
  7. display: inline-flex;
  8. width: map.get($input-number-width, 'default');
  9. line-height: #{map.get($input-height, 'default') - 2};
  10. vertical-align: middle;
  11. .#{$namespace}-input {
  12. &__wrapper {
  13. padding-left: #{map.get($input-height, 'default') + 10};
  14. padding-right: #{map.get($input-height, 'default') + 10};
  15. }
  16. &__inner {
  17. -webkit-appearance: none;
  18. -moz-appearance: textfield;
  19. text-align: center;
  20. line-height: 1;
  21. &::-webkit-inner-spin-button,
  22. &::-webkit-outer-spin-button {
  23. margin: 0;
  24. -webkit-appearance: none;
  25. }
  26. }
  27. }
  28. @include e((increase, decrease)) {
  29. display: flex;
  30. justify-content: center;
  31. align-items: center;
  32. height: auto;
  33. position: absolute;
  34. z-index: 1;
  35. top: 1px;
  36. bottom: 1px;
  37. width: map.get($input-height, 'default');
  38. background: getCssVar('fill-color', 'light');
  39. color: getCssVar('text-color', 'regular');
  40. cursor: pointer;
  41. font-size: 13px;
  42. user-select: none;
  43. &:hover {
  44. color: getCssVar('color-primary');
  45. & ~ .#{$namespace}-input:not(.is-disabled) .#{$namespace}-input__wrapper {
  46. box-shadow: 0 0 0 1px
  47. var(
  48. #{getCssVarName('input', 'focus-border-color')},
  49. map.get($input, 'focus-border-color')
  50. )
  51. inset;
  52. }
  53. }
  54. &.is-disabled {
  55. color: getCssVar('disabled-text-color');
  56. cursor: not-allowed;
  57. }
  58. }
  59. @include e(increase) {
  60. right: 1px;
  61. border-radius: 0 getCssVar('border-radius-base')
  62. getCssVar('border-radius-base') 0;
  63. border-left: getCssVar('border');
  64. }
  65. @include e(decrease) {
  66. left: 1px;
  67. border-radius: getCssVar('border-radius-base') 0 0
  68. getCssVar('border-radius-base');
  69. border-right: getCssVar('border');
  70. }
  71. @include when(disabled) {
  72. @include e((increase, decrease)) {
  73. border-color: getCssVar('disabled-border-color');
  74. color: getCssVar('disabled-border-color');
  75. &:hover {
  76. color: getCssVar('disabled-border-color');
  77. cursor: not-allowed;
  78. }
  79. }
  80. }
  81. @each $size in (large, small) {
  82. @include m($size) {
  83. width: map.get($input-number-width, $size);
  84. line-height: #{map.get($input-height, $size) - 2};
  85. @include e((increase, decrease)) {
  86. width: map.get($input-height, $size);
  87. font-size: map.get($input-font-size, $size);
  88. }
  89. .#{$namespace}-input--#{$size} {
  90. .#{$namespace}-input__wrapper {
  91. padding-left: #{map.get($input-height, $size) + 7};
  92. padding-right: #{map.get($input-height, $size) + 7};
  93. }
  94. }
  95. }
  96. }
  97. @include m(small) {
  98. @include e((increase, decrease)) {
  99. [class*='#{$namespace}-icon'] {
  100. transform: scale(0.9);
  101. }
  102. }
  103. }
  104. @include when(without-controls) {
  105. .#{$namespace}-input__wrapper {
  106. padding-left: 15px;
  107. padding-right: 15px;
  108. }
  109. }
  110. @include when(controls-right) {
  111. .#{$namespace}-input__wrapper {
  112. padding-left: 15px;
  113. padding-right: #{map.get($input-height, 'default') + 10};
  114. }
  115. @include e((increase, decrease)) {
  116. @include set-css-var-value(
  117. ('input', 'number-controls-height'),
  118. math.div(map.get($input-height, 'default') - 2, 2)
  119. );
  120. height: getCssVar('input-number-controls-height');
  121. line-height: getCssVar('input-number-controls-height');
  122. [class*='#{$namespace}-icon'] {
  123. transform: scale(0.8);
  124. }
  125. }
  126. @include e(increase) {
  127. bottom: auto;
  128. left: auto;
  129. border-radius: 0 getCssVar('border-radius-base') 0 0;
  130. border-bottom: getCssVar('border');
  131. }
  132. @include e(decrease) {
  133. right: 1px;
  134. top: auto;
  135. left: auto;
  136. border-right: none;
  137. border-left: getCssVar('border');
  138. border-radius: 0 0 getCssVar('border-radius-base') 0;
  139. }
  140. @each $size in (large, small) {
  141. &[class*='#{$size}'] {
  142. [class*='increase'],
  143. [class*='decrease'] {
  144. @include set-css-var-value(
  145. ('input', 'number-controls-height'),
  146. math.div(map.get($input-height, $size) - 2, 2)
  147. );
  148. }
  149. }
  150. }
  151. }
  152. }