_forms.scss 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*
  2. * Component: Forms
  3. * ----------------
  4. */
  5. .form-group {
  6. &.has-icon {
  7. position: relative;
  8. .form-control {
  9. padding-right: 35px;
  10. }
  11. .form-icon {
  12. background-color: transparent;
  13. border: 0;
  14. cursor: pointer;
  15. font-size: 1rem;
  16. // margin-top: -3px;
  17. padding: $input-btn-padding-y $input-btn-padding-x;
  18. position: absolute;
  19. right: 3px;
  20. top: 0;
  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 icons in form-control
  33. .form-control-feedback {
  34. &.fa,
  35. &.fas,
  36. &.far,
  37. &.fab,
  38. &.glyphicon,
  39. &.ion {
  40. line-height: $input-height;
  41. }
  42. }
  43. .input-lg + .form-control-feedback,
  44. .input-group-lg + .form-control-feedback {
  45. &.fa,
  46. &.fas,
  47. &.far,
  48. &.fab,
  49. &.glyphicon,
  50. &.ion {
  51. line-height: $input-height-lg;
  52. }
  53. }
  54. .form-group-lg {
  55. .form-control + .form-control-feedback {
  56. &.fa,
  57. &.fas,
  58. &.far,
  59. &.fab,
  60. &.glyphicon,
  61. &.ion {
  62. line-height: $input-height-lg;
  63. }
  64. }
  65. }
  66. .input-sm + .form-control-feedback,
  67. .input-group-sm + .form-control-feedback {
  68. &.fa,
  69. &.fas,
  70. &.far,
  71. &.fab,
  72. &.glyphicon,
  73. &.ion {
  74. line-height: $input-height-sm;
  75. }
  76. }
  77. .form-group-sm {
  78. .form-control + .form-control-feedback {
  79. &.fa,
  80. &.fas,
  81. &.far,
  82. &.fab,
  83. &.glyphicon,
  84. &.ion {
  85. line-height: $input-height-sm;
  86. }
  87. }
  88. }
  89. label:not(.form-check-label, .custom-file-label) {
  90. font-weight: $font-weight-bold;
  91. }
  92. .warning-feedback {
  93. @include font-size($form-feedback-font-size);
  94. color: theme-color('warning');
  95. display: none;
  96. margin-top: $form-feedback-margin-top;
  97. width: 100%;
  98. }
  99. .warning-tooltip {
  100. @include border-radius($form-feedback-tooltip-border-radius);
  101. @include font-size($form-feedback-tooltip-font-size);
  102. background-color: rgba(theme-color('warning'), $form-feedback-tooltip-opacity);
  103. color: color-yiq(theme-color('warning'));
  104. display: none;
  105. line-height: $form-feedback-tooltip-line-height;
  106. margin-top: .1rem;
  107. max-width: 100%; // Contain to parent when possible
  108. padding: $form-feedback-tooltip-padding-y $form-feedback-tooltip-padding-x;
  109. position: absolute;
  110. top: 100%;
  111. z-index: 5;
  112. }
  113. .form-control {
  114. &.is-warning {
  115. border-color: theme-color('warning');
  116. @if $enable-validation-icons {
  117. // padding-right: $input-height-inner;
  118. // background-image: none;
  119. // background-repeat: no-repeat;
  120. // background-position: center right $input-height-inner-quarter;
  121. // background-size: $input-height-inner-half $input-height-inner-half;
  122. }
  123. &:focus {
  124. border-color: theme-color('warning');
  125. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  126. }
  127. ~ .warning-feedback,
  128. ~ .warning-tooltip {
  129. display: block;
  130. }
  131. }
  132. }
  133. // stylelint-disable-next-line selector-no-qualifying-type
  134. textarea.form-control {
  135. &.is-warning {
  136. @if $enable-validation-icons {
  137. padding-right: $input-height-inner;
  138. background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
  139. }
  140. }
  141. }
  142. .custom-select {
  143. &.is-warning {
  144. border-color: theme-color('warning');
  145. @if $enable-validation-icons {
  146. // padding-right: $custom-select-feedback-icon-padding-right;
  147. // background: $custom-select-background, none $custom-select-bg no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
  148. }
  149. &:focus {
  150. border-color: theme-color('warning');
  151. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  152. }
  153. ~ .warning-feedback,
  154. ~ .warning-tooltip {
  155. display: block;
  156. }
  157. }
  158. }
  159. .form-control-file {
  160. &.is-warning {
  161. ~ .warning-feedback,
  162. ~ .warning-tooltip {
  163. display: block;
  164. }
  165. }
  166. }
  167. .form-check-input {
  168. &.is-warning {
  169. ~ .form-check-label {
  170. color: theme-color('warning');
  171. }
  172. ~ .warning-feedback,
  173. ~ .warning-tooltip {
  174. display: block;
  175. }
  176. }
  177. }
  178. .custom-control-input.is-warning {
  179. ~ .custom-control-label {
  180. color: theme-color('warning');
  181. &::before {
  182. border-color: theme-color('warning');
  183. }
  184. }
  185. ~ .warning-feedback,
  186. ~ .warning-tooltip {
  187. display: block;
  188. }
  189. &:checked {
  190. ~ .custom-control-label::before {
  191. @include gradient-bg(lighten(theme-color('warning'), 10%));
  192. border-color: lighten(theme-color('warning'), 10%);
  193. }
  194. }
  195. &:focus {
  196. ~ .custom-control-label::before {
  197. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  198. }
  199. &:not(:checked) ~ .custom-control-label::before {
  200. border-color: theme-color('warning');
  201. }
  202. }
  203. }
  204. // custom file
  205. .custom-file-input {
  206. &.is-warning {
  207. ~ .custom-file-label {
  208. border-color: theme-color('warning');
  209. }
  210. ~ .warning-feedback,
  211. ~ .warning-tooltip {
  212. display: block;
  213. }
  214. &:focus {
  215. ~ .custom-file-label {
  216. border-color: theme-color('warning');
  217. box-shadow: 0 0 0 $input-focus-width rgba(theme-color('warning'), .25);
  218. }
  219. }
  220. }
  221. }
  222. // custom switch color variations
  223. .custom-switch {
  224. @each $name, $color in $theme-colors {
  225. &.custom-switch-off-#{$name} {
  226. & .custom-control-input ~ .custom-control-label::before {
  227. background: #{$color};
  228. border-color: darken($color, 20%);
  229. }
  230. & .custom-control-input ~ .custom-control-label::after {
  231. background: darken($color, 25%);
  232. }
  233. }
  234. &.custom-switch-on-#{$name} {
  235. & .custom-control-input:checked ~ .custom-control-label::before {
  236. background: #{$color};
  237. border-color: darken($color, 20%);
  238. }
  239. & .custom-control-input:checked ~ .custom-control-label::after {
  240. background: lighten($color, 30%);
  241. }
  242. }
  243. }
  244. @each $name, $color in $colors {
  245. &.custom-switch-off-#{$name} {
  246. & .custom-control-input ~ .custom-control-label::before {
  247. background: #{$color};
  248. border-color: darken($color, 20%);
  249. }
  250. & .custom-control-input ~ .custom-control-label::after {
  251. background: darken($color, 25%);
  252. }
  253. }
  254. &.custom-switch-on-#{$name} {
  255. & .custom-control-input:checked ~ .custom-control-label::before {
  256. background: #{$color};
  257. border-color: darken($color, 20%);
  258. }
  259. & .custom-control-input:checked ~ .custom-control-label::after {
  260. background: lighten($color, 30%);
  261. }
  262. }
  263. }
  264. }
  265. // custom range color variations
  266. .custom-range {
  267. @each $name, $color in $theme-colors {
  268. &.custom-range-#{$name} {
  269. &:focus {
  270. &::-webkit-slider-thumb {
  271. background-color: lighten($color, 35%);
  272. }
  273. &::-moz-range-thumb {
  274. background-color: lighten($color, 35%);
  275. }
  276. &::-ms-thumb {
  277. background-color: lighten($color, 35%);
  278. }
  279. }
  280. &::-webkit-slider-thumb {
  281. background-color: $color;
  282. }
  283. &::-moz-range-thumb {
  284. background-color: $color;
  285. }
  286. &::-ms-thumb {
  287. background-color: $color;
  288. }
  289. }
  290. }
  291. @each $name, $color in $colors {
  292. &.custom-range-#{$name} {
  293. &:focus {
  294. &::-webkit-slider-thumb {
  295. background-color: lighten($color, 35%);
  296. }
  297. &::-moz-range-thumb {
  298. background-color: lighten($color, 35%);
  299. }
  300. &::-ms-thumb {
  301. background-color: lighten($color, 35%);
  302. }
  303. }
  304. &::-webkit-slider-thumb {
  305. background-color: $color;
  306. }
  307. &::-moz-range-thumb {
  308. background-color: $color;
  309. }
  310. &::-ms-thumb {
  311. background-color: $color;
  312. }
  313. }
  314. }
  315. }