add tooltip stuff

[deploy]
This commit is contained in:
2023-07-18 01:40:30 +02:00
parent 4eb1e8c049
commit b04ed7fe7f
24 changed files with 1161 additions and 5143 deletions

View File

@@ -0,0 +1,31 @@
import tippy from "tippy.js"
import InputEdit from "$lib/components/InputEdit.svelte"
import type {Action} from "svelte/action"
export const editableLayout: Action<HTMLButtonElement, {id: number; quadrant: number}> = (
node,
{id, quadrant},
) => {
let component: InputEdit | undefined
const edit = tippy(node, {
interactive: true,
appendTo: document.body,
placement: (["top", "right", "bottom", "left"] as const)[quadrant],
onShow(instance) {
component ??= new InputEdit({
target: instance.popper.querySelector(".tippy-content")!,
props: {id},
})
},
onHidden() {
component?.$destroy()
component = undefined
},
})
return {
destroy() {
edit.destroy()
},
}
}