8
0

form.scss 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'mixins/var' as *;
  5. @use 'common/var' as *;
  6. $form-item-margin-bottom: () !default;
  7. $form-item-margin-bottom: map.merge(
  8. (
  9. 'large': 22px,
  10. 'default': 18px,
  11. 'small': 18px,
  12. ),
  13. $form-item-margin-bottom
  14. );
  15. $form-item-line-height: () !default;
  16. $form-item-line-height: map.merge(
  17. (
  18. 'large': 40px,
  19. 'default': 32px,
  20. 'small': 24px,
  21. ),
  22. $form-item-line-height
  23. );
  24. $form-item-error-padding-top: () !default;
  25. $form-item-error-padding-top: map.merge(
  26. (
  27. 'large': 4px,
  28. 'default': 2px,
  29. 'small': 2px,
  30. ),
  31. $form-item-error-padding-top
  32. );
  33. $form-item-label-top-line-height: () !default;
  34. $form-item-label-top-line-height: map.merge(
  35. (
  36. 'large': 22px,
  37. 'default': 22px,
  38. 'small': 20px,
  39. ),
  40. $form-item-label-top-line-height
  41. );
  42. $form-item-label-top-margin-bottom: () !default;
  43. $form-item-label-top-margin-bottom: map.merge(
  44. (
  45. 'large': 12px,
  46. 'default': 8px,
  47. 'small': 4px,
  48. ),
  49. $form-item-label-top-margin-bottom
  50. );
  51. @include b(form) {
  52. @include set-component-css-var('form', $form);
  53. @include m(inline) {
  54. .#{$namespace}-form-item {
  55. display: inline-flex;
  56. vertical-align: middle;
  57. margin-right: 32px;
  58. }
  59. &.#{$namespace}-form--label-top {
  60. display: flex;
  61. flex-wrap: wrap;
  62. .#{$namespace}-form-item {
  63. display: block;
  64. }
  65. }
  66. }
  67. }
  68. @include b(form-item) {
  69. display: flex;
  70. --font-size: #{map.get($input-font-size, 'default')};
  71. margin-bottom: #{map.get($form-item-margin-bottom, 'default')};
  72. .#{$namespace}-form-item {
  73. margin-bottom: 0;
  74. }
  75. .#{$namespace}-input__validateIcon {
  76. display: none;
  77. }
  78. @each $size in (large, default, small) {
  79. @include m($size) {
  80. --font-size: #{map.get($input-font-size, $size)};
  81. @include set-css-var-value(('form', 'label-font-size'), var(--font-size));
  82. margin-bottom: #{map.get($form-item-margin-bottom, $size)};
  83. @include e(label) {
  84. height: #{map.get($form-item-line-height, $size)};
  85. line-height: #{map.get($form-item-line-height, $size)};
  86. }
  87. @include e(content) {
  88. line-height: #{map.get($form-item-line-height, $size)};
  89. }
  90. @include e(error) {
  91. padding-top: #{map.get($form-item-error-padding-top, $size)};
  92. }
  93. }
  94. }
  95. @include m(label-left) {
  96. .#{$namespace}-form-item__label {
  97. justify-content: flex-start;
  98. }
  99. }
  100. @include m(label-top) {
  101. display: block;
  102. .#{$namespace}-form-item__label {
  103. display: inline-block;
  104. vertical-align: middle;
  105. height: auto;
  106. text-align: left;
  107. margin-bottom: #{map.get($form-item-label-top-margin-bottom, 'default')};
  108. line-height: #{map.get($form-item-label-top-line-height, 'default')};
  109. }
  110. }
  111. @include e(label-wrap) {
  112. display: flex;
  113. }
  114. @include e(label) {
  115. display: inline-flex;
  116. justify-content: flex-end;
  117. align-items: flex-start;
  118. flex: 0 0 auto;
  119. font-size: getCssVar('form-label-font-size');
  120. color: getCssVar('text-color', 'regular');
  121. height: #{map.get($form-item-line-height, 'default')};
  122. line-height: #{map.get($form-item-line-height, 'default')};
  123. padding: 0 12px 0 0;
  124. box-sizing: border-box;
  125. }
  126. @include e(content) {
  127. display: flex;
  128. flex-wrap: wrap;
  129. align-items: center;
  130. flex: 1;
  131. line-height: #{map.get($form-item-line-height, 'default')};
  132. position: relative;
  133. font-size: var(--font-size);
  134. min-width: 0;
  135. .#{$namespace}-input-group {
  136. vertical-align: top;
  137. }
  138. }
  139. @include e(error) {
  140. color: getCssVar('color-danger');
  141. font-size: 12px;
  142. line-height: 1;
  143. padding-top: #{map.get($form-item-error-padding-top, 'default')};
  144. position: absolute;
  145. top: 100%;
  146. left: 0;
  147. @include m(inline) {
  148. position: relative;
  149. top: auto;
  150. left: auto;
  151. display: inline-block;
  152. margin-left: 10px;
  153. }
  154. }
  155. @include when(required) {
  156. @include pseudo('not(.is-no-asterisk)') {
  157. &.asterisk-left {
  158. > .#{$namespace}-form-item__label:before,
  159. > .#{$namespace}-form-item__label-wrap
  160. > .#{$namespace}-form-item__label:before {
  161. content: '*';
  162. color: getCssVar('color-danger');
  163. margin-right: 4px;
  164. }
  165. }
  166. &.asterisk-right {
  167. > .#{$namespace}-form-item__label:after,
  168. > .#{$namespace}-form-item__label-wrap
  169. > .#{$namespace}-form-item__label:after {
  170. content: '*';
  171. color: getCssVar('color-danger');
  172. margin-left: 4px;
  173. }
  174. }
  175. }
  176. }
  177. @include when(error) {
  178. .#{$namespace}-input__wrapper,
  179. .#{$namespace}-textarea__inner,
  180. .#{$namespace}-select__wrapper {
  181. &,
  182. &:hover,
  183. &:focus,
  184. &.is-focus {
  185. box-shadow: 0 0 0 1px getCssVar('color-danger') inset;
  186. }
  187. }
  188. .#{$namespace}-input-group__append,
  189. .#{$namespace}-input-group__prepend {
  190. .#{$namespace}-input__wrapper {
  191. box-shadow: 0 0 0 1px transparent inset;
  192. }
  193. .#{$namespace}-input__validateIcon {
  194. display: none;
  195. }
  196. }
  197. .#{$namespace}-input__validateIcon {
  198. color: getCssVar('color-danger');
  199. }
  200. }
  201. @include m(feedback) {
  202. .#{$namespace}-input__validateIcon {
  203. display: inline-flex;
  204. }
  205. }
  206. }