input-number.scss 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. @include when(controls-right) {
  90. .#{$namespace}-input--#{$size} {
  91. .#{$namespace}-input__wrapper {
  92. padding-right: #{map.get($input-height, $size) + 7};
  93. }
  94. }
  95. }
  96. .#{$namespace}-input--#{$size} {
  97. .#{$namespace}-input__wrapper {
  98. padding-left: #{map.get($input-height, $size) + 7};
  99. padding-right: #{map.get($input-height, $size) + 7};
  100. }
  101. }
  102. }
  103. }
  104. @include m(small) {
  105. @include e((increase, decrease)) {
  106. [class*='#{$namespace}-icon'] {
  107. transform: scale(0.9);
  108. }
  109. }
  110. }
  111. @include when(without-controls) {
  112. .#{$namespace}-input__wrapper {
  113. padding-left: 15px;
  114. padding-right: 15px;
  115. }
  116. }
  117. @include when(controls-right) {
  118. .#{$namespace}-input__wrapper {
  119. padding-left: 15px;
  120. padding-right: #{map.get($input-height, 'default') + 10};
  121. }
  122. @include e((increase, decrease)) {
  123. @include set-css-var-value(
  124. ('input', 'number-controls-height'),
  125. math.div(map.get($input-height, 'default') - 2, 2)
  126. );
  127. height: getCssVar('input-number-controls-height');
  128. line-height: getCssVar('input-number-controls-height');
  129. [class*='#{$namespace}-icon'] {
  130. transform: scale(0.8);
  131. }
  132. }
  133. @include e(increase) {
  134. bottom: auto;
  135. left: auto;
  136. border-radius: 0 getCssVar('border-radius-base') 0 0;
  137. border-bottom: getCssVar('border');
  138. }
  139. @include e(decrease) {
  140. right: 1px;
  141. top: auto;
  142. left: auto;
  143. border-right: none;
  144. border-left: getCssVar('border');
  145. border-radius: 0 0 getCssVar('border-radius-base') 0;
  146. }
  147. @each $size in (large, small) {
  148. &[class*='#{$size}'] {
  149. [class*='increase'],
  150. [class*='decrease'] {
  151. @include set-css-var-value(
  152. ('input', 'number-controls-height'),
  153. math.div(map.get($input-height, $size) - 2, 2)
  154. );
  155. }
  156. }
  157. }
  158. }
  159. }