_forms.scss 12 KB

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