From 253e48d12dfe57f2d041da3dffe32608e4c05a02 Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Wed, 4 Jan 2023 16:23:54 -0600 Subject: [PATCH] Append addon CSS at the end of Fixes https://github.com/TurboWarp/scratch-gui/issues/685 --- src/addons/conditional-style.js | 6 +++--- src/lib/tw-theme-hoc.jsx | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/addons/conditional-style.js b/src/addons/conditional-style.js index eef81e631..44af0a596 100644 --- a/src/addons/conditional-style.js +++ b/src/addons/conditional-style.js @@ -1,8 +1,8 @@ -// Stylesheets are added at the start of so that they have higher precedence -// than those in +// Stylesheets are added at the end of so that they have higher precedence +// than those in and above dark mode which is appended at the start of const stylesheetContainer = document.createElement('div'); stylesheetContainer.style.display = 'none'; -document.body.insertBefore(stylesheetContainer, document.body.firstChild); +document.body.appendChild(stylesheetContainer); /** * Maps opaque module IDs to its ConditionalStyle. diff --git a/src/lib/tw-theme-hoc.jsx b/src/lib/tw-theme-hoc.jsx index 6d32f6845..33379c0ac 100644 --- a/src/lib/tw-theme-hoc.jsx +++ b/src/lib/tw-theme-hoc.jsx @@ -55,6 +55,8 @@ const ThemeHOC = function (WrappedComponent) { const dark = this.state.dark; document.body.setAttribute('theme', dark ? 'dark' : 'light'); if (dark && !darkModeStylesheet.parentNode) { + // Append at the start of we override scratch-gui styles in + // but are overridden by addon styles at the end of document.body.insertBefore(darkModeStylesheet, document.body.firstChild); } else if (!dark && darkModeStylesheet.parentNode) { darkModeStylesheet.parentNode.removeChild(darkModeStylesheet);