2023-10-04 13:27:02 +00:00
|
|
|
@include comfortable {
|
|
|
|
--editable-text-padding-inline: 4px;
|
|
|
|
--editable-text-padding-block: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@include compact {
|
|
|
|
--editable-text-padding-inline: 4px;
|
|
|
|
--editable-text-padding-block: 1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
editable-text {
|
2023-12-01 18:53:38 +00:00
|
|
|
--min-visible-lines: 0;
|
2024-01-11 06:49:16 +00:00
|
|
|
--max-visible-lines: 6;
|
2023-12-01 18:53:38 +00:00
|
|
|
|
|
|
|
&[multiline] {
|
|
|
|
--min-visible-lines: 5;
|
|
|
|
--max-visible-lines: 20;
|
|
|
|
}
|
|
|
|
|
2023-12-21 14:18:57 +00:00
|
|
|
&[nowrap] {
|
|
|
|
--min-visible-lines: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
&[tight] {
|
|
|
|
@include comfortable {
|
|
|
|
--editable-text-padding-inline: 4px;
|
|
|
|
--editable-text-padding-block: 2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@include compact {
|
|
|
|
--editable-text-padding-inline: 3px;
|
|
|
|
--editable-text-padding-block: 1px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
span {
|
2023-10-04 13:27:02 +00:00
|
|
|
visibility: hidden;
|
2023-12-21 20:10:04 +00:00
|
|
|
margin: 0;
|
|
|
|
border: 1px solid transparent;
|
2023-12-21 14:18:57 +00:00
|
|
|
width: fit-content;
|
2024-01-10 04:42:38 +00:00
|
|
|
white-space: pre;
|
2023-12-21 20:10:04 +00:00
|
|
|
padding: var(--editable-text-padding-block) var(--editable-text-padding-inline);
|
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;
|
|
|
|
scrollbar-gutter: stable;
|
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;
|
2023-12-01 18:53:38 +00:00
|
|
|
max-height: calc(2ex * var(--max-visible-lines));
|
2024-02-02 08:05:59 +00:00
|
|
|
// Somehow this hides scroll arrows on windows when the content is short or empty
|
|
|
|
scrollbar-width: thin;
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
2023-11-28 10:58:59 +00:00
|
|
|
.input {
|
2024-01-10 20:42:53 +00:00
|
|
|
--width-focus-border: 1px;
|
|
|
|
--radius-focus-border: 5px;
|
|
|
|
|
2024-02-01 08:01:19 +00:00
|
|
|
// No focus ring for read-only fields
|
|
|
|
&:read-only {
|
|
|
|
--width-focus-border: 0px;
|
|
|
|
}
|
2023-12-21 14:18:57 +00:00
|
|
|
@include focus-ring;
|
2023-11-28 10:58:59 +00:00
|
|
|
// Necessary for consistent padding, even if it's actually an <input>
|
|
|
|
-moz-default-appearance: textarea;
|
|
|
|
|
2023-12-01 18:53:38 +00:00
|
|
|
min-height: calc(2ex * 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;
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover:not(:read-only, :focus) {
|
|
|
|
border-radius: 5px;
|
2023-12-21 20:10:04 +00:00
|
|
|
background-color: var(--fill-quinary);
|
2023-12-21 14:18:57 +00:00
|
|
|
box-shadow: 0 0 0 1px var(--fill-quinary);
|
2023-10-04 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
::placeholder {
|
|
|
|
color: var(--fill-tertiary);
|
|
|
|
}
|
|
|
|
}
|
2023-12-21 14:18:57 +00:00
|
|
|
|
|
|
|
&[multiline] {
|
|
|
|
.input {
|
|
|
|
min-height: 5em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&[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
|
|
|
}
|