Skip to content

Commit

Permalink
destructure all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jun 14, 2023
1 parent 2768846 commit 868d059
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web_src/js/modules/tippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import tippy from 'tippy.js';

const visibleInstances = new Set();

export function createTippy(target, opts = {}) {
const {onHide, onShow, onDestroy, ...other} = opts;
export function createTippy(target, {onHide, onShow, onDestroy, role, content, ...other} = {}) {
const instance = tippy(target, {
appendTo: document.body,
animation: false,
Expand Down Expand Up @@ -32,15 +31,16 @@ export function createTippy(target, opts = {}) {
},
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
theme: role || 'menu', // CSS theme, we support either "tooltip" or "menu"
content,
...other,
});

// for popups where content refers to a DOM element, we use the 'tippy-target' class
// to initially hide the content, now we can remove it as the content has been removed
// from the DOM by tippy
if (other.content instanceof Element) {
other.content.classList.remove('tippy-target');
if (content instanceof Element) {
content.classList.remove('tippy-target');
}

return instance;
Expand Down

0 comments on commit 868d059

Please sign in to comment.