Skip to content

Commit 55cac74

Browse files
thetaPCbrandyscarneyShaneK
authored
feat(chip): add recipe and variables (#30873)
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com> Co-authored-by: Shane <shane@shanessite.net>
1 parent 52779dd commit 55cac74

File tree

157 files changed

+2089
-832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+2089
-832
lines changed

core/api.txt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -596,23 +596,17 @@ ion-checkbox,part,supporting-text
596596
ion-chip,shadow
597597
ion-chip,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
598598
ion-chip,prop,disabled,boolean,false,false,false
599-
ion-chip,prop,hue,"bold" | "subtle" | undefined,'subtle',false,false
599+
ion-chip,prop,fill,"outline" | "solid" | undefined,undefined,false,false
600+
ion-chip,prop,hue,"bold" | "subtle" | undefined,undefined,false,false
600601
ion-chip,prop,mode,"ios" | "md",undefined,false,false
601602
ion-chip,prop,outline,boolean,false,false,false
602603
ion-chip,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
603604
ion-chip,prop,size,"large" | "small" | undefined,undefined,false,false
604-
ion-chip,prop,theme,"ios" | "md" | "ionic",undefined,false,false
605-
ion-chip,css-prop,--background,ionic
606-
ion-chip,css-prop,--background,ios
607-
ion-chip,css-prop,--background,md
608-
ion-chip,css-prop,--border-radius,ionic
609-
ion-chip,css-prop,--border-radius,ios
610-
ion-chip,css-prop,--border-radius,md
611-
ion-chip,css-prop,--color,ionic
612-
ion-chip,css-prop,--color,ios
613-
ion-chip,css-prop,--color,md
614-
ion-chip,css-prop,--focus-ring-color,ionic
615-
ion-chip,css-prop,--focus-ring-width,ionic
605+
ion-chip,css-prop,--border-radius
606+
ion-chip,css-prop,--color
607+
ion-chip,css-prop,--focus-ring-color
608+
ion-chip,css-prop,--focus-ring-style
609+
ion-chip,css-prop,--focus-ring-width
616610

617611
ion-col,shadow
618612
ion-col,prop,mode,"ios" | "md",undefined,false,false

core/scripts/testing/scripts.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,23 @@ const DEFAULT_PALETTE = 'light';
130130

131131
async function loadThemeTokens(themeName, paletteName) {
132132
try {
133+
// Store existing theme set from the app initialization
134+
const customTheme = window.Ionic?.config?.customTheme;
133135
// Load the default tokens for the theme
134136
const defaultTokens = await import(`/themes/${themeName}/default.tokens.js`);
135-
const theme = defaultTokens.defaultTheme;
137+
let theme = defaultTokens.defaultTheme;
138+
139+
// Merge with existing theme to preserve any customizations
140+
if (customTheme) {
141+
theme = {
142+
...theme,
143+
...customTheme,
144+
palette: {
145+
...theme.palette,
146+
...customTheme.palette,
147+
},
148+
};
149+
}
136150

137151
// If a specific palette is requested, modify the palette structure
138152
// to set the enabled property to 'always'
@@ -147,15 +161,42 @@ const DEFAULT_PALETTE = 'light';
147161
theme.palette.highContrastDark.enabled = 'always';
148162
}
149163

150-
// Apply the theme tokens to Ionic config
151-
window.Ionic = window.Ionic || {};
152-
window.Ionic.config = window.Ionic.config || {};
153-
window.Ionic.config.customTheme = theme;
164+
if (window.Ionic?.config?.set) {
165+
/**
166+
* New Page Load after Initial App Load or Playwright Test:
167+
*
168+
* If the Config instance exists, we must use the
169+
* `set()` method. This ensures the internal private Map inside
170+
* the `Config` class is updated with the loaded theme tokens.
171+
* Without this, components would read 'undefined' or 'base'
172+
* values from the stale Map when trying to access them through
173+
* methods like `config.get()`.
174+
*/
175+
window.Ionic.config.set('customTheme', theme);
176+
} else {
177+
/**
178+
* App Initialization or Browser Refresh:
179+
*
180+
* If the Config instance doesn't exist yet,
181+
* we attach the theme to the global Ionic object. The `initialize()`
182+
* method in `ionic-global.ts` will later merge this into the new
183+
* `Config` instance via `config.reset()`.
184+
*/
185+
window.Ionic = window.Ionic || {};
186+
window.Ionic.config = window.Ionic.config || {};
187+
window.Ionic.config.customTheme = theme;
188+
}
154189

155-
// Re-apply the global theme
156-
if (window.Ionic.config.get && window.Ionic.config.set) {
190+
/**
191+
* Re-applying the global theme is critical for Playwright tests.
192+
* Even if the config is set, the CSS variables for the specific theme
193+
* (e.g., md or ios) must be force-injected into the document head to
194+
* ensure visual assertions pass correctly.
195+
*/
196+
if (window.Ionic?.config?.get && window.Ionic?.config?.set) {
157197
const themeModule = await import('/themes/utils/theme.js');
158198
themeModule.applyGlobalTheme(theme);
199+
themeModule.applyComponentsTheme(theme);
159200
}
160201
} catch (error) {
161202
console.error(`Failed to load theme tokens for ${themeName}:`, error);

core/src/components.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,11 @@ export namespace Components {
872872
*/
873873
"disabled": boolean;
874874
/**
875-
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
876-
* @default 'subtle'
875+
* The fill for the chip. Set to `"outline"` for a chip with a border and background. Set to `"solid"` for a chip with a background. Defaults to `"solid"`.
876+
*/
877+
"fill"?: 'outline' | 'solid';
878+
/**
879+
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Defaults to `"subtle"`.
877880
*/
878881
"hue"?: 'bold' | 'subtle';
879882
/**
@@ -882,21 +885,18 @@ export namespace Components {
882885
"mode"?: "ios" | "md";
883886
/**
884887
* Display an outline style button.
888+
* @deprecated - Use fill="outline" instead
885889
* @default false
886890
*/
887891
"outline": boolean;
888892
/**
889-
* Set to `"soft"` for a chip with slightly rounded corners, `"round"` for a chip with fully rounded corners, or `"rectangular"` for a chip without rounded corners. Defaults to `"round"` for the `"ionic"` theme and `"soft"` for all other themes.
893+
* Set to `"soft"` for a chip with slightly rounded corners, `"round"` for a chip with fully rounded corners, or `"rectangular"` for a chip without rounded corners. Defaults to `"round"`.
890894
*/
891895
"shape"?: 'soft' | 'round' | 'rectangular';
892896
/**
893-
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` for the ionic theme, and undefined for all other themes.
897+
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"`.
894898
*/
895899
"size"?: 'small' | 'large';
896-
/**
897-
* The theme determines the visual appearance of the component.
898-
*/
899-
"theme"?: "ios" | "md" | "ionic";
900900
}
901901
interface IonCol {
902902
/**
@@ -6846,8 +6846,11 @@ declare namespace LocalJSX {
68466846
*/
68476847
"disabled"?: boolean;
68486848
/**
6849-
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
6850-
* @default 'subtle'
6849+
* The fill for the chip. Set to `"outline"` for a chip with a border and background. Set to `"solid"` for a chip with a background. Defaults to `"solid"`.
6850+
*/
6851+
"fill"?: 'outline' | 'solid';
6852+
/**
6853+
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Defaults to `"subtle"`.
68516854
*/
68526855
"hue"?: 'bold' | 'subtle';
68536856
/**
@@ -6856,21 +6859,18 @@ declare namespace LocalJSX {
68566859
"mode"?: "ios" | "md";
68576860
/**
68586861
* Display an outline style button.
6862+
* @deprecated - Use fill="outline" instead
68596863
* @default false
68606864
*/
68616865
"outline"?: boolean;
68626866
/**
6863-
* Set to `"soft"` for a chip with slightly rounded corners, `"round"` for a chip with fully rounded corners, or `"rectangular"` for a chip without rounded corners. Defaults to `"round"` for the `"ionic"` theme and `"soft"` for all other themes.
6867+
* Set to `"soft"` for a chip with slightly rounded corners, `"round"` for a chip with fully rounded corners, or `"rectangular"` for a chip without rounded corners. Defaults to `"round"`.
68646868
*/
68656869
"shape"?: 'soft' | 'round' | 'rectangular';
68666870
/**
6867-
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` for the ionic theme, and undefined for all other themes.
6871+
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"`.
68686872
*/
68696873
"size"?: 'small' | 'large';
6870-
/**
6871-
* The theme determines the visual appearance of the component.
6872-
*/
6873-
"theme"?: "ios" | "md" | "ionic";
68746874
}
68756875
interface IonCol {
68766876
/**
-33 Bytes
Loading
158 Bytes
Loading
-27 Bytes
Loading
-33 Bytes
Loading
143 Bytes
Loading
18 Bytes
Loading

core/src/components/chip/chip.common.scss

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)