diff --git a/static/usage/v8/animations/preference-based/demo.html b/static/usage/v8/animations/preference-based/demo.html index a4f750e9118..d141beb1e62 100644 --- a/static/usage/v8/animations/preference-based/demo.html +++ b/static/usage/v8/animations/preference-based/demo.html @@ -49,7 +49,7 @@ } /* Demo does not use `prefers-color-scheme` media query because Docusaurus already checks for it. Otherwise, the demo might have the wrong background on certain edge cases. */ - body.dark ion-card { + .ion-palette-dark ion-card { --background: green; } diff --git a/static/usage/v8/common.js b/static/usage/v8/common.js index 752a7424bb6..3b647737940 100644 --- a/static/usage/v8/common.js +++ b/static/usage/v8/common.js @@ -1,10 +1,3 @@ -const linkElement = document.createElement('link'); - -linkElement.rel = 'stylesheet'; -linkElement.href = 'https://cdn.jsdelivr.net/npm/@ionic/core@8/css/palettes/dark.class.css'; - -document.head.appendChild(linkElement); - /** * Wait for the initial HTML document to be * loaded and parsed before adding the message @@ -12,6 +5,21 @@ document.head.appendChild(linkElement); * listener will fire before the body is ready. */ window.addEventListener('DOMContentLoaded', () => { + /** + * The dark palette goes right after ionic.bundle.css, the order an app + * imports them in. Before it, the bundle's default colors win; after the + * demo's own styles, it overrides them. Demos that load a palette of + * their own, such as the theming demos, are left to it. + */ + if (!document.querySelector('link[href*="/css/palettes/"]')) { + const linkElement = document.createElement('link'); + + linkElement.rel = 'stylesheet'; + linkElement.href = 'https://cdn.jsdelivr.net/npm/@ionic/core@8/css/palettes/dark.class.css'; + + document.querySelector('link[href*="ionic.bundle.css"]').after(linkElement); + } + /** * The parent Playground component will * dispatch messages whenever the theme on @@ -23,9 +31,9 @@ window.addEventListener('DOMContentLoaded', () => { const { data } = event; if (data.darkMode) { - document.documentElement.classList.add('ion-theme-dark'); + document.documentElement.classList.add('ion-palette-dark'); } else { - document.documentElement.classList.remove('ion-theme-dark'); + document.documentElement.classList.remove('ion-palette-dark'); } }); diff --git a/static/usage/v8/datetime/styling/global-theming/demo.html b/static/usage/v8/datetime/styling/global-theming/demo.html index df3278ab1d8..a066f2d32df 100644 --- a/static/usage/v8/datetime/styling/global-theming/demo.html +++ b/static/usage/v8/datetime/styling/global-theming/demo.html @@ -10,8 +10,8 @@ diff --git a/static/usage/v9/common.js b/static/usage/v9/common.js index 486b95aab0c..53833c6a781 100644 --- a/static/usage/v9/common.js +++ b/static/usage/v9/common.js @@ -1,10 +1,3 @@ -const linkElement = document.createElement('link'); - -linkElement.rel = 'stylesheet'; -linkElement.href = 'https://cdn.jsdelivr.net/npm/@ionic/core@9/css/palettes/dark.class.css'; - -document.head.appendChild(linkElement); - /** * Wait for the initial HTML document to be * loaded and parsed before adding the message @@ -12,6 +5,21 @@ document.head.appendChild(linkElement); * listener will fire before the body is ready. */ window.addEventListener('DOMContentLoaded', () => { + /** + * The dark palette goes right after ionic.bundle.css, the order an app + * imports them in. Before it, the bundle's default colors win; after the + * demo's own styles, it overrides them. Demos that load a palette of + * their own, such as the theming demos, are left to it. + */ + if (!document.querySelector('link[href*="/css/palettes/"]')) { + const linkElement = document.createElement('link'); + + linkElement.rel = 'stylesheet'; + linkElement.href = 'https://cdn.jsdelivr.net/npm/@ionic/core@9/css/palettes/dark.class.css'; + + document.querySelector('link[href*="ionic.bundle.css"]').after(linkElement); + } + /** * The parent Playground component will * dispatch messages whenever the theme on @@ -23,9 +31,9 @@ window.addEventListener('DOMContentLoaded', () => { const { data } = event; if (data.darkMode) { - document.documentElement.classList.add('ion-theme-dark'); + document.documentElement.classList.add('ion-palette-dark'); } else { - document.documentElement.classList.remove('ion-theme-dark'); + document.documentElement.classList.remove('ion-palette-dark'); } }); diff --git a/static/usage/v9/datetime/styling/global-theming/demo.html b/static/usage/v9/datetime/styling/global-theming/demo.html index 50813a7e303..e99bbb29408 100644 --- a/static/usage/v9/datetime/styling/global-theming/demo.html +++ b/static/usage/v9/datetime/styling/global-theming/demo.html @@ -10,8 +10,8 @@