Files
element-web/res/css/views/elements/_Field.pcss
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

180 lines
4.3 KiB
Plaintext
Raw Normal View History

2019-01-19 22:11:20 -06:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2019-2024 New Vector Ltd.
2019-01-19 22:11:20 -06:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
2024-09-09 14:57:16 +01:00
Please see LICENSE files in the repository root for full details.
2019-01-19 22:11:20 -06:00
*/
2022-07-15 14:53:23 +01:00
/* TODO: Consider unifying with general input styles in _light.pcss */
2019-01-19 22:11:20 -06:00
.mx_Field {
2019-03-05 15:13:12 +00:00
display: flex;
2019-06-17 18:29:03 +02:00
flex: 1;
min-width: 0;
2019-01-19 22:11:20 -06:00
position: relative;
margin: 1em 0;
border-radius: 8px;
2019-03-01 16:45:33 +00:00
transition: border-color 0.25s;
border: 1px solid var(--cpd-color-border-interactive-secondary);
2019-01-19 22:11:20 -06:00
}
2019-03-05 15:13:12 +00:00
.mx_Field_prefix {
border-right: 1px solid var(--cpd-color-border-interactive-secondary);
2019-03-05 15:13:12 +00:00
}
2019-09-20 17:45:14 +02:00
.mx_Field_postfix {
border-left: 1px solid var(--cpd-color-border-interactive-secondary);
2019-09-20 17:45:14 +02:00
}
2019-01-22 19:25:09 -07:00
.mx_Field input,
.mx_Field select,
.mx_Field textarea {
2023-06-29 11:30:25 +01:00
font: var(--cpd-font-body-md-regular);
2019-03-01 16:45:33 +00:00
border: none;
/* Even without a border here, we still need this avoid overlapping the rounded */
/* corners on the field above. */
border-radius: 8px;
padding: 8px 9px;
2021-08-12 11:27:12 +02:00
color: $primary-content;
2021-08-12 11:10:47 +02:00
background-color: $background;
flex: 1;
2019-11-15 15:37:43 +01:00
min-width: 0;
2019-01-19 22:11:20 -06:00
}
.mx_Field select {
-moz-appearance: none;
-webkit-appearance: none;
text-overflow: ellipsis;
}
/* Can't add pseudo-elements to a select directly, so we use its parent. */
.mx_Field_select::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 4px;
width: 18px;
height: 18px;
mask: url("@vector-im/compound-design-tokens/icons/chevron-down.svg");
mask-repeat: no-repeat;
mask-position: center;
mask-size: contain;
2021-08-12 11:27:12 +02:00
background-color: $primary-content;
z-index: 1;
pointer-events: none;
}
2019-03-01 16:45:33 +00:00
.mx_Field:focus-within {
2021-11-29 13:52:09 +01:00
border-color: $accent-alt;
2019-03-01 16:45:33 +00:00
}
2019-01-22 19:25:09 -07:00
.mx_Field input:focus,
.mx_Field select:focus,
.mx_Field textarea:focus {
2019-01-19 22:11:20 -06:00
outline: 0;
}
.mx_Field input::placeholder,
.mx_Field textarea::placeholder {
2019-01-19 22:11:20 -06:00
transition: color 0.25s ease-in 0s;
color: transparent;
}
.mx_Field input:placeholder-shown:focus::placeholder,
2021-11-01 23:44:42 -06:00
.mx_Field textarea:placeholder-shown:focus::placeholder,
.mx_Field.mx_Field_placeholderIsHint input::placeholder {
2019-01-19 22:11:20 -06:00
transition: color 0.25s ease-in 0.1s;
2021-11-29 13:52:09 +01:00
color: $info-plinth-fg-color;
2019-01-19 22:11:20 -06:00
}
.mx_Field label {
2024-01-02 18:56:39 +00:00
transition:
font-size 0.25s ease-out 0.1s,
color 0.25s ease-out 0.1s,
transform 0.25s ease-out 0.1s,
2019-01-19 22:11:20 -06:00
background-color 0.25s ease-out 0.1s;
background-color: transparent;
2023-06-29 11:30:25 +01:00
font: var(--cpd-font-body-md-regular);
color: var(--cpd-color-text-secondary);
2021-09-11 02:03:55 -05:00
transform: translateY(0);
2019-01-19 22:11:20 -06:00
position: absolute;
left: 0px;
2019-01-21 10:09:33 -06:00
margin: 7px 8px;
2019-01-19 22:11:20 -06:00
padding: 2px;
pointer-events: none; /* Allow clicks to fall through to the input */
2019-03-04 12:02:23 +00:00
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: calc(100% - 20px); /* 100% of parent minus margin and padding */
2019-01-19 22:11:20 -06:00
}
2019-07-10 16:55:03 +01:00
.mx_Field_labelAlwaysTopLeft label,
2019-07-11 13:14:20 +01:00
.mx_Field select + label /* Always show a select's label on top to not collide with the value */,
2019-01-19 22:11:20 -06:00
.mx_Field input:focus + label,
2019-01-22 19:25:09 -07:00
.mx_Field input:not(:placeholder-shown) + label,
.mx_Field textarea:focus + label,
2019-07-10 16:55:03 +01:00
.mx_Field textarea:not(:placeholder-shown) + label {
2024-01-02 18:56:39 +00:00
transition:
font-size 0.25s ease-out 0s,
color 0.25s ease-out 0s,
transform 0.25s ease-out 0s,
2019-01-19 22:11:20 -06:00
background-color 0.25s ease-out 0s;
2020-03-31 15:26:23 +01:00
font-size: $font-10px;
2021-09-11 02:03:55 -05:00
transform: translateY(-13px);
padding: 0 2px;
background-color: $background;
2019-02-27 13:23:45 +00:00
pointer-events: initial;
2019-01-19 22:11:20 -06:00
}
2019-01-22 19:25:09 -07:00
.mx_Field input:focus + label,
.mx_Field select:focus + label,
.mx_Field textarea:focus + label {
2021-11-29 13:52:09 +01:00
color: $accent-alt;
2019-01-19 22:11:20 -06:00
}
2019-01-25 09:10:16 -07:00
.mx_Field select:disabled,
.mx_Field select:disabled + label,
.mx_Field input:disabled,
.mx_Field input:disabled + label,
.mx_Field textarea:disabled,
.mx_Field textarea:disabled + label {
background-color: $background;
2021-11-29 13:52:09 +01:00
color: $info-plinth-fg-color;
}
2019-03-07 14:16:39 +00:00
.mx_Field_valid {
&.mx_Field,
&.mx_Field:focus-within {
2021-11-11 14:37:29 +01:00
border-color: $accent;
2019-03-07 14:16:39 +00:00
}
&.mx_Field label,
&.mx_Field:focus-within label {
2021-11-11 14:37:29 +01:00
color: $accent;
2019-03-07 14:16:39 +00:00
}
}
.mx_Field_invalid {
&.mx_Field,
&.mx_Field:focus-within {
2021-11-11 14:37:29 +01:00
border-color: $alert;
2019-03-07 14:16:39 +00:00
}
&.mx_Field label,
&.mx_Field:focus-within label {
2021-11-11 14:37:29 +01:00
color: $alert;
2019-03-07 14:16:39 +00:00
}
2019-02-01 00:36:19 +01:00
}
/* Customise other components when placed inside a Field */
.mx_Field .mx_Dropdown_input {
border: initial;
border-radius: initial;
}
.mx_Field .mx_CountryDropdown {
2023-06-29 11:30:25 +01:00
width: fit-content;
}