Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6498f16
feat(themes): add new tokens and definitions
brandyscarney Oct 3, 2025
f16b58b
feat(themes): add ionic theme tokens
brandyscarney Oct 3, 2025
1a81b0f
test(themes): update basic test for new tokens
brandyscarney Oct 3, 2025
6390d17
refactor(themes): exclude certain keys from generated css variables
brandyscarney Oct 6, 2025
e342530
fix(themes): remove testing overrides for global variables in ionic t…
brandyscarney Oct 6, 2025
56b9a5b
style: lint
brandyscarney Oct 6, 2025
9c83b5c
test(components): update to set the global background on root
brandyscarney Oct 7, 2025
ad6fe66
test(themes): only override the global background for ionic theme
brandyscarney Oct 7, 2025
4a45a78
test(themes): update the testing script to include the tokens
brandyscarney Oct 7, 2025
f60f83c
chore: build the new tokens on build
brandyscarney Oct 7, 2025
a631f2c
fix(themes): set the bare tokens for ios and md to work
brandyscarney Oct 7, 2025
43ee386
chore: generate theme utils file
brandyscarney Oct 7, 2025
652cbf3
style: lint
brandyscarney Oct 7, 2025
68d110a
test(scripts): transpile themes to dist directory
brandyscarney Oct 8, 2025
d29ce36
chore(themes): generate themes in top-level directory and pass to CI
brandyscarney Oct 8, 2025
1954189
fix(themes): add missing 0 border width
brandyscarney Oct 15, 2025
050b9d0
fix(themes): check for excluded keys after kebab-case conversion
brandyscarney Oct 15, 2025
9611d1b
chore(): add updated snapshots (#30721)
brandyscarney Oct 15, 2025
13c6d31
fix(themes): update incorrect import
brandyscarney Oct 15, 2025
6f2c0c3
test(themes): update font color on basic space tests
brandyscarney Oct 15, 2025
994340f
test(themes): add a warning when an invalid theme is passed
brandyscarney Oct 15, 2025
5be5838
test(scripts): update to print default theme
brandyscarney Oct 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ runs:
with:
name: ionic-core
output: core/CoreBuild.zip
paths: core/dist core/components core/src/foundations core/css core/hydrate core/loader core/src/components.d.ts
paths: core/dist core/components core/src/foundations core/css core/themes core/hydrate core/loader core/src/components.d.ts
2 changes: 1 addition & 1 deletion .github/workflows/actions/build-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ runs:
output: core/CoreBuild.zip
# Include generated proxy files from Stencil output targets so
# framework builds can detect when they need to be updated
paths: core/dist core/components core/src/foundations core/css core/hydrate core/loader core/src/components.d.ts core/api.txt packages/angular/src/directives/proxies.ts packages/angular/src/directives/proxies-list.ts packages/angular/standalone/src/directives/proxies.ts packages/vue/src/proxies.ts packages/react/src/components/proxies.ts packages/react/src/components/inner-proxies.ts packages/react/src/components/routing-proxies.ts
paths: core/dist core/components core/src/foundations core/css core/themes core/hydrate core/loader core/src/components.d.ts core/api.txt packages/angular/src/directives/proxies.ts packages/angular/src/directives/proxies-list.ts packages/angular/standalone/src/directives/proxies.ts packages/vue/src/proxies.ts packages/react/src/components/proxies.ts packages/react/src/components/inner-proxies.ts packages/react/src/components/routing-proxies.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ temp/
core/theme-builder/
core/test-components/
core/css/
core/themes/
$RECYCLE.BIN/

.DS_Store
Expand Down
5 changes: 3 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@
"stylelint-order": "^4.1.0"
},
"scripts": {
"build": "npm run clean && npm run build.css && stencil build --es5 --docs-json dist/docs.json",
"build": "npm run clean && npm run build.css && npm run build.themes && stencil build --es5 --docs-json dist/docs.json",
"build.css": "npm run css.sass && npm run css.minify",
"build.debug": "npm run clean && stencil build --debug",
"build.docs.json": "stencil build --docs-json dist/docs.json",
"build.tokens": "npx build.tokens --config scripts/tokens/index.mjs && npm run prettier.tokens",
"build.themes": "esbuild src/themes/*/*.tokens.ts --bundle --format=esm --platform=browser --target=es2017 --outdir=themes --outbase=src/themes && esbuild src/utils/theme.ts --bundle --format=esm --platform=browser --target=es2017 --outfile=themes/utils/theme.js",
"clean": "node scripts/clean.js",
"css.minify": "cleancss -O2 -o ./css/ionic.bundle.css ./css/ionic.bundle.css",
"css.sass": "sass --embed-sources --style compressed src/css:./css",
Expand All @@ -94,7 +95,7 @@
"prerender.e2e": "node scripts/testing/prerender.js",
"prettier": "prettier \"./src/**/*.{html,ts,tsx,js,jsx,scss}\"",
"prettier.tokens": "prettier \"./src/foundations/*.{scss, html}\" --write --cache",
"start": "npm run build.css && stencil build --dev --watch --serve",
"start": "npm run build.css && npm run build.themes && stencil build --dev --watch --serve",
"test": "npm run test.spec && npm run test.e2e",
"test.spec": "stencil test --spec --max-workers=2",
"test.e2e": "npx playwright test",
Expand Down
3 changes: 2 additions & 1 deletion core/scripts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const path = require('path');

const cleanDirs = [
'dist',
'css'
'css',
'themes'
];

cleanDirs.forEach(dir => {
Expand Down
71 changes: 52 additions & 19 deletions core/scripts/testing/scripts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const DEFAULT_THEME = 'md';

(function() {

Expand All @@ -15,28 +16,15 @@
}

/**
* The term `palette` is used to as a param to match the
* Ionic docs, plus here is already a `ionic:theme` query being
* used for `md`, `ios`, and `ionic` themes.
*/
const palette = window.location.search.match(/palette=([a-z]+)/);
if (palette && palette[1] !== 'light') {
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'stylesheet');
linkTag.setAttribute('type', 'text/css');
linkTag.setAttribute('href', `/css/palettes/${palette[1]}.always.css`);
document.head.appendChild(linkTag);
}

/**
* The `ionic` theme uses a different stylesheet than the `iOS` and `md` themes.
* This is to ensure that the `ionic` theme is loaded when the `ionic:theme=ionic`
* or when the HTML tag has the `theme="ionic"` attribute. This is useful for
* the snapshot tests, where the `ionic` theme is not loaded by default.
* The `theme` query param is used to load a specific theme.
* This can be `ionic`, `ios`, or `md`. Default to `md` for tests.
*/
const themeQuery = window.location.search.match(/ionic:theme=([a-z]+)/);
const themeQuery = window.location.search.match(/ionic:theme=([a-z0-9]+)/i);
const themeAttr = document.documentElement.getAttribute('theme');
const themeName = themeQuery?.[1] || themeAttr || DEFAULT_THEME;

// TODO(): Remove this when the tokens are working for all components
// and the themes all use the same bundle
if ((themeQuery && themeQuery[1] === 'ionic') || themeAttr === 'ionic') {
const ionicThemeLinkTag = document.querySelector('link[href*="css/ionic/bundle.ionic.css"]');

Expand All @@ -54,6 +42,51 @@
}
}

/**
* The `palette` query param is used to load a specific palette
* for the theme. This can be `light`, `dark`, `high-contrast`,
* or `high-contrast-dark`. Default to `light` for tests.
*/
const paletteQuery = window.location.search.match(/palette=([a-z]+)/);
const paletteName = paletteQuery?.[1] || 'light';

// Load theme tokens if the theme is valid
const validThemes = ['ionic', 'ios', 'md'];
if (themeName && validThemes.includes(themeName)) {
loadThemeTokens(themeName, paletteName);
} else if(themeName) {
console.warn(
`Unsupported theme "${themeName}". Supported themes are: ${validThemes.join(', ')}. Defaulting to ${DEFAULT_THEME}.`
);
}

async function loadThemeTokens(themeName, paletteName) {
try {
// Load the default tokens for the theme
const defaultTokens = await import(`/themes/${themeName}/default.tokens.js`);
const theme = defaultTokens.defaultTheme;

// If a specific palette is requested, modify the palette structure
// to set the enabled property to 'always'
if (paletteName === 'dark' && theme.palette?.dark) {
theme.palette.dark.enabled = 'always';
}

// Apply the theme tokens to Ionic config
window.Ionic = window.Ionic || {};
window.Ionic.config = window.Ionic.config || {};
window.Ionic.config.customTheme = theme;

// Re-apply the global theme
if (window.Ionic.config.get && window.Ionic.config.set) {
const themeModule = await import('/themes/utils/theme.js');
themeModule.applyGlobalTheme(theme);
}
} catch (error) {
console.error(`Failed to load theme tokens for ${themeName}:`, error);
}
}

window.Ionic = window.Ionic || {};
window.Ionic.config = window.Ionic.config || {};

Expand Down
16 changes: 3 additions & 13 deletions core/scripts/testing/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>
<ion-accordion-group>
Expand Down Expand Up @@ -47,8 +47,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>
<ion-accordion-group value="first">
Expand Down Expand Up @@ -87,8 +87,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>
<ion-accordion-group expand="inset">
Expand Down Expand Up @@ -125,8 +125,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>
<ion-accordion-group value="first" expand="inset">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #222;
.ionic {
--ion-background-color: #222;
}
</style>

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/accordion/test/shape/accordion.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screens
`
<style>
/* Background styles to show the border radius */
:root {
--background: #222;
.ionic {
--ion-background-color: #222;
}
</style>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}

.container {
Expand All @@ -32,8 +32,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}

.container {
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/searchbar/test/shape/searchbar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
`
<style>
/* Background styles to show the border radius */
:root {
--background: #000;
.ionic {
--ion-background-color: #000;
}
</style>

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/tab-bar/test/basic/tab-bar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ configs({ modes: ['ionic-md', 'md', 'ios'] }).forEach(({ title, screenshot, conf
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>

Expand Down
24 changes: 12 additions & 12 deletions core/src/components/tab-bar/test/shape/tab-bar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>

Expand All @@ -22,12 +22,12 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
Expand All @@ -48,8 +48,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>

Expand All @@ -58,12 +58,12 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
Expand All @@ -84,8 +84,8 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
await page.setContent(
`
<style>
:root {
--background: #ccc7c7;
.ionic {
--ion-background-color: #ccc7c7;
}
</style>

Expand All @@ -94,12 +94,12 @@ configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ title, screensh
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="2">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
</ion-tab-button>

<ion-tab-button tab="3">
<ion-icon name="triangle-outline"></ion-icon>
<ion-label>Label</ion-label>
Expand Down
7 changes: 1 addition & 6 deletions core/src/global/ionic-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { applyGlobalTheme, getCustomTheme } from '@utils/theme';

import type { IonicConfig, Mode, Theme } from '../interface';
import { defaultTheme as baseTheme } from '../themes/base/default.tokens';
import { defaultTheme as ionicTheme } from '../themes/ionic/default.tokens';
import type { BaseTheme } from '../themes/themes.interfaces';
import { shouldUseCloseWatcher } from '../utils/hardware-back-button';
import { isPlatform, setupPlatforms } from '../utils/platform';
Expand Down Expand Up @@ -156,11 +155,7 @@ export const initialize = (userConfig: IonicConfig = {}) => {
config.set('customTheme', combinedTheme);
} else {
applyGlobalTheme(baseTheme);
}

// TODO(): remove this when we update the ionic theme
if (defaultTheme === 'ionic') {
applyGlobalTheme(ionicTheme);
config.set('customTheme', baseTheme);
}

if (config.getBoolean('_testing')) {
Expand Down
Loading
Loading