All files / src/components close-button.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10        507x 507x 507x 507x    
import { setIcon, type WorkspaceLeaf } from "obsidian";
 
/** Close control for a sidebar view; sidebar leaves hide the view header that would otherwise carry it. */
export function addCloseButton(container: HTMLElement, leaf: WorkspaceLeaf, label: string): HTMLElement {
    const button = container.createEl("button", { cls: "lilbee-panel-close", attr: { "aria-label": label } });
    setIcon(button, "x");
    button.addEventListener("click", () => leaf.detach());
    return button;
}