_forms.scss 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. // .tagit {
  42. // appearance: none;
  43. // box-sizing: border-box;
  44. // border-radius: 6px;
  45. // width: 100%;
  46. // font-family: $font-sans;
  47. // border: 1px solid $color-input-border;
  48. // padding: 0.9em 1.2em;
  49. // background-color: $color-fieldset-hover;
  50. // color: $color-text-input;
  51. // font-size: 1.2em;
  52. // font-weight: 300;
  53. //
  54. // &:hover {
  55. // background-color: $color-white;
  56. // }
  57. //
  58. // &:focus {
  59. // background-color: $color-input-focus;
  60. // border-color: $color-input-focus-border;
  61. // }
  62. //
  63. // &:disabled,
  64. // &[disabled],
  65. // &:disabled:hover,
  66. // &[disabled]:hover {
  67. // background-color: inherit;
  68. // cursor: default;
  69. // color: $color-grey-4;
  70. // }
  71. // }
  72. // select boxes
  73. .collection_choice_field .input,
  74. .choice_field .input,
  75. .model_choice_field .input,
  76. .typed_choice_field .input {
  77. position: relative;
  78. // Add select arrow back on browsers where native ui has been removed
  79. select ~ span:after {
  80. border-radius: 0 6px 6px 0;
  81. z-index: 0;
  82. position: absolute;
  83. right: 0;
  84. top: 1px;
  85. bottom: 0;
  86. width: 1.5em;
  87. font-family: $font-wagtail-icons;
  88. content: map.get($icons, 'arrow-down'); // UI-Redesign: to be removed
  89. border: 1px solid $color-input-border;
  90. border-width: 0 0 0 1px;
  91. text-align: center;
  92. line-height: 1.4em;
  93. font-size: 3em;
  94. pointer-events: none;
  95. color: $color-grey-3;
  96. margin: 0 1px 1px 0;
  97. .ie & {
  98. display: none;
  99. }
  100. }
  101. // Override default select padding so the chevron will overlap with long option text
  102. select {
  103. padding-right: 5em;
  104. }
  105. }
  106. // Other text
  107. .help,
  108. .error-message {
  109. border: 1px solid transparent; // ensure visible separation in Windows High Contrast mode
  110. font-size: 0.85em;
  111. font-weight: normal;
  112. margin: 0.5em 0 0;
  113. }
  114. .error-message {
  115. font-size: 1em;
  116. font-weight: bold;
  117. color: $color-text-error;
  118. @media (forced-colors: $media-forced-colours) {
  119. forced-color-adjust: none;
  120. color: $color-text-error-forced-color;
  121. }
  122. // UI-Redesign: to be added via js and styled here
  123. &::before {
  124. font-family: $font-wagtail-icons;
  125. vertical-align: -10%;
  126. content: map.get($icons, 'cross');
  127. }
  128. }
  129. .help {
  130. color: $color-grey-2;
  131. }
  132. fieldset:hover > .help,
  133. .field.focused + .help,
  134. .field:focus + .help,
  135. .field:hover + .help,
  136. li.focused > .help {
  137. opacity: 1;
  138. }
  139. .required .field > label:after,
  140. label.required:after {
  141. content: '*';
  142. color: $color-red;
  143. font-weight: bold;
  144. display: inline-block;
  145. margin-left: 0.5em;
  146. line-height: 1em;
  147. font-size: 13px;
  148. }
  149. .error input,
  150. .error textarea,
  151. .error select,
  152. .error .tagit {
  153. border-color: $color-red;
  154. background-color: $color-input-error-bg;
  155. }
  156. // Layouts for particular kinds of of fields
  157. // permanently show checkbox/radio help as they have no focus state
  158. .boolean_field .help,
  159. .radio .help {
  160. opacity: 1;
  161. }
  162. // This is expected to go on the parent of the input/select/textarea
  163. // so in most cases .input
  164. .iconfield, // generic
  165. .date_field,
  166. .time_field,
  167. .date_time_field,
  168. .url_field {
  169. .input {
  170. position: relative;
  171. &:before,
  172. &:after {
  173. font-family: $font-wagtail-icons;
  174. position: absolute;
  175. top: 0.5em;
  176. line-height: 100%;
  177. font-size: 2em;
  178. color: $color-grey-3;
  179. }
  180. &:before {
  181. left: 0.3em;
  182. }
  183. &:after {
  184. right: 0.5em;
  185. }
  186. }
  187. input:not([type='radio']),
  188. input:not([type='checkbox']),
  189. input:not([type='submit']),
  190. input:not([type='button']) {
  191. padding-left: 2.5em;
  192. }
  193. // smaller fields required slight repositioning of icons
  194. &.field-small {
  195. .input {
  196. &:before,
  197. &:after {
  198. font-size: 1.3rem; // REMs are necessary here because IE doesn't treat generated content correctly
  199. top: 0.3em;
  200. }
  201. &:before {
  202. left: 0.5em;
  203. }
  204. &:after {
  205. right: 0.5em;
  206. }
  207. }
  208. }
  209. // special case for search spinners
  210. &.icon-spinner:after {
  211. color: $color-teal;
  212. opacity: 0.8;
  213. text-align: center;
  214. top: 0.3em;
  215. }
  216. }
  217. .date_field,
  218. .date_time_field {
  219. .input:before {
  220. content: map.get($icons, 'date'); // UI-Redesign: To be removed
  221. }
  222. }
  223. .time_field {
  224. .input:before {
  225. content: map.get($icons, 'time'); // UI-Redesign: To be removed
  226. }
  227. }
  228. .url_field {
  229. .input:before {
  230. content: map.get($icons, 'link'); // UI-Redesign: To be removed
  231. }
  232. }
  233. .daterange_field {
  234. input:last-of-type {
  235. margin-top: 1.2em; // Mirrors the label 1.2em top padding.
  236. }
  237. }
  238. // This is specifically for list of radios/checkboxes
  239. .model_multiple_choice_field .input li,
  240. .checkbox_select_multiple .input li,
  241. .multiple_choice_field .input li,
  242. .choice_field .input li {
  243. label {
  244. display: inline-flex;
  245. align-items: center;
  246. width: auto;
  247. float: none;
  248. padding-top: 0; // Negates padding added to label for the group of fields as a whole
  249. padding-bottom: 0.8em;
  250. }
  251. }
  252. .fields > li,
  253. .field-col {
  254. @include clearfix();
  255. padding-top: 0.5em;
  256. padding-bottom: 1.2em;
  257. }
  258. .field-row {
  259. @include clearfix();
  260. // negative margin the bottom so it doesn't add too much space
  261. margin-bottom: -1.2em;
  262. }
  263. .input {
  264. clear: both;
  265. }
  266. // field sizing and alignment
  267. .field-small {
  268. input,
  269. textarea,
  270. select,
  271. .tagit {
  272. border-radius: 3px;
  273. padding: 0.4em 1em;
  274. }
  275. }
  276. .field {
  277. &.col1,
  278. &.col2,
  279. &.col3,
  280. &.col4,
  281. &.col5,
  282. &.col6,
  283. &.col7,
  284. &.col8,
  285. &.col9,
  286. &.col10,
  287. &.col11,
  288. &.col12 {
  289. clear: both;
  290. }
  291. }
  292. li.inline .field {
  293. &.col1,
  294. &.col2,
  295. &.col3,
  296. &.col4,
  297. &.col5,
  298. &.col6,
  299. &.col7,
  300. &.col8,
  301. &.col9,
  302. &.col10,
  303. &.col11,
  304. &.col12 {
  305. clear: none;
  306. }
  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: 35px;
  464. height: 35px;
  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. }