mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 17:32:41 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
import tippy from "tippy.js"
|
||||
import type {Action} from "svelte/action"
|
||||
import type {ComponentType, SvelteComponent} from "svelte"
|
||||
import tippy from "tippy.js";
|
||||
import type { Action } from "svelte/action";
|
||||
import type { ComponentType, SvelteComponent } from "svelte";
|
||||
|
||||
export const popup: Action<HTMLButtonElement, ComponentType> = (node, Component) => {
|
||||
let component: SvelteComponent | undefined
|
||||
let target: HTMLElement | undefined
|
||||
export const popup: Action<HTMLButtonElement, ComponentType> = (
|
||||
node,
|
||||
Component,
|
||||
) => {
|
||||
let component: SvelteComponent | undefined;
|
||||
let target: HTMLElement | undefined;
|
||||
const edit = tippy(node, {
|
||||
interactive: true,
|
||||
trigger: "click",
|
||||
onShow(instance) {
|
||||
target = instance.popper.querySelector(".tippy-content") as HTMLElement
|
||||
target.classList.add("active")
|
||||
component ??= new Component({target})
|
||||
target = instance.popper.querySelector(".tippy-content") as HTMLElement;
|
||||
target.classList.add("active");
|
||||
component ??= new Component({ target });
|
||||
},
|
||||
onHidden() {
|
||||
component?.$destroy()
|
||||
target?.classList.remove("active")
|
||||
component = undefined
|
||||
component?.$destroy();
|
||||
target?.classList.remove("active");
|
||||
component = undefined;
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
edit.destroy()
|
||||
edit.destroy();
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user