Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/usage/v8/animations/preference-based/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
Expand Down
26 changes: 17 additions & 9 deletions static/usage/v8/common.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
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
* listener. Otherwise, it is possible that the message
* 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
Expand All @@ -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');
}
});

Expand Down
4 changes: 2 additions & 2 deletions static/usage/v8/datetime/styling/global-theming/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" />
<style>
:root,
.ios body.dark,
.md body.dark {
.ion-palette-dark.ios,
.ion-palette-dark.md {
--ion-color-rose: #831843;
--ion-color-rose-rgb: 131, 24, 67;
--ion-color-rose-contrast: #ffffff;
Expand Down
2 changes: 1 addition & 1 deletion static/usage/v9/animations/preference-based/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
Expand Down
26 changes: 17 additions & 9 deletions static/usage/v9/common.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
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
* listener. Otherwise, it is possible that the message
* 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
Expand All @@ -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');
}
});

Expand Down
4 changes: 2 additions & 2 deletions static/usage/v9/datetime/styling/global-theming/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@9/css/ionic.bundle.css" />
<style>
:root,
.ios body.dark,
.md body.dark {
.ion-palette-dark.ios,
.ion-palette-dark.md {
--ion-color-rose: #831843;
--ion-color-rose-rgb: 131, 24, 67;
--ion-color-rose-contrast: #ffffff;
Expand Down
Loading