_forms.scss 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. .collection_choice_field .input,
  76. .choice_field .input,
  77. .model_choice_field .input,
  78. .typed_choice_field .input {
  79. position: relative;
  80. // Add select arrow back on browsers where native ui has been removed
  81. select ~ span:after {
  82. border-radius: 0 6px 6px 0;
  83. z-index: 0;
  84. position: absolute;
  85. right: 0;
  86. top: 1px;
  87. bottom: 0;
  88. width: 1.5em;
  89. font-family: wagtail;
  90. content: map-get($icons, 'arrow-down');
  91. border: 1px solid $color-input-border;
  92. border-width: 0 0 0 1px;
  93. text-align: center;
  94. line-height: 1.4em;
  95. font-size: 3em;
  96. pointer-events: none;
  97. color: $color-grey-3;
  98. margin: 0 1px 1px 0;
  99. .ie & {
  100. display: none;
  101. }
  102. }
  103. // Override default select padding so the chevron will overlap with long option text
  104. select {
  105. padding-right: 5em;
  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. label.required:after {
  130. content: '*';
  131. color: $color-red;
  132. font-weight: bold;
  133. display: inline-block;
  134. margin-left: 0.5em;
  135. line-height: 1em;
  136. font-size: 13px;
  137. }
  138. .error input,
  139. .error textarea,
  140. .error select,
  141. .error .tagit {
  142. border-color: $color-red;
  143. background-color: $color-input-error-bg;
  144. }
  145. // Layouts for particular kinds of of fields
  146. // permanently show checkbox/radio help as they have no focus state
  147. .boolean_field .help,
  148. .radio .help {
  149. opacity: 1;
  150. }
  151. // This is expected to go on the parent of the input/select/textarea
  152. // so in most cases .input
  153. .iconfield, // generic
  154. .date_field,
  155. .time_field,
  156. .date_time_field,
  157. .url_field {
  158. .input {
  159. position: relative;
  160. &:before,
  161. &:after {
  162. font-family: wagtail;
  163. position: absolute;
  164. top: 0.5em;
  165. line-height: 100%;
  166. font-size: 2em;
  167. color: $color-grey-3;
  168. }
  169. &:before {
  170. left: 0.3em;
  171. }
  172. &:after {
  173. right: 0.5em;
  174. }
  175. }
  176. input:not([type=radio]),
  177. input:not([type=checkbox]),
  178. input:not([type=submit]),
  179. input:not([type=button]) {
  180. padding-left: 2.5em;
  181. }
  182. // smaller fields required slight repositioning of icons
  183. &.field-small {
  184. .input {
  185. &:before,
  186. &:after {
  187. font-size: 1.3rem; // REMs are necessary here because IE doesn't treat generated content correctly
  188. top: 0.3em;
  189. }
  190. &:before {
  191. left: 0.5em;
  192. }
  193. &:after {
  194. right: 0.5em;
  195. }
  196. }
  197. }
  198. // special case for search spinners
  199. &.icon-spinner:after {
  200. color: $color-teal;
  201. opacity: 0.8;
  202. text-align: center;
  203. top: 0.3em;
  204. }
  205. }
  206. .date_field,
  207. .date_time_field {
  208. .input:before {
  209. content: map-get($icons, 'date');
  210. }
  211. }
  212. .time_field {
  213. .input:before {
  214. content: map-get($icons, 'time');
  215. }
  216. }
  217. .url_field {
  218. .input:before {
  219. content: map-get($icons, 'link');
  220. }
  221. }
  222. .daterange_field {
  223. input:last-of-type {
  224. margin-top: 1.2em; // Mirrors the label 1.2em top padding.
  225. }
  226. }
  227. // This is specifically for list of radios/checkboxes
  228. .model_multiple_choice_field .input li,
  229. .checkbox_select_multiple .input li,
  230. .multiple_choice_field .input li,
  231. .choice_field .input li {
  232. label {
  233. display: block;
  234. width: auto;
  235. float: none;
  236. padding-top: 0; // Negates padding added to label for the group of fields as a whole
  237. padding-bottom: 0.8em;
  238. }
  239. }
  240. .fields > li,
  241. .field-col {
  242. @include clearfix();
  243. padding-top: 0.5em;
  244. padding-bottom: 1.2em;
  245. }
  246. .field-row {
  247. @include clearfix();
  248. // negative margin the bottom so it doesn't add too much space
  249. margin-bottom: -1.2em;
  250. }
  251. .input {
  252. clear: both;
  253. }
  254. // field sizing and alignment
  255. .field-small {
  256. input,
  257. textarea,
  258. select,
  259. .halloeditor,
  260. .tagit {
  261. border-radius: 3px;
  262. padding: 0.4em 1em;
  263. }
  264. }
  265. .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: both;}
  278. }
  279. li.inline .field {
  280. &.col1,
  281. &.col2,
  282. &.col3,
  283. &.col4,
  284. &.col5,
  285. &.col6,
  286. &.col7,
  287. &.col8,
  288. &.col9,
  289. &.col10,
  290. &.col11,
  291. &.col12 { clear: none;}
  292. }
  293. // solve gutter issues of inline fields
  294. ul.inline li:first-child,
  295. li.inline:first-child {
  296. margin-left: -$grid-gutter-width / 2;
  297. }
  298. // search-bars
  299. .search-bar {
  300. .required .field > label:after {
  301. display: none;
  302. }
  303. .button-filter {
  304. height: 2.71em;
  305. border-color: transparent;
  306. }
  307. }
  308. // file drop zones
  309. .drop-zone {
  310. border-radius: 5px;
  311. border: 2px dashed $color-grey-4;
  312. padding: $mobile-nice-padding;
  313. background-color: $color-grey-5;
  314. margin-bottom: 1em;
  315. text-align: center;
  316. .drop-zone-help {
  317. border: 0;
  318. }
  319. &.hovered {
  320. border-color: $color-teal;
  321. background-color: $color-input-focus;
  322. }
  323. }
  324. // Transitions
  325. .help {
  326. @include transition(opacity 0.2s ease);
  327. }
  328. .label-uppercase {
  329. .field > label {
  330. text-transform: uppercase;
  331. }
  332. }
  333. @include media-breakpoint-up(sm) {
  334. .help {
  335. opacity: 1;
  336. }
  337. .fields {
  338. max-width: 800px;
  339. }
  340. .field {
  341. @include row();
  342. }
  343. .field-content {
  344. @include column(10, 0);
  345. }
  346. .field-col {
  347. float: left;
  348. padding-left: 0;
  349. // anything less than 4 columns or greater than 6 is impractical
  350. &.col4 {
  351. label {
  352. @include column(2, 0, 4);
  353. }
  354. .field-content {
  355. @include column(2, $padding, 4);
  356. padding-left: 0;
  357. }
  358. }
  359. &.col6 {
  360. label {
  361. @include column(2, 0, 6);
  362. }
  363. .field-content {
  364. @include column(4, $padding, 6);
  365. padding-left: 0;
  366. }
  367. }
  368. }
  369. .label-above {
  370. .field > label,
  371. .field > .field-content {
  372. display: block;
  373. padding: 0 0 0.8em;
  374. float: none;
  375. width: auto;
  376. }
  377. }
  378. }
  379. .field-comment-control {
  380. display: none;
  381. }
  382. .tab-content--comments-enabled {
  383. .field {
  384. position: relative;
  385. }
  386. .field-content {
  387. padding-right: 45px;
  388. @include media-breakpoint-up(sm) {
  389. padding-right: 60px;
  390. }
  391. }
  392. .widget-draftail_rich_text_area .field-content {
  393. padding-right: 0;
  394. }
  395. .field-comment-control {
  396. position: absolute;
  397. display: block;
  398. top: 0;
  399. right: 0;
  400. height: 100%;
  401. line-height: 100%;
  402. &--object {
  403. right: 20px;
  404. @include media-breakpoint-up(lg) {
  405. right: 350px;
  406. }
  407. }
  408. button {
  409. @include transition(opacity 0.2s ease);
  410. border: 0;
  411. background: none;
  412. width: 30px;
  413. height: 30px;
  414. padding: 0;
  415. border-radius: 3px;
  416. position: absolute;
  417. top: 50%;
  418. right: 0;
  419. @include media-breakpoint-up(sm) {
  420. right: 10px;
  421. }
  422. // Hide by default, reveal on hover of parent
  423. @include media-breakpoint-up(md) {
  424. opacity: 0;
  425. pointer-events: none;
  426. transform: translateY(-50%);
  427. right: 0;
  428. }
  429. .icon-reversed {
  430. display: none;
  431. }
  432. &:hover {
  433. cursor: pointer;
  434. // stylelint-disable max-nesting-depth
  435. .icon-default {
  436. display: none;
  437. }
  438. .icon-reversed {
  439. display: block;
  440. }
  441. }
  442. &:focus {
  443. opacity: 1;
  444. pointer-events: initial;
  445. }
  446. > svg {
  447. width: 30px;
  448. height: 30px;
  449. color: $color-teal;
  450. }
  451. }
  452. }
  453. .field-row .field-comment-control {
  454. top: 0;
  455. }
  456. .field:not(.block_field) {
  457. &:hover {
  458. .field-comment-control button {
  459. opacity: 1;
  460. pointer-events: initial;
  461. }
  462. }
  463. }
  464. .object {
  465. &:hover {
  466. .field-comment-control--object button {
  467. opacity: 1;
  468. pointer-events: initial;
  469. }
  470. }
  471. }
  472. .object.model_choice_field {
  473. .object-help {
  474. right: 153px;
  475. }
  476. }
  477. }