From 2750049333e44eb3cdb8083a55cada6d8b34bdc7 Mon Sep 17 00:00:00 2001 From: Joe <33972521+hnb-ku@users.noreply.github.com> Date: Fri, 8 Jul 2022 22:30:59 +0800 Subject: [PATCH] UX: Makes splash dots use theme colors (#17388) The dots in the splash were previously hard-coded (v1). This PR makes progress towards making them be based on current theme colors. Note that this is an improvement and not the "final" version. We're going to dynamically generate the splash file and the base64 URL later on. --- app/views/common/_discourse_splash.html.erb | 144 +++++++++++++++++++- public/images/preloader.svg | 84 ------------ 2 files changed, 137 insertions(+), 91 deletions(-) delete mode 100644 public/images/preloader.svg diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erb index 6c6dd1ad94b..8ec585593f1 100644 --- a/app/views/common/_discourse_splash.html.erb +++ b/app/views/common/_discourse_splash.html.erb @@ -1,5 +1,116 @@ <%- unless customization_disabled? %>
+ + <%=SiteSetting.title%> @@ -98,10 +218,19 @@ const DELAY_TARGET = 2000; const POLLING_INTERVAL = 50; + const splashSvgTemplate = document.querySelector(".splash-svg-template"); + const splashTemplateClone = splashSvgTemplate.content.cloneNode(true); + const svgElement = splashTemplateClone.querySelector("svg"); + + const svgString = new XMLSerializer().serializeToString(svgElement); + const encodedSvg = btoa(svgString); + const splashWrapper = document.querySelector("#d-splash"); const splashImage = splashWrapper?.querySelector(".preloader-image"); if (splashImage) { + splashImage.src = `data:image/svg+xml;base64,${encodedSvg}`; + const connectStart = performance?.timing?.connectStart || 0; const splashDelay = connectStart ? DELAY_TARGET : 0; const targetTime = connectStart + DELAY_TARGET; @@ -111,11 +240,12 @@ const swapSplash = () => { splashWrapper?.style.setProperty("--animation-state", "running"); + svgElement?.style.setProperty("--animation-state", "running"); - splashImage.src = splashImage.src.replace( - "--animation-state: paused;", - "--animation-state: running;" - ); + const newSvgString = new XMLSerializer().serializeToString(svgElement); + const newEncodedSvg = btoa(newSvgString); + + splashImage.src = `data:image/svg+xml;base64,${newEncodedSvg}`; performance.mark("discourse-splash-visible"); diff --git a/public/images/preloader.svg b/public/images/preloader.svg deleted file mode 100644 index b2319c1b2fb..00000000000 --- a/public/images/preloader.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - -