Add visual elements for pinned fields
This commit is contained in:
parent
d13bd1096d
commit
d1bca9e4d9
@ -135,3 +135,15 @@ button.highlighted {
|
|||||||
color: var(--link);
|
color: var(--link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sticky-icon {
|
||||||
|
color: var(--bs-dark);
|
||||||
|
|
||||||
|
.nightMode & {
|
||||||
|
color: var(--bs-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
color: var(--bs-danger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -211,21 +211,55 @@ export class EditingArea extends HTMLDivElement {
|
|||||||
|
|
||||||
customElements.define("anki-editing-area", EditingArea, { extends: "div" });
|
customElements.define("anki-editing-area", EditingArea, { extends: "div" });
|
||||||
|
|
||||||
|
export class LabelContainer extends HTMLDivElement {
|
||||||
|
sticky: HTMLSpanElement
|
||||||
|
label: HTMLSpanElement
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.className = "d-flex";
|
||||||
|
|
||||||
|
this.sticky = document.createElement("span");
|
||||||
|
this.sticky.className = "bi bi-pin-angle-fill me-1 sticky-icon";
|
||||||
|
this.appendChild(this.sticky);
|
||||||
|
|
||||||
|
this.label = document.createElement("span");
|
||||||
|
this.label.className = "fieldname";
|
||||||
|
this.appendChild(this.label);
|
||||||
|
|
||||||
|
this.toggleSticky = this.toggleSticky.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
connectedCallback(): void {
|
||||||
|
this.sticky.addEventListener("click", this.toggleSticky);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback(): void {
|
||||||
|
this.sticky.removeEventListener("click", this.toggleSticky);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize(labelName: string): void {
|
||||||
|
this.label.innerText = labelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleSticky(): void {
|
||||||
|
this.sticky.classList.toggle('is-active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
customElements.define("anki-label-container", LabelContainer, { extends: "div" });
|
||||||
|
|
||||||
export class EditorField extends HTMLDivElement {
|
export class EditorField extends HTMLDivElement {
|
||||||
labelContainer: HTMLDivElement;
|
labelContainer: LabelContainer;
|
||||||
label: HTMLSpanElement;
|
|
||||||
editingArea: EditingArea;
|
editingArea: EditingArea;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.labelContainer = document.createElement("div");
|
this.labelContainer = document.createElement("div", {
|
||||||
this.labelContainer.className = "fname";
|
is: "anki-label-container",
|
||||||
|
}) as LabelContainer;
|
||||||
this.appendChild(this.labelContainer);
|
this.appendChild(this.labelContainer);
|
||||||
|
|
||||||
this.label = document.createElement("span");
|
|
||||||
this.label.className = "fieldname";
|
|
||||||
this.labelContainer.appendChild(this.label);
|
|
||||||
|
|
||||||
this.editingArea = document.createElement("div", {
|
this.editingArea = document.createElement("div", {
|
||||||
is: "anki-editing-area",
|
is: "anki-editing-area",
|
||||||
}) as EditingArea;
|
}) as EditingArea;
|
||||||
@ -248,7 +282,7 @@ export class EditorField extends HTMLDivElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize(label: string, color: string, content: string): void {
|
initialize(label: string, color: string, content: string): void {
|
||||||
this.label.innerText = label;
|
this.labelContainer.initialize(label);
|
||||||
this.editingArea.initialize(color, content);
|
this.editingArea.initialize(color, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user