Bez popisu

forms.scss 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. input[type="text"],
  2. input[type="email"],
  3. input[type="url"],
  4. input[type="password"],
  5. input[type="search"],
  6. input[type="number"],
  7. input[type="tel"],
  8. input[type="date"],
  9. input[type="month"],
  10. input[type="week"],
  11. input[type="time"],
  12. input[type="datetime"],
  13. input[type="datetime-local"],
  14. input[type="color"],
  15. .site textarea {
  16. border: var(--form--border-width) solid var(--form--border-color);
  17. border-radius: var(--form--border-radius);
  18. color: var(--form--color-text);
  19. line-height: var(--global--line-height-body);
  20. padding: var(--form--spacing-unit);
  21. // Gives a little more space for the outline offset.
  22. margin: 0 2px;
  23. max-width: 100%;
  24. &:focus {
  25. color: var(--form--color-text);
  26. outline-offset: 2px;
  27. outline: 2px dotted var(--form--border-color);
  28. }
  29. &:disabled {
  30. opacity: 0.7;
  31. }
  32. .is-dark-theme & {
  33. background: var(--global--color-white-90);
  34. }
  35. }
  36. // Reset the negative offset from normalize to make the thicker "border" work on focus.
  37. input[type="search"] {
  38. &:focus {
  39. outline-offset: -7px;
  40. .is-dark-theme & {
  41. outline-color: var(--global--color-background);
  42. }
  43. }
  44. }
  45. input[type="color"] {
  46. padding: calc(var(--form--spacing-unit) / 2);
  47. height: calc(4 * var(--form--spacing-unit));
  48. }
  49. input[type="email"],
  50. input[type="url"] {
  51. /*rtl:ignore*/
  52. direction: ltr;
  53. }
  54. select {
  55. border: var(--form--border-width) solid var(--form--border-color);
  56. color: var(--form--color-text);
  57. -moz-appearance: none;
  58. -webkit-appearance: none;
  59. appearance: none;
  60. line-height: var(--global--line-height-body);
  61. padding: var(--form--spacing-unit) calc(3 * var(--form--spacing-unit)) var(--form--spacing-unit) var(--form--spacing-unit);
  62. background: var(--global--color-white) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2328303d'><polygon points='0,0 10,0 5,5'/></svg>") no-repeat; // stylelint-disable-line function-url-quotes
  63. background-position: right var(--form--spacing-unit) top 60%;
  64. &:focus {
  65. outline-offset: 2px;
  66. outline: 2px dotted var(--form--border-color);
  67. }
  68. .is-dark-theme & {
  69. background: var(--global--color-white-90) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2328303d'><polygon points='0,0 10,0 5,5'/></svg>") no-repeat; // stylelint-disable-line function-url-quotes
  70. background-position: right var(--form--spacing-unit) top 60%;
  71. }
  72. }
  73. textarea {
  74. width: 100%;
  75. }
  76. label {
  77. font-size: var(--form--font-size);
  78. font-weight: var(--form--label-weight);
  79. margin-bottom: calc(var(--global--spacing-vertical) / 3);
  80. }
  81. /**
  82. https://css-tricks.com/custom-styling-form-inputs-with-modern-css-features/
  83. https://codepen.io/aaroniker/pen/ZEYoxEY by Aaron Iker.
  84. License: MIT.
  85. */
  86. @supports (-webkit-appearance: none) or (-moz-appearance: none) {
  87. input[type="checkbox"],
  88. input[type="radio"] {
  89. -webkit-appearance: none;
  90. -moz-appearance: none;
  91. position: relative;
  92. width: 25px;
  93. height: 25px;
  94. border: var(--form--border-width) solid var(--form--border-color);
  95. background: var(--global--color-white);
  96. &:disabled {
  97. opacity: 0.7;
  98. }
  99. .is-dark-theme & {
  100. background: var(--global--color-white-90);
  101. }
  102. }
  103. input[type="checkbox"] {
  104. &:focus {
  105. outline-offset: 2px;
  106. outline: 2px dotted var(--form--border-color);
  107. }
  108. &:after {
  109. content: "";
  110. opacity: 0;
  111. display: block;
  112. left: 5px;
  113. top: 2px;
  114. position: absolute;
  115. width: 7px;
  116. height: 13px;
  117. border: 3px solid var(--form--color-text);
  118. border-top: 0;
  119. border-left: 0;
  120. transform: rotate(30deg);
  121. }
  122. &:checked {
  123. color: var(--form--color-text);
  124. &:after {
  125. opacity: 1;
  126. }
  127. }
  128. }
  129. input[type="radio"] {
  130. border-radius: 50%;
  131. &:focus {
  132. outline-offset: 2px;
  133. outline: 2px dotted var(--form--border-color);
  134. }
  135. &:after {
  136. content: "";
  137. opacity: 0;
  138. display: block;
  139. left: 3px;
  140. top: 3px;
  141. position: absolute;
  142. width: 11px;
  143. height: 11px;
  144. border-radius: 50%;
  145. background: var(--form--color-text);
  146. }
  147. &:checked {
  148. border: 4px solid var(--form--border-color);
  149. &:after {
  150. opacity: 1;
  151. }
  152. // Focus style for checked radio buttons.
  153. &:focus {
  154. outline-offset: 4px;
  155. outline: 2px dotted var(--form--border-color);
  156. }
  157. }
  158. }
  159. }
  160. input[type="checkbox"] + label,
  161. input[type="radio"] + label {
  162. display: inline-block;
  163. padding-left: 10px;
  164. font-size: var(--global--font-size-xs);
  165. vertical-align: top;
  166. }
  167. /**
  168. * https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/
  169. */
  170. @supports (-webkit-appearance: none) or (-moz-appearance: none) {
  171. input[type="range"] {
  172. -webkit-appearance: none; /* Hides the slider so that custom slider can be made */
  173. width: 100%; /* Specific width is required for Firefox. */
  174. height: 6px;
  175. background: var(--form--color-ranged);
  176. border-radius: 6px;
  177. outline-offset: 10px;
  178. &:disabled {
  179. opacity: 0.7;
  180. }
  181. }
  182. input[type="range"]::-webkit-slider-thumb {
  183. -webkit-appearance: none;
  184. border: 3px solid var(--form--color-ranged);
  185. height: 44px;
  186. width: 44px;
  187. border-radius: 50%;
  188. background: var(--global--color-background);
  189. cursor: pointer;
  190. }
  191. input[type="range"]::-moz-range-thumb {
  192. border: 3px solid var(--form--color-ranged);
  193. height: 44px;
  194. width: 44px;
  195. border-radius: 50%;
  196. background: var(--global--color-background);
  197. cursor: pointer;
  198. box-sizing: border-box;
  199. }
  200. }
  201. input[type="range"]::-ms-track {
  202. width: 100%;
  203. height: 6px;
  204. border-radius: 6px;
  205. border-width: 19px 0;
  206. border-color: var(--global--color-background);
  207. background: transparent;
  208. color: transparent;
  209. cursor: pointer;
  210. }
  211. input[type="range"]::-ms-fill-upper {
  212. background: var(--form--color-ranged);
  213. border-radius: 6px;
  214. }
  215. input[type="range"]::-ms-fill-lower {
  216. background: var(--form--color-ranged);
  217. border-radius: 6px;
  218. }
  219. input[type="range"]::-ms-thumb {
  220. border: 3px solid var(--form--color-ranged);
  221. height: 44px;
  222. width: 44px;
  223. border-radius: 50%;
  224. background: var(--global--color-background);
  225. cursor: pointer;
  226. }
  227. fieldset {
  228. display: grid;
  229. border-color: var(--global--color-secondary);
  230. padding: var(--global--spacing-horizontal);
  231. legend {
  232. font-size: var(--global--font-size-lg);
  233. }
  234. input {
  235. &[type="submit"] {
  236. max-width: max-content;
  237. }
  238. &:not([type="submit"]) {
  239. margin-bottom: var(--global--spacing-unit);
  240. }
  241. &[type="radio"],
  242. &[type="checkbox"] {
  243. margin-bottom: 0;
  244. }
  245. &[type="radio"] + label,
  246. &[type="checkbox"] + label {
  247. font-size: var(--form--font-size);
  248. padding-left: 0;
  249. margin-bottom: var(--global--spacing-unit);
  250. }
  251. }
  252. }
  253. ::-moz-placeholder { // Firefox 19+
  254. opacity: 1;
  255. }
  256. .post-password-message {
  257. font-size: var(--global--font-size-lg);
  258. }
  259. .post-password-form {
  260. display: flex;
  261. flex-wrap: wrap;
  262. &__label {
  263. width: 100%;
  264. margin-bottom: 0;
  265. }
  266. input[type="password"] {
  267. flex-grow: 1;
  268. margin-top: calc(var(--global--spacing-vertical) / 3);
  269. margin-right: calc(0.66 * var(--global--spacing-horizontal));
  270. }
  271. &__submit {
  272. margin-top: calc(var(--global--spacing-vertical) / 3);
  273. @include media(tablet) {
  274. margin-left: calc(0.4 * var(--global--spacing-horizontal));
  275. }
  276. }
  277. }