_forms.scss 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. // These are the generic stylings for forms of any type.
  2. // If you're styling something specific to the page editing interface,
  3. // it probably ought to go in layouts/page-editor.scss
  4. // TODO: mixin,
  5. // These these styles are currently in elements
  6. // but the ones for the class should be here
  7. //
  8. // label,
  9. // .label {
  10. // text-transform: none;
  11. // font-weight: bold;
  12. // color: $color-grey-1;
  13. // font-size: 1.1em;
  14. // display: block;
  15. // padding: 0 0 0.8em;
  16. // margin: 0;
  17. // line-height: 1.3em;
  18. //
  19. // .checkbox &,
  20. // .radio & {
  21. // display: inline;
  22. // }
  23. // }
  24. .plain-checkbox-label {
  25. // cancel heavy / floated label styles, for labels that should appear inline against checkboxes
  26. float: none;
  27. color: inherit;
  28. font-weight: inherit;
  29. font-size: inherit;
  30. }
  31. // TODO: mixin,
  32. // These these styles are currently in elements
  33. // but the ones for the classes should be here
  34. //
  35. // input,
  36. // textarea,
  37. // select,
  38. // .halloeditor,
  39. // .tagit {
  40. // appearance: none;
  41. // box-sizing: border-box;
  42. // border-radius: 6px;
  43. // width: 100%;
  44. // font-family: Open Sans,Arial,sans-serif;
  45. // border: 1px solid $color-input-border;
  46. // padding: 0.9em 1.2em;
  47. // background-color: $color-fieldset-hover;
  48. // color: $color-text-input;
  49. // font-size: 1.2em;
  50. // font-weight: 300;
  51. // outline: none;
  52. //
  53. // &:hover {
  54. // background-color: $color-white;
  55. // }
  56. //
  57. // &:focus {
  58. // background-color: $color-input-focus;
  59. // border-color: $color-input-focus-border;
  60. // outline: none;
  61. // }
  62. //
  63. // &:disabled,
  64. // &[disabled],
  65. // &:disabled:hover,
  66. // &[disabled]:hover {
  67. // background-color: inherit;
  68. // cursor: default;
  69. // color: $color-grey-4;
  70. // }
  71. // }
  72. // Reset the arrow on `<select>`s in IE10+.
  73. select::-ms-expand {
  74. display: none;
  75. }
  76. // select boxes
  77. .choice_field .input,
  78. .model_choice_field .input,
  79. .typed_choice_field .input {
  80. position: relative;
  81. select {
  82. outline: none;
  83. }
  84. // Add select arrow back on browsers where native ui has been removed
  85. select ~ span:after {
  86. border-radius: 0 6px 6px 0;
  87. z-index: 0;
  88. position: absolute;
  89. right: 0;
  90. top: 1px;
  91. bottom: 0;
  92. width: 1.5em;
  93. font-family: wagtail;
  94. content: 'q';
  95. border: 1px solid $color-input-border;
  96. border-width: 0 0 0 1px;
  97. text-align: center;
  98. line-height: 1.4em;
  99. font-size: 3em;
  100. pointer-events: none;
  101. color: $color-grey-3;
  102. margin: 0 1px 1px 0;
  103. .ie & {
  104. display: none;
  105. }
  106. }
  107. }
  108. // Other text
  109. .help,
  110. .error-message {
  111. font-size: 0.85em;
  112. font-weight: normal;
  113. margin: 0.5em 0 0;
  114. }
  115. .error-message {
  116. color: $color-red;
  117. }
  118. .help {
  119. color: $color-grey-2;
  120. }
  121. fieldset:hover > .help,
  122. .field.focused + .help,
  123. .field:focus + .help,
  124. .field:hover + .help,
  125. li.focused > .help {
  126. opacity: 1;
  127. }
  128. .required .field > label:after {
  129. content: '*';
  130. color: $color-red;
  131. font-weight: bold;
  132. display: inline-block;
  133. margin-left: 0.5em;
  134. line-height: 1em;
  135. font-size: 13px;
  136. }
  137. .error input,
  138. .error textarea,
  139. .error select,
  140. .error .tagit {
  141. border-color: $color-red;
  142. background-color: $color-input-error-bg;
  143. }
  144. // Layouts for particular kinds of of fields
  145. // permanently show checkbox/radio help as they have no focus state
  146. .boolean_field .help,
  147. .radio .help {
  148. opacity: 1;
  149. }
  150. // This is expected to go on the parent of the input/select/textarea
  151. // so in most cases .input
  152. .iconfield, // generic
  153. .date_field,
  154. .time_field,
  155. .date_time_field,
  156. .url_field {
  157. .input {
  158. position: relative;
  159. &:before,
  160. &:after {
  161. font-family: wagtail;
  162. position: absolute;
  163. top: 0.5em;
  164. line-height: 100%;
  165. font-size: 2em;
  166. color: $color-grey-3;
  167. }
  168. &:before {
  169. left: 0.3em;
  170. }
  171. &:after {
  172. right: 0.5em;
  173. }
  174. }
  175. input:not([type=radio]),
  176. input:not([type=checkbox]),
  177. input:not([type=submit]),
  178. input:not([type=button]) {
  179. padding-left: 2.5em;
  180. }
  181. // smaller fields required slight repositioning of icons
  182. &.field-small {
  183. .input {
  184. &:before,
  185. &:after {
  186. font-size: 1.3rem; // REMs are necessary here because IE doesn't treat generated content correctly
  187. top: 0.3em;
  188. }
  189. &:before {
  190. left: 0.5em;
  191. }
  192. &:after {
  193. right: 0.5em;
  194. }
  195. }
  196. }
  197. // special case for search spinners
  198. &.icon-spinner:after {
  199. color: $color-teal;
  200. opacity: 0.8;
  201. text-align: center;
  202. top: 0.3em;
  203. }
  204. }
  205. .date_field,
  206. .date_time_field {
  207. .input:before {
  208. @extend .icon-date:before;
  209. }
  210. }
  211. .time_field {
  212. .input:before {
  213. @extend .icon-time:before;
  214. }
  215. }
  216. .url_field {
  217. .input:before {
  218. @extend .icon-link:before;
  219. }
  220. }
  221. // This is specifically for model that are a generated set of checkboxes/radios
  222. .model_multiple_choice_field .input li,
  223. .choice_field .input li {
  224. label {
  225. display: block;
  226. width: auto;
  227. float: none;
  228. padding-top: 0; // Negates padding added to label for the group of fields as a whole
  229. }
  230. }
  231. .fields > li,
  232. .field-col {
  233. @include clearfix();
  234. padding-top: 0.5em;
  235. padding-bottom: 1.2em;
  236. }
  237. .field-row {
  238. @include clearfix();
  239. // negative margin the bottom so it doesn't add too much space
  240. margin-bottom: -1.2em;
  241. }
  242. .input {
  243. clear: both;
  244. }
  245. // field sizing and alignment
  246. .field-small {
  247. input,
  248. textarea,
  249. select,
  250. .halloeditor,
  251. .tagit {
  252. border-radius: 3px;
  253. padding: 0.4em 1em;
  254. }
  255. }
  256. .field {
  257. &.col1,
  258. &.col2,
  259. &.col3,
  260. &.col4,
  261. &.col5,
  262. &.col6,
  263. &.col7,
  264. &.col8,
  265. &.col9,
  266. &.col10,
  267. &.col11,
  268. &.col12 { clear: both;}
  269. }
  270. li.inline .field {
  271. &.col1,
  272. &.col2,
  273. &.col3,
  274. &.col4,
  275. &.col5,
  276. &.col6,
  277. &.col7,
  278. &.col8,
  279. &.col9,
  280. &.col10,
  281. &.col11,
  282. &.col12 { clear: none;}
  283. }
  284. // solve gutter issues of inline fields
  285. ul.inline li:first-child,
  286. li.inline:first-child {
  287. margin-left: -$grid-gutter-width / 2;
  288. }
  289. // search-bars
  290. .search-bar {
  291. .required .field > label:after {
  292. display: none;
  293. }
  294. .button-filter {
  295. height: 2.71em;
  296. border-color: transparent;
  297. }
  298. }
  299. // file drop zones
  300. .drop-zone {
  301. border-radius: 5px;
  302. border: 2px dashed $color-grey-4;
  303. padding: $mobile-nice-padding;
  304. background-color: $color-grey-5;
  305. margin-bottom: 1em;
  306. text-align: center;
  307. .drop-zone-help {
  308. border: 0;
  309. }
  310. &.hovered {
  311. border-color: $color-teal;
  312. background-color: $color-input-focus;
  313. }
  314. }
  315. // Transitions
  316. .help {
  317. @include transition(opacity 0.2s ease);
  318. }
  319. .label-uppercase {
  320. .field > label {
  321. text-transform: uppercase;
  322. }
  323. }
  324. @include media-breakpoint-up(sm) {
  325. .help {
  326. opacity: 1;
  327. }
  328. .fields {
  329. max-width: 800px;
  330. }
  331. .field {
  332. @include row();
  333. }
  334. .field-content {
  335. @include column(10, 0);
  336. }
  337. .field-col {
  338. float: left;
  339. padding-left: 0;
  340. // anything less than 4 columns or greater than 6 is impractical
  341. &.col4 {
  342. label {
  343. @include column(2, 0, 4);
  344. }
  345. .field-content {
  346. @include column(2, $padding, 4);
  347. padding-left: 0;
  348. }
  349. }
  350. &.col6 {
  351. label {
  352. @include column(2, 0, 6);
  353. }
  354. .field-content {
  355. @include column(4, $padding, 6);
  356. padding-left: 0;
  357. }
  358. }
  359. }
  360. .label-above {
  361. .field > label,
  362. .field > .field-content {
  363. display: block;
  364. padding: 0 0 0.8em;
  365. float: none;
  366. width: auto;
  367. }
  368. }
  369. }