_forms.scss 7.8 KB

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