mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
32 lines
845 B
TypeScript
32 lines
845 B
TypeScript
import tippy, { type Props as TippyProps } from 'tippy.js';
|
|
import 'tippy.js/dist/tippy.css';
|
|
|
|
/**
|
|
* Svelte action for tippy.js tooltips.
|
|
* Usage: <button use:tooltip={'New terminal'}>
|
|
* or: <button use:tooltip={{ content: 'New terminal', placement: 'bottom' }}>
|
|
*/
|
|
export function tooltip(node: HTMLElement, params: string | Partial<TippyProps>) {
|
|
const opts: Partial<TippyProps> = typeof params === 'string' ? { content: params } : params;
|
|
|
|
const instance = tippy(node, {
|
|
arrow: false,
|
|
delay: [400, 0],
|
|
duration: [100, 75],
|
|
placement: 'bottom',
|
|
theme: 'cptr',
|
|
touch: false,
|
|
...opts
|
|
});
|
|
|
|
return {
|
|
update(newParams: string | Partial<TippyProps>) {
|
|
const newOpts = typeof newParams === 'string' ? { content: newParams } : newParams;
|
|
instance.setProps(newOpts);
|
|
},
|
|
destroy() {
|
|
instance.destroy();
|
|
}
|
|
};
|
|
}
|