Repository navigation
feat(router-link): add the link states from the ionic design - #31707
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
If we're not a fan of the focus ring, I would vote in creating a follow up PR so we can investigate what values to use by looking into MD2 and iOS native components.
There was a problem hiding this comment.
Material Design 2 uses a background on focus on their clear buttons:
Material Design 3 seems to use a ring for their "text" buttons:
I think we should probably match MD2 for the initial MD theme that is added then support the ring when we add MD3 support. We might want to make this configurable?
I am fine with this being a follow-up ticket.
There was a problem hiding this comment.
Thanks for the references! Changed md and ios to match MD2 in 78b2a24: a focused link now gets a tinted background like the clear button (the link's color at 12% in md, 10% in ios), with a bit of padding that doesn't move the text. The ring is still there for ionic, and a theme can set the ring, the background or both through tokens, so MD3 can switch to the ring without code changes.
brandyscarney
left a comment
There was a problem hiding this comment.
Left some non-blocking questions. 👍
There was a problem hiding this comment.
Material Design 2 uses a background on focus on their clear buttons:
Material Design 3 seems to use a ring for their "text" buttons:
I think we should probably match MD2 for the initial MD theme that is added then support the ring when we add MD3 support. We might want to make this configurable?
I am fine with this being a follow-up ticket.
# Conflicts: # BREAKING.md # core/api.txt # core/src/components/router-link/router-link.scss
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me! Just a few small things, the subtle hue one is probably the main one.
| hue: { | ||
| bold: { | ||
| activated: { | ||
| color: '#09358a', |
There was a problem hiding this comment.
Since #09358a is hardcoded here and the ionic dark palette doesn't override it, a pressed or visited link would be around 1.9:1 once dark gets a real dark background. It doesn't affect anything today because ionic's dark palette is still a placeholder with a white page, so this is just something to keep in mind for FW-7558. No action required.
There was a problem hiding this comment.
Good catch, I'll keep it in mind when the ionic dark palette gets its real background.
| @@ -945,6 +953,35 @@ export const defaultTheme: DefaultTheme = { | |||
| }, | |||
There was a problem hiding this comment.
Was leaving activated and visited off subtle on purpose? Right now a pressed subtle link underlines but stays #004acd, while a bold link that looks the same at rest turns #09358a, and visited subtle links keep the resting color too. Adding the same activated and visited colors under hue.subtle makes them match.
There was a problem hiding this comment.
Not on purpose, thanks! Added them in df3ed27, so subtle pressed and visited links now match bold.
| /** | ||
| * This behavior does not vary across directions. | ||
| */ | ||
| configs({ modes: ['ios', 'md', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { |
There was a problem hiding this comment.
This only renders the default bold hue, but every state rule is generated for subtle too. Adding some hue="subtle" links, like chip/test/states does, would catch the subtle pressed color I mentioned on the ionic tokens. The test/states/index.html page would need them too.
There was a problem hiding this comment.
Added subtle links to the test and to test/states/index.html in bf1b63b.
| a { | ||
| @include mixins.text-inherit(); | ||
|
|
||
| // The focus ring below replaces the browser's own ring |
There was a problem hiding this comment.
| // The focus ring below replaces the browser's own ring | |
| // The theme's focus ring or background below replaces the browser's own ring |
The md and ios themes don't set any ring tokens, so the tinted background is what shows focus there. I'd also rename the should be focusable for the focus ring spec to something like should add the ion-focusable class for the same reason.
| * @prop --ion-router-link-state-focus-padding-bottom: Bottom padding of the focus background | ||
| * @prop --ion-router-link-state-focus-padding-end: End padding of the focus background | ||
| * @prop --ion-router-link-state-focus-padding-start: Start padding of the focus background | ||
| * @prop --ion-router-link-state-focus-padding-top: Top padding of the focus background |
There was a problem hiding this comment.
| * @prop --ion-router-link-state-focus-padding-bottom: Bottom padding of the focus background | |
| * @prop --ion-router-link-state-focus-padding-end: End padding of the focus background | |
| * @prop --ion-router-link-state-focus-padding-start: Start padding of the focus background | |
| * @prop --ion-router-link-state-focus-padding-top: Top padding of the focus background | |
| * @prop --ion-router-link-state-focus-padding-bottom: Bottom padding of the focus ring and background | |
| * @prop --ion-router-link-state-focus-padding-end: End padding of the focus ring and background | |
| * @prop --ion-router-link-state-focus-padding-start: Start padding of the focus ring and background | |
| * @prop --ion-router-link-state-focus-padding-top: Top padding of the focus ring and background |
The ionic theme has no focus background, so these only size the ring there. This matches the border-radius prop's wording.
| 3. The color applied by the `color` prop is now driven by the centralized Ionic Theming system, scoped to the new `hue` property. <sup>[3](#version-10x-router-link-hue)</sup> | ||
| 4. The text color now uses the color's `foreground` variant instead of `base`. <sup>[4](#version-10x-router-link-foreground)</sup> | ||
| 5. Mode classes (`ion-router-link.md`, `ion-router-link.ios`) are no longer supported. <sup>[5](#version-10x-router-link-mode-classes)</sup> | ||
| 5. A focused router link now shows a tinted background instead of the browser's focus ring. <sup>[5](#version-10x-router-link-focus)</sup> |
There was a problem hiding this comment.
| 5. A focused router link now shows a tinted background instead of the browser's focus ring. <sup>[5](#version-10x-router-link-focus)</sup> | |
| 5. In the `md` and `ios` themes, a focused router link now shows a tinted background instead of the browser's focus ring. In the `ionic` theme, it shows a 2px ring. <sup>[5](#version-10x-router-link-focus)</sup> |
Right now this reads like ionic gets a tinted background too, but it draws a 2px ring with no background. The main sentence in the Focus style section has the same problem.
There was a problem hiding this comment.
Updated the list item and the Focus style paragraph in 9066e4a.
| test.describe(title('router-link: states'), () => { | ||
| test('should not have visual regressions', async ({ page }) => { | ||
| /** | ||
| * The padding keeps the focus ring, which sits outside the |
There was a problem hiding this comment.
Nit: these comments are a lot heavier than the other router-link tests. I think the CSS ones could each be a single line, and the empty href note is already in test/states/index.html. The Firefox note is useful though, so I'd keep that one. No worries if you don't want to do that.
There was a problem hiding this comment.
Shortened them in e737edd and kept the Firefox note.
…o bold Co-authored-by: Shane <[email protected]>
Co-authored-by: Shane <[email protected]>
Co-authored-by: Shane <[email protected]>
Co-authored-by: Shane <[email protected]>
Co-authored-by: Shane <[email protected]>
Co-authored-by: Shane <[email protected]>
Issue number: resolves internal
What is the current behavior?
ion-router-linkhas no pressed, visited or focus styles. The browser draws its own focus ring.What is the new behavior?
ionictheme, links match the design kit:colorturns#09358awhen pressed or visited#b5c0f7ring with 4px cornersiosandmdthemes, a focused link shows a tinted background instead of the browser's ring, matching the clear button: the link's color at 12% opacity inmdand 10% inios, with padding that doesn't move the texthue.<hue>.activated.color,hue.<hue>.visited.colorandhue.<hue>.focus.background(also undersemantic),state.focus.ring,state.focus.border.radius,state.focus.padding, andtext.decoration, whichstate.activatedandstate.focuscan overrideDoes this introduce a breaking change?
iosandmd, a focused router link now shows a tinted background instead of the browser's default ring. Customize it with the tokens for global styles, or the CSS variables for component-specific styles:IonRouterLink.hue.bold.focus.background--ion-router-link-hue-bold-focus-backgroundcolorsetIonRouterLink.hue.bold.semantic.focus.background--ion-router-link-hue-bold-semantic-focus-backgroundIonRouterLink.state.focus.border.radius--ion-router-link-state-focus-border-radiusIonRouterLink.state.focus.padding--ion-router-link-state-focus-padding-top,-end,-bottom,-startOther information
Focus style in ios and md
Neither theme has a design for a focused link, and they can't keep the browser's ring, because the rule that draws the ionic ring turns it off in every theme. Both follow MD2's clear button, which shows focus as a tinted background, and reuse the button's clear focus values. A theme can set the ring, the background or both, so a future MD3 theme can show a ring through tokens alone.
Known gaps
ionictheme, although the design kit shows an underline. Browsers only allow color changes on:visitedto protect browsing history, sotext-decorationthere is ignored. Visited links still get the darker colorionictheme, links withcolorset keep their color when pressed or visited. The kit only shows the primary link, and the palette has no darker variant to useHow to test
The states page is new, so Before points at the basic page.