From 293323af38ab6d1bca6f4ff80e9657edaf5efee8 Mon Sep 17 00:00:00 2001 From: Joe <33972521+hnb-ku@users.noreply.github.com> Date: Thu, 23 Jun 2022 14:07:04 +0800 Subject: [PATCH] UX: Splash screen v1 improvements (#17214) This commit does six things * changes the animation for the splash screen. To a more subtle animation. * defers displaying the splash by 1.5 seconds * defers displaying the splash "loading" text by 2.5 seconds * defers removing the splash until all Discourse initializers have run * fixes a display issue in Firefox * Inlines the SVG as a base64 and inlines the required CSS. The encoded SVG is hard coded for now, but we will use a helper to generate that based on the file after some testing. --- app/assets/javascripts/discourse/app/app.js | 6 +- app/assets/stylesheets/d_splash.scss | 59 ------------- app/views/common/_discourse_splash.html.erb | 92 ++++++++++++++++++--- app/views/layouts/application.html.erb | 4 - public/images/preloader.svg | 45 +++++----- 5 files changed, 106 insertions(+), 100 deletions(-) delete mode 100644 app/assets/stylesheets/d_splash.scss diff --git a/app/assets/javascripts/discourse/app/app.js b/app/assets/javascripts/discourse/app/app.js index 5d620caf85..3ff0205ccc 100644 --- a/app/assets/javascripts/discourse/app/app.js +++ b/app/assets/javascripts/discourse/app/app.js @@ -52,9 +52,6 @@ const Discourse = Application.extend({ start() { document.querySelector("noscript")?.remove(); - // The app booted. Remove the splash screen - document.querySelector("#d-splash")?.remove(); - if (Error.stackTraceLimit) { // We need Errors to have full stack traces for `lib/source-identifier` Error.stackTraceLimit = Infinity; @@ -84,6 +81,9 @@ const Discourse = Application.extend({ initialize: () => withPluginApi(cb.version, cb.code), }); }); + + // The app booted. Remove the splash screen + document.querySelector("#d-splash")?.remove(); }, _registerPluginCode(version, code) { diff --git a/app/assets/stylesheets/d_splash.scss b/app/assets/stylesheets/d_splash.scss deleted file mode 100644 index c56c915f93..0000000000 --- a/app/assets/stylesheets/d_splash.scss +++ /dev/null @@ -1,59 +0,0 @@ -html { - background: var(--secondary); - // needed because this sheet loads early and we want no scroll bars until - // the splash is removed. - overflow: hidden !important; -} - -#d-splash { - display: grid; - place-items: center; - position: relative; - backface-visibility: hidden; - - .preloader-image { - max-width: 100%; - height: 100vh; - object-fit: none; - } - - .preloader-text { - padding-top: 5em; - position: absolute; - display: grid; - grid-auto-flow: column; - place-items: center; - - &:after { - animation: loading-text 3s infinite; - content: ""; - position: absolute; - top: 5em; - margin: 0 0.1em; - left: 100%; - // TODO: this needs R2 RTL magic - .rtl & { - left: 0; - right: 100%; - } - } - } -} - -@keyframes loading-text { - 0% { - content: ""; - } - - 25% { - content: "."; - } - - 50% { - content: ".."; - } - - 75% { - content: "..."; - } -} diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erb index e48c75e1ef..5e6fe84ea0 100644 --- a/app/views/common/_discourse_splash.html.erb +++ b/app/views/common/_discourse_splash.html.erb @@ -1,17 +1,83 @@ <%- unless customization_disabled? %> -
- <%= discourse_stylesheet_link_tag 'd_splash', theme_id: nil %> +
+ + + <%=SiteSetting.title%> + +
+ <%= I18n.t("js.preloader_text") %> +
+
<%- end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index abbca6bb2b..969c68a542 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,10 +9,6 @@ <%= render partial: "layouts/head" %> <%= discourse_csrf_tags %> - <%- if include_splash_screen? %> - - <%- end %> - <%- if SiteSetting.enable_escaped_fragments? %> <%- end %> diff --git a/public/images/preloader.svg b/public/images/preloader.svg index b2088cee5e..fe22441d17 100644 --- a/public/images/preloader.svg +++ b/public/images/preloader.svg @@ -1,9 +1,8 @@ - - - - - + + + + +