webcoreui
Version:
UI component and template library for Astro, Svelte, and React apps styled with Sass.
21 lines (16 loc) • 501 B
text/typescript
export const closeContext = (ctx: string | HTMLElement) => {
const element = typeof ctx === 'string'
? document.querySelector(ctx)
: ctx
const parent = element?.parentElement
if (!parent) {
// eslint-disable-next-line no-console
console.error('Could not found context for:', ctx)
return
}
parent.dataset.show = 'false'
setTimeout(() => {
parent.style.top = ''
parent.style.left = ''
}, 200)
}