_forms.scss 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. @use "sass:map";
  2. @use "sass:math";
  3. // stylelint-disable scss/comment-no-empty
  4. // These are the generic stylings for forms of any type.
  5. // If you're styling something specific to the page editing interface,
  6. // it probably ought to go in layouts/page-editor.scss
  7. // TODO: mixin,
  8. // These these styles are currently in elements
  9. // but the ones for the class should be here
  10. //
  11. // label,
  12. // .label {
  13. // text-transform: none;
  14. // font-weight: bold;
  15. // color: $color-grey-1;
  16. // font-size: 1.1em;
  17. // display: block;
  18. // padding: 0 0 0.8em;
  19. // margin: 0;
  20. // line-height: 1.3em;
  21. //
  22. // .checkbox &,
  23. // .radio & {
  24. // display: inline;
  25. // }
  26. // }
  27. .plain-checkbox-label {
  28. // cancel heavy / floated label styles, for labels that should appear inline against checkboxes
  29. float: none;
  30. color: inherit;
  31. font-weight: inherit;
  32. font-size: inherit;
  33. }
  34. // TODO: mixin,
  35. // These these styles are currently in elements
  36. // but the ones for the classes should be here
  37. //
  38. // input,
  39. // textarea,
  40. // select,
  41. // .halloeditor,
  42. // .tagit {
  43. // appearance: none;
  44. // box-sizing: border-box;
  45. // border-radius: 6px;
  46. // width: 100%;
  47. // font-family: Open Sans,Arial,sans-serif;
  48. // border: 1px solid $color-input-border;
  49. // padding: 0.9em 1.2em;
  50. // background-color: $color-fieldset-hover;
  51. // color: $color-text-input;
  52. // font-size: 1.2em;
  53. // font-weight: 300;
  54. //
  55. // &:hover {
  56. // background-color: $color-white;
  57. // }
  58. //
  59. // &:focus {
  60. // background-color: $color-input-focus;
  61. // border-color: $color-input-focus-border;
  62. // }
  63. //
  64. // &:disabled,
  65. // &[disabled],
  66. // &:disabled:hover,
  67. // &[disabled]:hover {
  68. // background-color: inherit;
  69. // cursor: default;
  70. // color: $color-grey-4;
  71. // }
  72. // }
  73. // Reset the arrow on `<select>`s in IE10+.
  74. select::-ms-expand {
  75. display: none;
  76. }
  77. // select boxes
  78. .collection_choice_field .input,
  79. .choice_field .input,
  80. .model_choice_field .input,
  81. .typed_choice_field .input {
  82. position: relative;
  83. // Add select arrow back on browsers where native ui has been removed
  84. select ~ span:after {
  85. border-radius: 0 6px 6px 0;
  86. z-index: 0;
  87. position: absolute;
  88. right: 0;
  89. top: 1px;
  90. bottom: 0;
  91. width: 1.5em;
  92. font-family: $font-wagtail-icons;
  93. content: map.get($icons, 'arrow-down');
  94. border: 1px solid $color-input-border;
  95. border-width: 0 0 0 1px;
  96. text-align: center;
  97. line-height: 1.4em;
  98. font-size: 3em;
  99. pointer-events: none;
  100. color: $color-grey-3;
  101. margin: 0 1px 1px 0;
  102. .ie & {
  103. display: none;
  104. }
  105. }
  106. // Override default select padding so the chevron will overlap with long option text
  107. select {
  108. padding-right: 5em;
  109. }
  110. }
  111. // Other text
  112. .help,
  113. .error-message {
  114. border: 1px solid transparent; // ensure visible separation in Windows High Contrast mode
  115. font-size: 0.85em;
  116. font-weight: normal;
  117. margin: 0.5em 0 0;
  118. }
  119. .error-message {
  120. font-size: 1em;
  121. font-weight: bold;
  122. color: $color-text-error;
  123. @media (forced-colors: $media-forced-colours) {
  124. forced-color-adjust: none;
  125. color: $color-text-error-forced-color;
  126. }
  127. &::before {
  128. font-family: $font-wagtail-icons;
  129. vertical-align: -10%;
  130. content: map.get($icons, 'cross');
  131. }
  132. }
  133. .help {
  134. color: $color-grey-2;
  135. }
  136. fieldset:hover > .help,
  137. .field.focused + .help,
  138. .field:focus + .help,
  139. .field:hover + .help,
  140. li.focused > .help {
  141. opacity: 1;
  142. }
  143. .required .field > label:after,
  144. label.required:after {
  145. content: '*';
  146. color: $color-red;
  147. font-weight: bold;
  148. display: inline-block;
  149. margin-left: 0.5em;
  150. line-height: 1em;
  151. font-size: 13px;
  152. }
  153. .error input,
  154. .error textarea,
  155. .error select,
  156. .error .tagit {
  157. border-color: $color-red;
  158. background-color: $color-input-error-bg;
  159. }
  160. // Layouts for particular kinds of of fields
  161. // permanently show checkbox/radio help as they have no focus state
  162. .boolean_field .help,
  163. .radio .help {
  164. opacity: 1;
  165. }
  166. // This is expected to go on the parent of the input/select/textarea
  167. // so in most cases .input
  168. .iconfield, // generic
  169. .date_field,
  170. .time_field,
  171. .date_time_field,
  172. .url_field {
  173. .input {
  174. position: relative;
  175. &:before,
  176. &:after {
  177. font-family: $font-wagtail-icons;
  178. position: absolute;
  179. top: 0.5em;
  180. line-height: 100%;
  181. font-size: 2em;
  182. color: $color-grey-3;
  183. }
  184. &:before {
  185. left: 0.3em;
  186. }
  187. &:after {
  188. right: 0.5em;
  189. }
  190. }
  191. input:not([type=radio]),
  192. input:not([type=checkbox]),
  193. input:not([type=submit]),
  194. input:not([type=button]) {
  195. padding-left: 2.5em;
  196. }
  197. // smaller fields required slight repositioning of icons
  198. &.field-small {
  199. .input {
  200. &:before,
  201. &:after {
  202. font-size: 1.3rem; // REMs are necessary here because IE doesn't treat generated content correctly
  203. top: 0.3em;
  204. }
  205. &:before {
  206. left: 0.5em;
  207. }
  208. &:after {
  209. right: 0.5em;
  210. }
  211. }
  212. }
  213. // special case for search spinners
  214. &.icon-spinner:after {
  215. color: $color-teal;
  216. opacity: 0.8;
  217. text-align: center;
  218. top: 0.3em;
  219. }
  220. }
  221. .date_field,
  222. .date_time_field {
  223. .input:before {
  224. content: map.get($icons, 'date');
  225. }
  226. }
  227. .time_field {
  228. .input:before {
  229. content: map.get($icons, 'time');
  230. }
  231. }
  232. .url_field {
  233. .input:before {
  234. content: map.get($icons, 'link');
  235. }
  236. }
  237. .daterange_field {
  238. input:last-of-type {
  239. margin-top: 1.2em; // Mirrors the label 1.2em top padding.
  240. }
  241. }
  242. // This is specifically for list of radios/checkboxes
  243. .model_multiple_choice_field .input li,
  244. .checkbox_select_multiple .input li,
  245. .multiple_choice_field .input li,
  246. .choice_field .input li {
  247. label {
  248. display: block;
  249. width: auto;
  250. float: none;
  251. padding-top: 0; // Negates padding added to label for the group of fields as a whole
  252. padding-bottom: 0.8em;
  253. }
  254. }
  255. .fields > li,
  256. .field-col {
  257. @include clearfix();
  258. padding-top: 0.5em;
  259. padding-bottom: 1.2em;
  260. }
  261. .field-row {
  262. @include clearfix();
  263. // negative margin the bottom so it doesn't add too much space
  264. margin-bottom: -1.2em;
  265. }
  266. .input {
  267. clear: both;
  268. }
  269. // field sizing and alignment
  270. .field-small {
  271. input,
  272. textarea,
  273. select,
  274. .halloeditor,
  275. .tagit {
  276. border-radius: 3px;
  277. padding: 0.4em 1em;
  278. }
  279. }
  280. .field {
  281. &.col1,
  282. &.col2,
  283. &.col3,
  284. &.col4,
  285. &.col5,
  286. &.col6,
  287. &.col7,
  288. &.col8,
  289. &.col9,
  290. &.col10,
  291. &.col11,
  292. &.col12 { clear: both;}
  293. }
  294. li.inline .field {
  295. &.col1,
  296. &.col2,
  297. &.col3,
  298. &.col4,
  299. &.col5,
  300. &.col6,
  301. &.col7,
  302. &.col8,
  303. &.col9,
  304. &.col10,
  305. &.col11,
  306. &.col12 { clear: none;}
  307. }
  308. // solve gutter issues of inline fields
  309. ul.inline li:first-child,
  310. li.inline:first-child {
  311. margin-left: math.div(-$grid-gutter-width, 2);
  312. }
  313. // search-bars
  314. .search-bar {
  315. .required .field > label:after {
  316. display: none;
  317. }
  318. .button-filter {
  319. height: 2.71em;
  320. border-color: transparent;
  321. }
  322. }
  323. // file drop zones
  324. .drop-zone {
  325. border-radius: 5px;
  326. border: 2px dashed $color-grey-4;
  327. padding: $mobile-nice-padding;
  328. background-color: $color-grey-5;
  329. margin-bottom: 1em;
  330. text-align: center;
  331. .drop-zone-help {
  332. border: 0;
  333. }
  334. &.hovered {
  335. border-color: $color-teal;
  336. background-color: $color-input-focus;
  337. }
  338. }
  339. // Transitions
  340. // stylelint-disable-next-line no-duplicate-selectors
  341. .help {
  342. @include transition(opacity 0.2s ease);
  343. }
  344. .label-uppercase {
  345. .field > label {
  346. text-transform: uppercase;
  347. }
  348. }
  349. @include media-breakpoint-up(sm) {
  350. .help {
  351. opacity: 1;
  352. }
  353. .fields {
  354. max-width: 800px;
  355. }
  356. .field {
  357. @include row();
  358. }
  359. .field-content {
  360. @include column(10, 0);
  361. }
  362. .field-col {
  363. float: left;
  364. padding-left: 0;
  365. // anything less than 4 columns or greater than 6 is impractical
  366. &.col4 {
  367. label {
  368. @include column(2, 0, 4);
  369. }
  370. .field-content {
  371. @include column(2, $padding, 4);
  372. padding-left: 0;
  373. }
  374. }
  375. &.col6 {
  376. label {
  377. @include column(2, 0, 6);
  378. }
  379. .field-content {
  380. @include column(4, $padding, 6);
  381. padding-left: 0;
  382. }
  383. }
  384. }
  385. .label-above {
  386. .field > label,
  387. .field > .field-content {
  388. display: block;
  389. padding: 0 0 0.8em;
  390. float: none;
  391. width: auto;
  392. }
  393. }
  394. }
  395. .field-comment-control {
  396. display: none;
  397. }
  398. .tab-content--comments-enabled {
  399. .field {
  400. position: relative;
  401. }
  402. .field-content {
  403. padding-right: 45px;
  404. @include media-breakpoint-up(sm) {
  405. padding-right: 60px;
  406. }
  407. }
  408. .widget-draftail_rich_text_area .field-content {
  409. padding-right: 0;
  410. }
  411. .field-comment-control {
  412. position: absolute;
  413. display: block;
  414. top: 0;
  415. right: 0;
  416. height: 100%;
  417. line-height: 100%;
  418. &--object {
  419. right: 20px;
  420. @include media-breakpoint-up(lg) {
  421. right: 350px;
  422. }
  423. }
  424. button {
  425. @include transition(opacity 0.2s ease);
  426. border: 0;
  427. background: none;
  428. width: 30px;
  429. height: 30px;
  430. padding: 0;
  431. border-radius: 3px;
  432. position: absolute;
  433. top: 50%;
  434. right: 0;
  435. @include media-breakpoint-up(sm) {
  436. right: 10px;
  437. }
  438. // Hide by default, reveal on hover of parent
  439. @include media-breakpoint-up(md) {
  440. opacity: 0;
  441. pointer-events: none;
  442. transform: translateY(-50%);
  443. right: 0;
  444. }
  445. .icon-reversed {
  446. display: none;
  447. }
  448. &:hover {
  449. cursor: pointer;
  450. // stylelint-disable max-nesting-depth
  451. .icon-default {
  452. display: none;
  453. }
  454. .icon-reversed {
  455. display: block;
  456. }
  457. }
  458. &:focus {
  459. opacity: 1;
  460. pointer-events: initial;
  461. }
  462. > svg {
  463. width: 30px;
  464. height: 30px;
  465. color: $color-teal;
  466. @media (forced-colors: $media-forced-colours) {
  467. color: ButtonText;
  468. border: 1px solid;
  469. }
  470. }
  471. }
  472. }
  473. .field-row .field-comment-control {
  474. top: 0;
  475. }
  476. .field:not(.block_field) {
  477. &:hover {
  478. .field-comment-control button {
  479. opacity: 1;
  480. pointer-events: initial;
  481. }
  482. }
  483. }
  484. .object {
  485. &:hover {
  486. .field-comment-control--object button {
  487. opacity: 1;
  488. pointer-events: initial;
  489. }
  490. }
  491. }
  492. .object.model_choice_field {
  493. .object-help {
  494. right: 153px;
  495. }
  496. }
  497. }