mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 20:39:03 +00:00
preloading of popup component
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
479fb21600
commit
74a9366688
@ -89,11 +89,7 @@ $: {
|
||||
</script>
|
||||
|
||||
<div class="popup" bind:this={modalHTML} style={`z-index: ${zIndex + 1};`}>
|
||||
{#if typeof(is) === 'string'}
|
||||
<Component is={is} props={props} on:close={ (ev) => close(ev.detail) }/>
|
||||
{:else}
|
||||
<svelte:component this={is} {...props} on:close={ (ev) => close(ev.detail) } />
|
||||
{/if}
|
||||
<svelte:component this={is} {...props} on:close={ (ev) => close(ev.detail) } />
|
||||
</div>
|
||||
<div bind:this={modalOHTML} class="modal-overlay" style={`z-index: ${zIndex};`} on:click={() => close(undefined)} />
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import { SvelteComponent } from 'svelte'
|
||||
import type { AnySvelteComponent, AnyComponent, PopupAlignment, LabelAndProps, TooltipAligment } from './types'
|
||||
import type { IntlString } from '@anticrm/platform'
|
||||
import { getResource, IntlString } from '@anticrm/platform'
|
||||
import { addStringsLoader } from '@anticrm/platform'
|
||||
import { uiId } from './plugin'
|
||||
|
||||
@ -81,7 +81,7 @@ export function createApp (target: HTMLElement): SvelteComponent {
|
||||
}
|
||||
|
||||
interface CompAndProps {
|
||||
is: AnySvelteComponent | AnyComponent
|
||||
is: AnySvelteComponent
|
||||
props: any
|
||||
element?: PopupAlignment
|
||||
onClose?: (result: any) => void
|
||||
@ -95,10 +95,19 @@ interface CompAndProps {
|
||||
export const popupstore = writable<CompAndProps[]>([])
|
||||
|
||||
export function showPopup (component: AnySvelteComponent | AnyComponent, props: any, element?: PopupAlignment, onClose?: (result: any) => void): void {
|
||||
popupstore.update(popups => {
|
||||
popups.push({ is: component, props, element, onClose })
|
||||
return popups
|
||||
})
|
||||
if (typeof component === 'string') {
|
||||
getResource(component).then(resolved => {
|
||||
popupstore.update(popups => {
|
||||
popups.push({ is: resolved, props, element, onClose })
|
||||
return popups
|
||||
})
|
||||
})
|
||||
} else {
|
||||
popupstore.update(popups => {
|
||||
popups.push({ is: component, props, element, onClose })
|
||||
return popups
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function closePopup (): void {
|
||||
|
Loading…
Reference in New Issue
Block a user