2022-07-25 14:20:19 +00:00
|
|
|
|
@use 'sass:map';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The field component handles form fields’ layout and ancillary elements such as error messages and help text.
|
|
|
|
|
* It doesn’t 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;
|
2023-05-25 06:57:52 +00:00
|
|
|
|
color: theme('colors.text-error');
|
2022-07-25 14:20:19 +00:00
|
|
|
|
display: inline-block;
|
|
|
|
|
margin: 0;
|
2023-03-31 21:49:40 +00:00
|
|
|
|
margin-top: theme('spacing.[0.5]');
|
2022-07-25 14:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.w-field__errors-icon {
|
|
|
|
|
// Position and size the icon according to the text size.
|
|
|
|
|
position: relative;
|
|
|
|
|
top: 0.125em;
|
|
|
|
|
width: 1em;
|
|
|
|
|
height: 1em;
|
2022-10-07 07:40:13 +00:00
|
|
|
|
margin-inline-end: 0.625rem;
|
2023-05-25 06:57:52 +00:00
|
|
|
|
color: theme('colors.text-error');
|
2022-07-25 14:20:19 +00:00
|
|
|
|
|
|
|
|
|
// Avoid displaying the error message icon if we already have an icon.
|
|
|
|
|
+ .error-message::before {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.w-field__label {
|
2023-03-27 16:04:23 +00:00
|
|
|
|
@apply w-label-2;
|
2022-07-25 14:20:19 +00:00
|
|
|
|
display: block;
|
2023-04-07 12:04:58 +00:00
|
|
|
|
margin-top: 0;
|
2023-03-31 16:05:20 +00:00
|
|
|
|
margin-bottom: 0;
|
2022-07-25 14:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.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 it’s safer to add a margin regardless
|
|
|
|
|
// of what the next element is.
|
2023-03-31 21:49:40 +00:00
|
|
|
|
margin-bottom: $form-field-spacing;
|
2022-10-07 07:40:13 +00:00
|
|
|
|
|
2023-03-31 21:49:40 +00:00
|
|
|
|
// Inside of listing tables we don't need margins because the table row will handle them.
|
2022-10-07 07:40:13 +00:00
|
|
|
|
table.listing td & {
|
|
|
|
|
margin-bottom: 0;
|
2023-03-31 21:49:40 +00:00
|
|
|
|
|
|
|
|
|
.w-field__input {
|
|
|
|
|
margin-top: 0;
|
|
|
|
|
}
|
2022-10-07 07:40:13 +00:00
|
|
|
|
}
|
2022-07-25 14:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.w-field__input {
|
|
|
|
|
position: relative;
|
2023-03-31 21:49:40 +00:00
|
|
|
|
margin-top: theme('spacing.[2.5]');
|
2022-07-25 14:20:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.w-field__icon {
|
|
|
|
|
$size: theme('spacing.4');
|
|
|
|
|
$offset: calc($text-input-height / 2 - $size / 2);
|
|
|
|
|
width: $size;
|
|
|
|
|
height: $size;
|
2023-04-19 05:58:14 +00:00
|
|
|
|
color: theme('colors.icon-primary');
|
2022-07-25 14:20:19 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|