0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00
wagtail/client/scss/components/forms/_field.scss
Thibaud Colas f82ff1e22c
Move help text above all form fields (#10302)
* Move all help text above fields
* Adjust vertical spacing of form fields and panels
* Move the page title’s help text below the field
* Release notes
2023-03-31 17:05:20 +01:00

83 lines
2.2 KiB
SCSS
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@use 'sass:map';
/**
* The field component handles form fields layout and ancillary elements such as error messages and help text.
* It doesnt handle the style of the widgets, which are implemented independently for each widget type.
*
* Take special care when changing the field component: it can be used in forms but also in filters, headers, and any
* other arbitrary part of the UI. It has to be very flexible to accommodate for all those use cases.
*/
.w-field {
position: relative;
}
.w-field__errors {
.error-message {
@apply w-label-2;
color: theme('colors.critical.200');
display: inline-block;
margin: 0;
margin-bottom: theme('spacing.[2.5]');
}
}
.w-field__errors-icon {
// Position and size the icon according to the text size.
position: relative;
top: 0.125em;
width: 1em;
height: 1em;
margin-inline-end: 0.625rem;
color: theme('colors.critical.200');
// Avoid displaying the error message icon if we already have an icon.
+ .error-message::before {
display: none;
}
}
.w-field__label {
@apply w-label-3;
display: block;
margin-bottom: 0;
}
.w-field__wrapper {
@include max-form-width();
// This is primarily helpful to add margins between fields, but fields can often
// be wrapped into groups (for example a row), so its safer to add a margin regardless
// of what the next element is.
margin-bottom: theme('spacing.5');
// Inside of listing tables we don't need the bottom margin because the table row will handle it.
table.listing td & {
margin-bottom: 0;
}
}
.w-field__input {
position: relative;
padding-top: theme('spacing.[2.5]');
// This padding gives room for widgets such as comments beside of inputs
padding-inline-end: calc($comment-button-size + $comment-button-space);
}
.w-field__icon {
$size: theme('spacing.4');
$offset: calc($text-input-height / 2 - $size / 2);
width: $size;
height: $size;
color: theme('colors.primary.DEFAULT');
position: absolute;
// Top padding of text input and half of text size.
top: $offset;
inset-inline-start: $offset;
pointer-events: none;
+ input {
// Allows for a nice square around the icon.
padding-inline-start: $text-input-height;
}
}