2023-10-04 13:27:02 +00:00
|
|
|
@include comfortable {
|
|
|
|
--editable-text-padding-inline: 4px;
|
|
|
|
--editable-text-padding-block: 4px;
|
2024-05-10 12:23:26 +00:00
|
|
|
|
|
|
|
--editable-text-tight-padding-inline: 4px;
|
|
|
|
--editable-text-tight-padding-block: 2px;
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@include compact {
|
|
|
|
--editable-text-padding-inline: 4px;
|
|
|
|
--editable-text-padding-block: 1px;
|
2024-05-10 12:23:26 +00:00
|
|
|
|
|
|
|
--editable-text-tight-padding-inline: 3px;
|
|
|
|
--editable-text-tight-padding-block: 1px;
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
editable-text {
|
2024-02-02 08:53:23 +00:00
|
|
|
// Default variables overriden by max-lines, min-lines attribute
|
|
|
|
--min-visible-lines: 1;
|
|
|
|
--max-visible-lines: 1;
|
2023-12-21 14:18:57 +00:00
|
|
|
|
|
|
|
&[tight] {
|
2024-05-10 12:23:26 +00:00
|
|
|
--editable-text-padding-inline: var(--editable-text-tight-padding-inline);
|
|
|
|
--editable-text-padding-block: var(--editable-text-tight-padding-block);
|
2023-12-21 14:18:57 +00:00
|
|
|
}
|
|
|
|
|
2023-10-04 13:27:02 +00:00
|
|
|
// Fun auto-sizing approach from CSSTricks:
|
|
|
|
// https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
|
|
|
|
|
|
|
|
display: grid;
|
2024-01-22 16:37:41 +00:00
|
|
|
scrollbar-color: var(--color-scrollbar) var(--color-scrollbar-background);
|
2023-10-04 13:27:02 +00:00
|
|
|
|
2023-12-21 14:18:57 +00:00
|
|
|
&:not([nowrap])::after {
|
|
|
|
content: attr(value) ' ';
|
|
|
|
visibility: hidden;
|
2024-01-11 06:45:23 +00:00
|
|
|
border: 1px solid transparent;
|
2023-10-04 13:27:02 +00:00
|
|
|
padding: var(--editable-text-padding-block) var(--editable-text-padding-inline);
|
|
|
|
font: inherit;
|
|
|
|
line-height: inherit;
|
2024-01-26 07:13:16 +00:00
|
|
|
overflow: hidden;
|
2023-12-21 14:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:not([nowrap])::after, &:not([nowrap]) .input {
|
|
|
|
grid-area: 1 / 1 / 2 / 2;
|
|
|
|
overflow-wrap: anywhere;
|
2023-10-04 13:27:02 +00:00
|
|
|
white-space: pre-wrap;
|
2024-02-02 08:53:23 +00:00
|
|
|
scrollbar-width: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&[max-lines] {
|
|
|
|
&::after, .input {
|
2024-02-27 19:31:14 +00:00
|
|
|
max-height: calc(var(--line-height) * var(--max-visible-lines));
|
2024-02-02 08:53:23 +00:00
|
|
|
scrollbar-width: auto;
|
|
|
|
}
|
|
|
|
&::after {
|
|
|
|
scrollbar-gutter: stable;
|
|
|
|
}
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
2023-11-28 10:58:59 +00:00
|
|
|
.input {
|
2024-03-02 07:51:55 +00:00
|
|
|
border-radius: 5px;
|
2024-01-10 20:42:53 +00:00
|
|
|
|
2024-02-01 08:01:19 +00:00
|
|
|
// No focus ring for read-only fields
|
|
|
|
&:read-only {
|
|
|
|
--width-focus-border: 0px;
|
2024-03-02 07:51:55 +00:00
|
|
|
--width-focus-outer-border: 0px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media not (-moz-platform: windows) {
|
|
|
|
@include focus-ring(true);
|
2024-02-01 08:01:19 +00:00
|
|
|
}
|
2024-03-11 06:25:26 +00:00
|
|
|
// Do not use default Windows focus-ring
|
|
|
|
@media (-moz-platform: windows) {
|
|
|
|
&:focus-visible {
|
|
|
|
outline: none;
|
|
|
|
box-shadow: 0 0 0 var(--width-focus-border) var(--color-focus-border);
|
|
|
|
--width-focus-border: 1px;
|
|
|
|
--color-focus-border: var(--color-accent);
|
|
|
|
}
|
|
|
|
}
|
2023-11-28 10:58:59 +00:00
|
|
|
// Necessary for consistent padding, even if it's actually an <input>
|
|
|
|
-moz-default-appearance: textarea;
|
|
|
|
|
2024-02-27 19:31:14 +00:00
|
|
|
min-height: calc(var(--line-height) * var(--min-visible-lines));
|
2023-10-04 13:27:02 +00:00
|
|
|
margin: 0;
|
2023-12-21 14:18:57 +00:00
|
|
|
border: 1px solid transparent;
|
|
|
|
|
|
|
|
font: inherit;
|
|
|
|
line-height: inherit;
|
|
|
|
color: inherit;
|
|
|
|
padding: var(--editable-text-padding-block) var(--editable-text-padding-inline);
|
|
|
|
|
2023-10-04 13:27:02 +00:00
|
|
|
&:read-only, &:not(:focus) {
|
|
|
|
appearance: none;
|
2024-03-11 06:25:26 +00:00
|
|
|
background: transparent;
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:hover:not(:read-only, :focus) {
|
2024-03-11 06:25:26 +00:00
|
|
|
background: var(--fill-quinary);
|
2024-03-02 07:51:55 +00:00
|
|
|
box-shadow: 0 0 0 1px var(--fill-quinary);
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
2024-03-11 06:25:26 +00:00
|
|
|
|
|
|
|
&:focus {
|
|
|
|
background: var(--material-background);
|
|
|
|
}
|
2023-10-04 13:27:02 +00:00
|
|
|
|
|
|
|
::placeholder {
|
|
|
|
color: var(--fill-tertiary);
|
|
|
|
}
|
|
|
|
}
|
2023-12-21 14:18:57 +00:00
|
|
|
&[nowrap] {
|
|
|
|
.input:not(:focus, :hover) {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 16:37:41 +00:00
|
|
|
&[hidden] {
|
2023-12-21 14:18:57 +00:00
|
|
|
display: none;
|
|
|
|
}
|
2024-01-22 19:08:13 +00:00
|
|
|
textarea {
|
2024-01-26 07:13:16 +00:00
|
|
|
// Per https://stackoverflow.com/a/22700700, somehow this removes an extra half-line
|
|
|
|
// at the bottom of textarea on all platforms with non-overlay scrollbars
|
2024-01-22 19:08:13 +00:00
|
|
|
overflow-x: hidden;
|
2024-01-26 07:13:16 +00:00
|
|
|
|
|
|
|
// Match the gutters we apply to ::after
|
|
|
|
overflow-y: scroll;
|
2023-12-21 14:18:57 +00:00
|
|
|
}
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|