_forms.scss 11 KB

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