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