@@ -31,7 +31,7 @@ const styleTestHelpers = `
3131 background: rgba(var(--ion-color-base-rgb), 0.16);
3232 }
3333 .ion-color {
34- color: var(--ion-color-base );
34+ color: var(--ion-color-foreground );
3535 }
3636 .ion-color-contrast {
3737 color: var(--ion-color-contrast);
@@ -52,7 +52,7 @@ const styleTestHelpers = `
5252configs ( { modes : [ 'md' ] , directions : [ 'ltr' ] , palettes : [ 'light' , 'dark' ] } ) . forEach ( ( { config, title } ) => {
5353 const colors = [ 'primary' , 'secondary' , 'tertiary' , 'success' , 'warning' , 'danger' , 'light' , 'medium' , 'dark' ] ;
5454
55- test . describe ( title ( 'theme ' ) , ( ) => {
55+ test . describe ( title ( 'palette colors: bold ' ) , ( ) => {
5656 test . beforeEach ( ( { skip } ) => {
5757 skip . browser ( 'firefox' , 'Color contrast ratio is consistent across browsers' ) ;
5858 skip . browser ( 'webkit' , 'Color contrast ratio is consistent across browsers' ) ;
@@ -227,3 +227,66 @@ configs({ modes: ['md'], directions: ['ltr'], palettes: ['high-contrast', 'high-
227227 } ) ;
228228 }
229229) ;
230+
231+ configs ( { modes : [ 'md' ] , directions : [ 'ltr' ] } ) . forEach ( ( { config, title } ) => {
232+ test . describe ( title ( 'colors: custom' ) , ( ) => {
233+ // TODO(): this test can be removed when foreground is a required variant
234+ // for ios and md themes
235+ test ( `overriding secondary color without foreground variant should style text properly` , async ( { page } ) => {
236+ await page . setContent (
237+ `${ styleTestHelpers }
238+
239+ <style>
240+ :root {
241+ --ion-color-secondary: #ff6c52;
242+ --ion-color-secondary-rgb: 255,108,82;
243+ --ion-color-secondary-contrast: #000000;
244+ --ion-color-secondary-contrast-rgb: 0,0,0;
245+ --ion-color-secondary-shade: #e05f48;
246+ --ion-color-secondary-tint: #ff7b63;
247+ }
248+ </style>
249+
250+ <main class="ion-color-secondary">
251+ <p class="ion-color">Hello World</p>
252+ </main>` ,
253+ config
254+ ) ;
255+
256+ const paragraph = await page . locator ( 'p' ) ;
257+ const color = await paragraph . evaluate ( ( el ) => getComputedStyle ( el ) . color ) ;
258+
259+ // Ensure the color matches --ion-color-secondary
260+ expect ( color ) . toBe ( 'rgb(255, 108, 82)' ) ;
261+ } ) ;
262+
263+ test ( `overriding secondary color with foreground variant should style text properly` , async ( { page } ) => {
264+ await page . setContent (
265+ `${ styleTestHelpers }
266+
267+ <style>
268+ :root {
269+ --ion-color-secondary: #ff6c52;
270+ --ion-color-secondary-rgb: 255,108,82;
271+ --ion-color-secondary-contrast: #000000;
272+ --ion-color-secondary-contrast-rgb: 0,0,0;
273+ --ion-color-secondary-shade: #e05f48;
274+ --ion-color-secondary-tint: #ff7b63;
275+ --ion-color-secondary-foreground: #e05f48;
276+ }
277+ </style>
278+
279+ <main class="ion-color-secondary">
280+ <p class="ion-color">Hello World</p>
281+ </main>` ,
282+ config
283+ ) ;
284+
285+ const paragraph = await page . locator ( 'p' ) ;
286+ const color = await paragraph . evaluate ( ( el ) => getComputedStyle ( el ) . color ) ;
287+
288+ // Ensure the color matches --ion-color-secondary-foreground
289+ expect ( color ) . toBe ( 'rgb(224, 95, 72)' ) ;
290+ } ) ;
291+ } ) ;
292+ } ) ;
0 commit comments