mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
28 lines
705 B
TypeScript
28 lines
705 B
TypeScript
import type { Action } from 'svelte/action';
|
|
import type { Props as TippyProps } from 'tippy.js';
|
|
import tippy from 'tippy.js';
|
|
|
|
type Props = TippyProps & {
|
|
disabled?: boolean;
|
|
};
|
|
|
|
export const tooltip: Action<HTMLElement, Partial<Props>> = (node, config) => {
|
|
const instance = tippy(node, config);
|
|
if (config.disabled) instance.disable();
|
|
|
|
return {
|
|
update({ content, disabled }) {
|
|
if (content !== instance.props.content) {
|
|
instance.setProps({
|
|
content
|
|
});
|
|
}
|
|
|
|
disabled ? instance.disable() : instance.enable();
|
|
},
|
|
destroy() {
|
|
instance.destroy();
|
|
}
|
|
};
|
|
};
|