mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 09:23:00 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import type {Action} from "svelte/action"
|
||||
import tippy from "tippy.js"
|
||||
import type {SvelteComponent} from "svelte"
|
||||
import Tooltip from "$lib/components/Tooltip.svelte"
|
||||
import hotkeys from "hotkeys-js"
|
||||
import type { Action } from "svelte/action";
|
||||
import tippy from "tippy.js";
|
||||
import type { SvelteComponent } from "svelte";
|
||||
import Tooltip from "$lib/components/Tooltip.svelte";
|
||||
import hotkeys from "hotkeys-js";
|
||||
|
||||
export const action: Action<Element, {title?: string; shortcut?: string}> = (
|
||||
export const action: Action<Element, { title?: string; shortcut?: string }> = (
|
||||
node: Element,
|
||||
{title, shortcut},
|
||||
{ title, shortcut },
|
||||
) => {
|
||||
let component: SvelteComponent | undefined
|
||||
let component: SvelteComponent | undefined;
|
||||
const tooltip = tippy(node, {
|
||||
arrow: false,
|
||||
theme: "tooltip",
|
||||
@@ -16,30 +16,30 @@ export const action: Action<Element, {title?: string; shortcut?: string}> = (
|
||||
onShow(instance) {
|
||||
component ??= new Tooltip({
|
||||
target: instance.popper.querySelector(".tippy-content") as Element,
|
||||
props: {title, shortcut},
|
||||
})
|
||||
props: { title, shortcut },
|
||||
});
|
||||
},
|
||||
onHidden() {
|
||||
component?.$destroy()
|
||||
component = undefined
|
||||
component?.$destroy();
|
||||
component = undefined;
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
if (shortcut && node instanceof HTMLElement) {
|
||||
hotkeys(shortcut, function (keyboardEvent) {
|
||||
keyboardEvent.preventDefault()
|
||||
node.click()
|
||||
})
|
||||
keyboardEvent.preventDefault();
|
||||
node.click();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
update(updated) {
|
||||
title = updated.title
|
||||
shortcut = updated.shortcut
|
||||
title = updated.title;
|
||||
shortcut = updated.shortcut;
|
||||
},
|
||||
destroy() {
|
||||
tooltip.destroy()
|
||||
hotkeys.unbind(shortcut)
|
||||
tooltip.destroy();
|
||||
hotkeys.unbind(shortcut);
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user