feat(themes): add support for modular themes and custom themes (#30651)

Issue number: internal

---------

## What is the new behavior?
- Moves `openURL` out of the `theme` utils because it makes more sense
in `helpers`
- Adds support for the default `default.tokens.ts` design tokens file
- Adds support for custom theme set globally and on a component 

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

## Other information

Requires additional changes in order to test.

---------

Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
This commit is contained in:
Brandy Smith
2025-08-29 13:53:24 -04:00
committed by Brandy Smith
parent fea1e64920
commit 1aa7c35da1
15 changed files with 658 additions and 33 deletions

View File

@ -1,7 +1,10 @@
import { Build, getMode, setMode, getElement } from '@stencil/core';
import { printIonWarning } from '@utils/logging';
import { applyGlobalTheme } from '@utils/theme';
import type { IonicConfig, Mode, Theme } from '../interface';
import { defaultTheme as baseTheme } from '../themes/base/default.tokens';
import type { Theme as BaseTheme } from '../themes/base/default.tokens';
import { shouldUseCloseWatcher } from '../utils/hardware-back-button';
import { isPlatform, setupPlatforms } from '../utils/platform';
@ -225,6 +228,16 @@ export const initialize = (userConfig: IonicConfig = {}) => {
doc.documentElement.setAttribute('theme', defaultTheme);
doc.documentElement.classList.add(defaultTheme);
const customTheme: BaseTheme | undefined = configObj.customTheme;
// Apply base theme, or combine with custom theme if provided
if (customTheme) {
const combinedTheme = applyGlobalTheme(baseTheme, customTheme);
config.set('customTheme', combinedTheme);
} else {
applyGlobalTheme(baseTheme);
}
if (config.getBoolean('_testing')) {
config.set('animated', false);
}