import { CdnEvent } from './events.models';
/**
* Specify loading screen options, see {@link LoadingScreenView}.
*
* @category Loading screen
*/
export interface LoadingScreenOptions {
/**
* container in which the loading screen's HTMLDivElement is appended
* (when calling {@link LoadingScreenView.render}).
*/
container?: HTMLElement;
/**
* id of the loading screen's HTMLDivElement wrapper
*/
id?: string;
/**
* innerHTML definition of the logo
*/
logo?: string;
/**
* style to apply on the loading screen's HTMLDivElement wrapper
*/
wrapperStyle?: {
[_k: string]: string;
};
/**
* fading timeout
*/
fadingTimeout?: number;
}
/**
* Default values of {@link LoadingScreenOptions}.
*
* @category Loading screen
*/
export declare class DefaultLoadingScreenOptions implements LoadingScreenOptions {
/**
* Default {@link LoadingScreenOptions.id}
*/
readonly id: string;
/**
* Default {@link LoadingScreenOptions.logo}, see {@link youwolSvgLogo}.
*/
readonly logo: string;
/**
* Default {@link LoadingScreenOptions.fadingTimeout}.
*/
readonly fadingTimeout: number;
/**
* Default {@link LoadingScreenOptions.container}
*/
readonly container: HTMLElement;
/**
* Default {@link LoadingScreenOptions.wrapperStyle}:
* ```
* {
* position: 'absolute',
* top: '0',
* left: '0',
* width: '100vw',
* height: '100vh',
* padding: 'inherit',
* 'font-weight': 'bolder'
* }
* ```
*/
readonly wrapperStyle: {
[_k: string]: string;
};
}
/**
* Class providing granular controls on how loading screen is displayed when using {@link Client.install}
* or {@link install}.
*
* Here is an example:
* ```
* import {LoadingScreenView, install} from '@youwol/cdn-client'
*
* const loadingScreen = new LoadingScreenView({
* container: this,
* logo: `
🐍
`,
* wrapperStyle: {
* position: 'absolute', top: '0', left: '0', width: '100%', height: '100%', 'font-weight': 'bolder',
* },
* })
* loadingScreen.render()
* await install({
* modules: ['rxjs#7'],
* onEvent: (ev) => {
* // event forwarding to loading screen
* loadingScreen.next(ev)
* },
* })
* // loadingScreen.next(...) can be used latter in the code
* // At some point remove the loading screen
* loadingScreen.done()
* ```
*
* Default values of the display options are defined in {@link DefaultLoadingScreenOptions}, it can be controlled by e.g.:
* ```
* import {LoadingScreenView, DefaultLoadingScreenOptions} from '@youwol/cdn-client'
* // for all LoadingScreenView instances:
* LoadingScreenView.DefaultOptions = {
* ...new DefaultLoadingScreenOptions(),
* fadingTimeout: 0,
* }
* // for one LoadingScreenView instance (includes previously set 'fadingTimeout' to 0):
* new cdnClient.LoadingScreenView({
* logo: `🐍
`,
* })
* ```
*
* > For default display, setting `displayLoadingScreen: true` from {@link InstallInputs} is enough:
* > creation and management of {@link LoadingScreenView} will be automatic.
*
* @category Loading screen
*/
export declare class LoadingScreenView {
/**
* Can be used to control default display options for all {@link LoadingScreenView} instances
*/
static DefaultOptions: DefaultLoadingScreenOptions;
/**
* The actual display options used by the class.
*/
readonly options: LoadingScreenOptions;
/**
* expose the wrapperDiv HTMLDivElement
*/
readonly wrapperDiv: HTMLDivElement;
/**
* expose the loadingDiv HTMLDivElement
*/
readonly loadingDiv: HTMLDivElement;
/**
* expose the contentDiv HTMLDivElement
*/
contentDiv: HTMLDivElement;
/**
*
* @param options see {@link LoadingScreenOptions}, final display options object is obtained by merging
* `options` with {@link DefaultLoadingScreenOptions} : `Object.assign(LoadingScreenView.DefaultOptions, options)`
*/
constructor(options?: LoadingScreenOptions);
/**
* Actualize the view given a new {@link CdnEvent} (provided that {@link LoadingScreenView.render}
* has been called before).
*
* @param event event to account for
*/
next(event: CdnEvent): void;
/**
* Render the loading screen view, should be called before any call to {@link LoadingScreenView.next}
* to actually see the updates.
*/
render(): void;
/**
* Remove the loading screen (see {@link LoadingScreenOptions.fadingTimeout}).
*/
done(): void;
}