From bdcadda22d3fbc015d4772405e5b4efeb181c567 Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Thu, 8 Jun 2023 22:39:30 -0700 Subject: [PATCH] Add an empty splash screen on notebook launch to avoid a flash of unstyled content (#6911) * add an empty splash screen * add empty splash screen styling * remove technical comment * Update packages/application-extension/src/index.ts --------- Co-authored-by: Jeremy Tuloup --- packages/application-extension/src/index.ts | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index 64a90ed63..2b9d5c328 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -13,6 +13,7 @@ import { DOMUtils, ICommandPalette, ISanitizer, + ISplashScreen, IToolbarWidgetRegistry, } from '@jupyterlab/apputils'; @@ -393,6 +394,35 @@ const shell: JupyterFrontEndPlugin = { provides: INotebookShell, }; +/** + * The default splash screen provider. + */ +const splash: JupyterFrontEndPlugin = { + id: '@jupyter-notebook/application-extension:splash', + description: 'Provides an empty splash screen.', + autoStart: true, + provides: ISplashScreen, + activate: (app: JupyterFrontEnd) => { + const { restored } = app; + const splash = document.createElement('div'); + splash.style.position = 'absolute'; + splash.style.width = '100%'; + splash.style.height = '100%'; + splash.style.zIndex = '10'; + + return { + show: (light = true) => { + splash.style.backgroundColor = light ? 'white' : '#111111'; + document.body.appendChild(splash); + return new DisposableDelegate(async () => { + await restored; + document.body.removeChild(splash); + }); + }, + }; + }, +}; + /** * The default JupyterLab application status provider. */ @@ -1005,6 +1035,7 @@ const plugins: JupyterFrontEndPlugin[] = [ rendermime, shell, sidePanelVisibility, + splash, status, tabTitle, title,