mirror of
https://github.com/zoldar/jenot.git
synced 2026-01-03 06:22:55 +00:00
Implement better empty state for label
This commit is contained in:
parent
ca0f954b14
commit
0ac303b6ef
2 changed files with 20 additions and 2 deletions
|
|
@ -186,7 +186,17 @@ class EditableArea extends HTMLElement {
|
|||
}
|
||||
|
||||
#sync() {
|
||||
this.displayElement.replaceChildren(...renderText(this.inputElement.value));
|
||||
const value = this.inputElement.value;
|
||||
|
||||
if (value.trim() === "") {
|
||||
this.classList.add("empty");
|
||||
this.classList.remove("non-empty");
|
||||
} else {
|
||||
this.classList.remove("empty");
|
||||
this.classList.add("non-empty");
|
||||
}
|
||||
|
||||
this.displayElement.replaceChildren(...renderText(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
--shadow-color: rgb(0 0 0 / 0.8);
|
||||
--button-background: lightgray;
|
||||
--inactive-color: gray;
|
||||
--placeholder-text: #999;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
|
@ -24,6 +25,7 @@
|
|||
--shadow-color: rgb(211 211 211 / 0.8);
|
||||
--button-background: silver;
|
||||
--inactive-color: lightgray;
|
||||
--placeholder-text: #999;
|
||||
}
|
||||
|
||||
html {
|
||||
|
|
@ -243,7 +245,8 @@ task-list ul {
|
|||
|
||||
/* Note form */
|
||||
|
||||
note-form:focus-within .title {
|
||||
note-form:focus-within .title,
|
||||
note-form .title:has(.non-empty) {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
@ -253,6 +256,11 @@ note-form .title {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
note-form .title .empty .display::before {
|
||||
content: "Title";
|
||||
color: var(--placeholder-text);
|
||||
}
|
||||
|
||||
note-form .content {
|
||||
min-height: 2.5em;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue