inputs.scss 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /* ========================================================================
  2. Component: inputs
  3. ========================================================================== */
  4. /**
  5. * Custom form elements
  6. * - Checkbox
  7. * - Radios
  8. * - Switch
  9. * - Note editor
  10. */
  11. //
  12. // CHECKBOX AND RADIOS
  13. //
  14. $ui-fg-color: $primary;
  15. $ui-bg-color: #ddd;
  16. @mixin switch-variant($wd, $hg) {
  17. & span {
  18. width: $wd;
  19. height: $hg;
  20. }
  21. & span:after {
  22. height: $hg - 2;
  23. width: $hg - 2;
  24. }
  25. }
  26. .c-checkbox,
  27. .c-radio {
  28. margin-right: 4px;
  29. * {
  30. cursor: pointer;
  31. }
  32. input {
  33. opacity: 0;
  34. position: absolute;
  35. margin-left: 0 !important;
  36. } // the element that replaces the input
  37. span {
  38. position: relative;
  39. display: inline-block;
  40. vertical-align: top; // margin-left: -20px;
  41. width: 20px;
  42. height: 20px;
  43. border-radius: 2px;
  44. border: 1px solid #ccc;
  45. margin-right: 5px;
  46. text-align: center;
  47. &:before {
  48. margin-left: 1px; // fa align trick
  49. }
  50. }
  51. &:hover span {
  52. border-color: $ui-fg-color;
  53. }
  54. .form-inline & span {
  55. margin-left: 0;
  56. }
  57. &.c-checkbox-rounded,
  58. &.c-radio-rounded {
  59. span {
  60. border-radius: 500px;
  61. }
  62. }
  63. }
  64. /* override for radio */
  65. .c-radio span {
  66. border-radius: 500px;
  67. }
  68. /* the icon */
  69. .c-checkbox,
  70. .c-radio {
  71. span:before {
  72. //content: "\2713"; /* comment content to use custom icon classes */
  73. position: absolute;
  74. top: 0;
  75. left: 0;
  76. right: 0;
  77. bottom: 0;
  78. opacity: 0;
  79. text-align: center !important;
  80. font-size: 12px;
  81. line-height: 18px;
  82. vertical-align: middle;
  83. }
  84. }
  85. .c-checkbox,
  86. .c-radio {
  87. /* Checked state */
  88. input[type=checkbox]:checked+span:before,
  89. input[type=radio]:checked+span:before {
  90. color: #fff;
  91. opacity: 1;
  92. transition: color .3s ease-out;
  93. }
  94. input[type=checkbox]:checked+span,
  95. input[type=radio]:checked+span {
  96. border-color: $ui-fg-color;
  97. background-color: $ui-fg-color;
  98. }
  99. /* override for radio */
  100. input[type=radio]:checked+span {
  101. background-color: #fff;
  102. &:before {
  103. color: $ui-fg-color;
  104. }
  105. }
  106. /* Disable state */
  107. input[type=checkbox]:disabled+span,
  108. input[type=radio]:disabled+span {
  109. border-color: $ui-bg-color !important;
  110. background-color: $ui-bg-color !important;
  111. }
  112. /* override for radio */
  113. input[type=radio]:disabled+span {
  114. background-color: #fff !important;
  115. &:before {
  116. color: $ui-bg-color;
  117. }
  118. }
  119. /* Focus state */
  120. input[type=checkbox]:focus + span,
  121. input[type=radio]:focus + span {
  122. box-shadow: 0 0 0 0.2rem rgba($ui-fg-color, .25)
  123. }
  124. }
  125. .c-radio.c-radio-nofont {
  126. span {
  127. &:before {
  128. $sz: 10px;
  129. content: "";
  130. width: $sz;
  131. height: $sz;
  132. top: 50%;
  133. left: 50%;
  134. margin-top: -($sz/2);
  135. margin-left: -($sz/2);
  136. border-radius: 500px;
  137. }
  138. }
  139. input[type=radio]:checked+span:before {
  140. color: #fff;
  141. opacity: 1;
  142. transition: color .3s ease-out;
  143. }
  144. input[type=radio]:checked+span {
  145. border-color: $ui-fg-color;
  146. background-color: $ui-fg-color;
  147. }
  148. /* override for radio */
  149. input[type=radio]:checked+span {
  150. background-color: #fff;
  151. &:before {
  152. background-color: $ui-fg-color;
  153. }
  154. }
  155. /* Disable state */
  156. input[type=radio]:disabled+span {
  157. border-color: $ui-bg-color !important;
  158. background-color: $ui-bg-color !important;
  159. }
  160. /* override for radio */
  161. input[type=radio]:disabled+span {
  162. background-color: #fff !important;
  163. &:before {
  164. background-color: $ui-bg-color;
  165. }
  166. }
  167. }
  168. //
  169. // Form SWITCH
  170. // Supports radio and checkbox
  171. //
  172. $switch-wd: 40px;
  173. $switch-hg: $switch-wd/2;
  174. $switch-lg-wd: 50px;
  175. $switch-lg-hg: $switch-lg-wd/2;
  176. $switch-sm-wd: 30px;
  177. $switch-sm-hg: $switch-sm-wd/2;
  178. .switch {
  179. .form-control {
  180. padding-top: 7px;
  181. margin-bottom: 0;
  182. }
  183. }
  184. .switch * {
  185. cursor: pointer;
  186. }
  187. .switch input {
  188. opacity: 0;
  189. position: absolute;
  190. z-index: -1;
  191. }
  192. .switch {
  193. display: flex;
  194. align-items: center;
  195. margin: 0;
  196. & span {
  197. position: relative;
  198. display: inline-block;
  199. width: $switch-wd;
  200. height: $switch-hg;
  201. background-color: #fff;
  202. border: 1px solid $ui-bg-color;
  203. border-radius: 100px;
  204. transition: all .5s;
  205. box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.1) inset;
  206. }
  207. & span:after {
  208. content: "";
  209. position: absolute;
  210. background-color: #fff;
  211. top: 0;
  212. left: 0;
  213. height: $switch-hg - 2;
  214. width: $switch-hg - 2;
  215. border: 1px solid #ddd;
  216. border-radius: 400px;
  217. box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
  218. -webkit-transition: all .2s;
  219. }
  220. &.switch-lg {
  221. @include switch-variant($switch-lg-wd, $switch-lg-hg);
  222. }
  223. &.switch-sm {
  224. @include switch-variant($switch-sm-wd, $switch-sm-hg);
  225. }
  226. }
  227. .switch input {
  228. &:checked+span {
  229. background-color: $ui-fg-color;
  230. border-color: $ui-fg-color;
  231. transition: all .5s;
  232. }
  233. &:checked+span:after {
  234. left: 50%;
  235. transition: all .2s;
  236. }
  237. &:disabled+span {
  238. background-color: #f1f1f1;
  239. cursor: not-allowed;
  240. }
  241. &:focus + span {
  242. box-shadow: 0 0 0 0.2rem rgba($ui-fg-color, .25)
  243. }
  244. }
  245. //
  246. // Textarea note editor
  247. //
  248. .note-editor {
  249. background-image: -webkit-linear-gradient(#eee .1em, transparent .1em);
  250. background-image: linear-gradient(#eee .1em, transparent .1em);
  251. background-size: 100% 20px;
  252. background-color: #fff;
  253. line-height: 20px;
  254. margin-top: 5px;
  255. padding: 0;
  256. padding-bottom: 1px;
  257. border: none;
  258. $margin-color: $warning;
  259. &.note-editor-margin {
  260. background-image: -webkit-linear-gradient(0deg, transparent 49px, lighten($margin-color, 30%) 49px, lighten($margin-color, 30%) 51px, transparent 51px), -webkit-linear-gradient(#eee .1em, transparent .1em);
  261. background-image: linear-gradient(90deg, transparent 49px, lighten($margin-color, 30%) 49px, lighten($margin-color, 30%) 51px, transparent 51px),
  262. linear-gradient(#eee .1em, transparent .1em);
  263. padding-left: 55px;
  264. }
  265. }