Repository navigation
feat(router-link): add recipe and tokens - #31705
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| <p> | ||
| <ion-router-link href="#" download="yes" class="custom">Custom Router Link</ion-router-link> | ||
| </p> | ||
|
|
There was a problem hiding this comment.
These were simply moved to the hue page.
brandyscarney
left a comment
There was a problem hiding this comment.
Looks good! My questions are non-blocking unless you decide to change the implementation.
brandyscarney
left a comment
There was a problem hiding this comment.
Looks good! Thanks for making the updates.
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me! Just a few small things on the tests and docs.
| }); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
| }); | |
| }); | |
| /** | |
| * The bold and subtle hues resolve to the same color in the default | |
| * light palette, so the screenshots above can't tell them apart. | |
| * Each hue is given its own color here to verify it reads its own tokens. | |
| */ | |
| configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, config }) => { | |
| test.describe(title('router-link: hue tokens'), () => { | |
| HUES.forEach((hue) => { | |
| test(`should use the ${hue} hue tokens`, async ({ page }) => { | |
| await page.setContent( | |
| ` | |
| <ion-router-link | |
| id="default" | |
| href="#" | |
| hue="${hue}" | |
| style="--ion-router-link-hue-${hue}-default-color: rgb(1, 2, 3)" | |
| >Default</ion-router-link> | |
| <ion-router-link | |
| id="danger" | |
| href="#" | |
| hue="${hue}" | |
| color="danger" | |
| style="--ion-router-link-hue-${hue}-semantic-default-color: rgb(4, 5, 6)" | |
| >Danger</ion-router-link> | |
| `, | |
| config | |
| ); | |
| await expect(page.locator('#default')).toHaveCSS('color', 'rgb(1, 2, 3)'); | |
| await expect(page.locator('#danger')).toHaveCSS('color', 'rgb(4, 5, 6)'); | |
| }); | |
| }); | |
| }); | |
| }); |
All 9 subtle screenshots are the same file as their bold twins, so if the subtle rules pointed at the bold tokens by mistake, the whole hue suite would still pass (I tried it). Giving each hue its own color like this fails right away in that case, and it doesn't add any screenshots. I know the matching colors are the palette thing from Brandy's thread, I'm only worried about the test not being able to tell the hues apart.
|
|
||
| <h5 id="version-10x-router-link-foreground">Text color</h5> | ||
|
|
||
| A bold router link now uses the `foreground` variant of its color instead of `base`, in every theme. `foreground` is darker, so the text stays readable on the page. This applies to the default link, which uses `primary`, and to a link with `color` set. To revert to the previous appearance, set the tokens for global styles or the CSS variables for component-specific styles: |
There was a problem hiding this comment.
| A bold router link now uses the `foreground` variant of its color instead of `base`, in every theme. `foreground` is darker, so the text stays readable on the page. This applies to the default link, which uses `primary`, and to a link with `color` set. To revert to the previous appearance, set the tokens for global styles or the CSS variables for component-specific styles: | |
| A bold router link now uses the `foreground` variant of its color instead of `base`, in every theme. In the light palette, `foreground` is a darker shade of the color, so the text stays readable on the page. This applies to the default link, which uses `primary`, and to a link with `color` set. To revert to the previous appearance, set the tokens for global styles or the CSS variables for component-specific styles: |
I know the dark palette values are being sorted out in the cleanup from Brandy's thread, so this is only about the wording. In both high-contrast palettes foreground is the same as base, so the "darker" part is only true in light. Up to you!
| directions: ['ltr'], | ||
| palettes: ['light', 'dark', 'high-contrast', 'high-contrast-dark'], | ||
| }).forEach(({ title, config }) => { | ||
| test.describe(title('router-link: hue a11y'), () => { |
There was a problem hiding this comment.
I think the old router-link: a11y block is redundant now? A link with no hue resolves to bold, and this block already runs the same markup with hue="bold" across every palette the old one covers, so I'd delete the old one.
There was a problem hiding this comment.
Agreed, every theme defaults to bold. Removed in 84ba52e.
# Conflicts: # core/src/components/router-link/router-link.tsx
Issue number: resolves internal
What is the current behavior?
ion-router-linkdoes not fragment styles based on themes.What is the new behavior?
ion-router-linkto Modular Ionic, withIonRouterLinkRecipe,IonRouterLinkConfigand per-theme tokenshueproperty.subtleis new, so it has nonextreferenceforegroundvariant instead ofbase, so they're darker and easier to read on the page. This applies to the default link and a link withcolorsetDoes this introduce a breaking change?
The router link's CSS variables are replaced by token-driven custom properties. Use the global token for theme-wide styling, or the CSS variable for component-specific overrides.
--colorIonRouterLink.hue.bold.default.color--ion-router-link-hue-bold-default-colorRemoved CSS variable:
--backgroundis removed, since a router link has no background of its own. Setbackgroundonion-router-linkdirectly instead.Text color: bold links use
foregroundinstead ofbase. To revert:IonRouterLink.hue.bold.default.colorvar(--ion-color-primary)--ion-router-link-hue-bold-default-colorcolorsetIonRouterLink.hue.bold.semantic.default.colorvar(--ion-color-base)--ion-router-link-hue-bold-semantic-default-colorion-router-link.mdorion-router-link.ios.Other information
Known gaps
next. That was already true before this PR:ionic-modular's ionic palette uses different values for those colorsforegroundvalue. That comes from the palette (FW-6417), and ion-text looks the same wayionic:theme=base), a router link renders as plain text in the inherited text color with no underline, since the base theme has no palette for its tokens. It's still readable and clickable, and ion-text behaves the same wayHow to test