forked from forgejo/forgejo
Batch delete issue and improve tippy opts (#25253)
1. Add "batch delete" button for selected issues, close #22273 2. Address the review in https://github.com/go-gitea/gitea/pull/25219#discussion_r1229266083
This commit is contained in:
parent
51c2aebe1f
commit
a1c5057fe8
10 changed files with 104 additions and 47 deletions
|
@ -3,11 +3,9 @@ import tippy from 'tippy.js';
|
|||
const visibleInstances = new Set();
|
||||
|
||||
export function createTippy(target, opts = {}) {
|
||||
const {role, content, onHide: optsOnHide, onDestroy: optsOnDestroy, onShow: optOnShow} = opts;
|
||||
delete opts.onHide;
|
||||
delete opts.onDestroy;
|
||||
delete opts.onShow;
|
||||
|
||||
// the callback functions should be destructured from opts,
|
||||
// because we should use our own wrapper functions to handle them, do not let the user override them
|
||||
const {onHide, onShow, onDestroy, ...other} = opts;
|
||||
const instance = tippy(target, {
|
||||
appendTo: document.body,
|
||||
animation: false,
|
||||
|
@ -18,11 +16,11 @@ export function createTippy(target, opts = {}) {
|
|||
maxWidth: 500, // increase over default 350px
|
||||
onHide: (instance) => {
|
||||
visibleInstances.delete(instance);
|
||||
return optsOnHide?.(instance);
|
||||
return onHide?.(instance);
|
||||
},
|
||||
onDestroy: (instance) => {
|
||||
visibleInstances.delete(instance);
|
||||
return optsOnDestroy?.(instance);
|
||||
return onDestroy?.(instance);
|
||||
},
|
||||
onShow: (instance) => {
|
||||
// hide other tooltip instances so only one tooltip shows at a time
|
||||
|
@ -32,19 +30,19 @@ export function createTippy(target, opts = {}) {
|
|||
}
|
||||
}
|
||||
visibleInstances.add(instance);
|
||||
return optOnShow?.(instance);
|
||||
return onShow?.(instance);
|
||||
},
|
||||
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: role || 'menu', // CSS theme, we support either "tooltip" or "menu"
|
||||
...opts,
|
||||
theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
|
||||
...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 (content instanceof Element) {
|
||||
content.classList.remove('tippy-target');
|
||||
if (other.content instanceof Element) {
|
||||
other.content.classList.remove('tippy-target');
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue