Skip to content
Merged
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
4 changes: 2 additions & 2 deletions e2e/playground.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ test('the demo follows the site theme, including after a reset', async ({ page }
const playground = page.locator('.playground').first();
const demo = playground.frameLocator('iframe[src*="ionic:mode=ios"]').locator('html');

await expect(demo).toHaveClass(/ion-theme-dark/);
await expect(demo).toHaveClass(/ion-palette-dark/);

// Marks the demo, so the check below waits for the reloaded one.
await demo.evaluate((html) => html.setAttribute('data-before-reset', ''));
await playground.getByRole('button', { name: 'Reset demo' }).click();
await expect(demo).not.toHaveAttribute('data-before-reset');
await expect(demo).toHaveClass(/ion-theme-dark/);
await expect(demo).toHaveClass(/ion-palette-dark/);
});
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
27 changes: 18 additions & 9 deletions static/usage/v8/common.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
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';

const bundle = document.querySelector('link[href*="ionic.bundle.css"]');
bundle ? bundle.after(linkElement) : document.head.append(linkElement);
}

/**
* The parent Playground component will
* dispatch messages whenever the theme on
Expand All @@ -23,9 +32,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
27 changes: 18 additions & 9 deletions static/usage/v9/common.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
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';

const bundle = document.querySelector('link[href*="ionic.bundle.css"]');
bundle ? bundle.after(linkElement) : document.head.append(linkElement);
}

/**
* The parent Playground component will
* dispatch messages whenever the theme on
Expand All @@ -23,9 +32,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