_forms.scss 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * Component: Form
  3. * ---------------
  4. */
  5. .form-group {
  6. &.has-icon {
  7. position: relative;
  8. .form-control {
  9. padding-right: 35px;
  10. }
  11. .form-icon {
  12. cursor: pointer;
  13. position: absolute;
  14. right: 3px;
  15. top: 0;
  16. padding: $input-btn-padding-y $input-btn-padding-x;
  17. // margin-top: -3px;
  18. border: 0;
  19. background-color: transparent;
  20. font-size: 1rem;
  21. }
  22. }
  23. }
  24. /* button groups */
  25. .btn-group-vertical {
  26. .btn {
  27. &.btn-flat:first-of-type, &.btn-flat:last-of-type {
  28. @include border-radius(0);
  29. }
  30. }
  31. }
  32. /* Support Font Awesome icons in form-control */
  33. .form-control-feedback {
  34. &.fa,
  35. &.fas,
  36. &.far,
  37. &.fab {
  38. line-height: $input-height;
  39. }
  40. }
  41. .input-lg + .form-control-feedback.fa,
  42. .input-group-lg + .form-control-feedback.fa,
  43. .form-group-lg .form-control + .form-control-feedback.fa,
  44. .input-lg + .form-control-feedback.fas,
  45. .input-group-lg + .form-control-feedback.fas,
  46. .form-group-lg .form-control + .form-control-feedback.fas,
  47. .input-lg + .form-control-feedback.far,
  48. .input-group-lg + .form-control-feedback.far,
  49. .form-group-lg .form-control + .form-control-feedback.far,
  50. .input-lg + .form-control-feedback.fab,
  51. .input-group-lg + .form-control-feedback.fab,
  52. .form-group-lg .form-control + .form-control-feedback.fab {
  53. line-height: $input-height-lg;
  54. }
  55. .input-sm + .form-control-feedback.fa,
  56. .input-group-sm + .form-control-feedback.fa,
  57. .form-group-sm .form-control + .form-control-feedback.fa,
  58. .input-sm + .form-control-feedback.fas,
  59. .input-group-sm + .form-control-feedback.fas,
  60. .form-group-sm .form-control + .form-control-feedback.fas,
  61. .input-sm + .form-control-feedback.far,
  62. .input-group-sm + .form-control-feedback.far,
  63. .form-group-sm .form-control + .form-control-feedback.far,
  64. .input-sm + .form-control-feedback.fab,
  65. .input-group-sm + .form-control-feedback.fab,
  66. .form-group-sm .form-control + .form-control-feedback.fab {
  67. line-height: $input-height-sm;
  68. }
  69. label:not(.form-check-label, .custom-file-label) {
  70. font-weight: $font-weight-bold;
  71. }
  72. .warning-feedback {
  73. display: none;
  74. width: 100%;
  75. margin-top: $form-feedback-margin-top;
  76. @include font-size($form-feedback-font-size);
  77. color: theme-color('warning');
  78. }
  79. .warning-tooltip {
  80. position: absolute;
  81. top: 100%;
  82. z-index: 5;
  83. display: none;
  84. max-width: 100%; // Contain to parent when possible
  85. padding: $form-feedback-tooltip-padding-y $form-feedback-tooltip-padding-x;
  86. margin-top: .1rem;
  87. @include font-size($form-feedback-tooltip-font-size);
  88. line-height: $form-feedback-tooltip-line-height;
  89. color: color-yiq(theme-color('warning'));
  90. background-color: rgba(theme-color('warning'), $form-feedback-tooltip-opacity);
  91. @include border-radius($form-feedback-tooltip-border-radius);
  92. }
  93. .form-control {
  94. &.is-warning {
  95. border-color: theme-color('warning');
  96. @if $enable-validation-icons {
  97. // padding-right: $input-height-inner;
  98. // background-image: none;
  99. // background-repeat: no-repeat;
  100. // background-position: center right $input-height-inner-quarter;
  101. // background-size: $input-height-inner-half $input-height-inner-half;
  102. }
  103. &:focus {
  104. border-color: theme-color('warning');
  105. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  106. }
  107. ~ .warning-feedback,
  108. ~ .warning-tooltip {
  109. display: block;
  110. }
  111. }
  112. }
  113. // stylelint-disable-next-line selector-no-qualifying-type
  114. textarea.form-control {
  115. &.is-warning {
  116. @if $enable-validation-icons {
  117. padding-right: $input-height-inner;
  118. background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
  119. }
  120. }
  121. }
  122. .custom-select {
  123. &.is-warning {
  124. border-color: theme-color('warning');
  125. @if $enable-validation-icons {
  126. // padding-right: $custom-select-feedback-icon-padding-right;
  127. // background: $custom-select-background, none $custom-select-bg no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
  128. }
  129. &:focus {
  130. border-color: theme-color('warning');
  131. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  132. }
  133. ~ .warning-feedback,
  134. ~ .warning-tooltip {
  135. display: block;
  136. }
  137. }
  138. }
  139. .form-control-file {
  140. &.is-warning {
  141. ~ .warning-feedback,
  142. ~ .warning-tooltip {
  143. display: block;
  144. }
  145. }
  146. }
  147. .form-check-input {
  148. &.is-warning {
  149. ~ .form-check-label {
  150. color: theme-color('warning');
  151. }
  152. ~ .warning-feedback,
  153. ~ .warning-tooltip {
  154. display: block;
  155. }
  156. }
  157. }
  158. .custom-control-input {
  159. &.is-warning {
  160. ~ .custom-control-label {
  161. color: theme-color('warning');
  162. &::before {
  163. border-color: theme-color('warning');
  164. }
  165. }
  166. ~ .warning-feedback,
  167. ~ .warning-tooltip {
  168. display: block;
  169. }
  170. &:checked {
  171. ~ .custom-control-label::before {
  172. border-color: lighten(theme-color('warning'), 10%);
  173. @include gradient-bg(lighten(theme-color('warning'), 10%));
  174. }
  175. }
  176. &:focus {
  177. ~ .custom-control-label::before {
  178. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  179. }
  180. &:not(:checked) ~ .custom-control-label::before {
  181. border-color: theme-color('warning');
  182. }
  183. }
  184. }
  185. }
  186. // custom file
  187. .custom-file-input {
  188. &.is-warning {
  189. ~ .custom-file-label {
  190. border-color: theme-color('warning');
  191. }
  192. ~ .warning-feedback,
  193. ~ .warning-tooltip {
  194. display: block;
  195. }
  196. &:focus {
  197. ~ .custom-file-label {
  198. border-color: theme-color('warning');
  199. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  200. }
  201. }
  202. }
  203. }
  204. .custom-switch {
  205. @each $name, $color in $theme-colors {
  206. &.custom-switch-off-#{$name} {
  207. & .custom-control-input ~ .custom-control-label::before {
  208. background-color: #{$color};
  209. border-color: darken($color, 20%);
  210. }
  211. & .custom-control-input ~ .custom-control-label::after {
  212. background-color: darken($color, 25%);
  213. }
  214. }
  215. &.custom-switch-on-#{$name} {
  216. & .custom-control-input:checked ~ .custom-control-label::before {
  217. background-color: #{$color};
  218. border-color: darken($color, 20%);
  219. }
  220. & .custom-control-input:checked ~ .custom-control-label::after {
  221. background-color: lighten($color, 30%);
  222. }
  223. }
  224. }
  225. // Background colors (colors)
  226. @each $name, $color in $colors {
  227. &.custom-switch-off-#{$name} {
  228. & .custom-control-input ~ .custom-control-label::before {
  229. background-color: #{$color};
  230. border-color: darken($color, 20%);
  231. }
  232. & .custom-control-input ~ .custom-control-label::after {
  233. background-color: darken($color, 25%);
  234. }
  235. }
  236. &.custom-switch-on-#{$name} {
  237. & .custom-control-input:checked ~ .custom-control-label::before {
  238. background-color: #{$color};
  239. border-color: darken($color, 20%);
  240. }
  241. & .custom-control-input:checked ~ .custom-control-label::after {
  242. background-color: lighten($color, 30%);
  243. }
  244. }
  245. }
  246. }