Repository navigation
Conversation
Recipe values under mediaQuery.min.resolution set the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.
The line is a filled box instead of a border, since WebKit skips borders thinner than one CSS pixel at some positions. The ios theme sets the thickness per screen density.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Chrome-linux.png # core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Firefox-linux.png # core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Safari-linux.png
There was a problem hiding this comment.
The open item's shadow from #31731 was already being drawn but was too faint to fail the old snapshot. This PR's half-pixel label move pushed the image over the threshold, so the regenerated snapshot now shows it too.
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me, great work! Left a few comments, mostly docs wording. The accordion lines one is the one I'd most like to see changed.
| @@ -332,8 +332,8 @@ ion-accordion-group.accordion-group-expand-inset > ion-accordion:last-of-type { | |||
| border-bottom-right-radius: 8px; | |||
| } | |||
|
|
|||
| ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"] { | |||
| --border-width: 0px; | |||
| ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line) { | |||
There was a problem hiding this comment.
| ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line) { | |
| ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line), | |
| ion-accordion.accordion-expanding > ion-item[slot="header"]::part(line), | |
| ion-accordion.accordion-expanded > ion-item[slot="header"]::part(line) { |
I think we can drop headerLineHidden and updateHeaderLine and hide the line here, since the host already gets accordion-expanding and accordion-expanded. Setting lines on the item shows up in the app, so an open accordion's header reads item.lines === 'none' even though nothing set it, and if the app sets lines="inset" while it's open, collapsing puts it back to 'full'. With this selector and the lines bullet dropped from BREAKING.md, the accordion screenshots come out identical and lines is never touched.
The line color has a similar problem, since updateNextLineColor only runs in componentDidLoad. If the header item's color changes later, the line above the next header keeps the old shade, where before it was the item's own border and followed color.
There was a problem hiding this comment.
Done in 9d8d03e with your selector, and the lines bullet is gone from BREAKING.md. For the color, 9f1826f watches the header item's color attribute with a MutationObserver, so the line follows it when it changes or is removed, and adds a test for both. I kept the line in the accordion rather than drawing it from core.scss, so the observer is what keeps it in sync.
|
|
||
| color: var(--border-color); | ||
|
|
||
| // Painted like a border: above the native element's background, |
There was a problem hiding this comment.
Was it intentional for the lines to sit under the state overlay? With both at z-index: -1, the ::after overlay comes later and paints over them. On ios the line goes from #c8c7cc to about rgb(175, 174, 179) while pressed and rgb(170, 169, 173) when focused, and in the ionic theme on an md touch device the pressed line takes on the fill color, though they're close enough that it's hard to notice. The ionic focus ring covers the line row now too.
Native iOS hides the separator on highlight anyway, so I don't think this is a big deal, but the "Painted like a border" comment isn't accurate anymore. If you do want the lines on top, z-index: -2 on the ::after works, as long as the ionic focus ring's ::after stays at -1 so it keeps its bottom row.
There was a problem hiding this comment.
Not intentional. 415ba6c moves the state overlay to z-index: -2 so the lines paint above it again, keeps the ionic focus ring at -1 so it keeps its bottom edge, and updates the comment. The pressed and focused snapshots are regenerating.
|
|
||
| <h4 id="version-10x-item">Item</h4> | ||
|
|
||
| The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them. `--border-color` still sets their color. |
There was a problem hiding this comment.
| The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them. `--border-color` still sets their color. | |
| The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them, and `--border-style` no longer changes their style. `--border-color` still sets their color. | |
| `--border-width` and `--inner-border-width` still draw a border on the item, so an app that set them to thicken a line now gets that border on top of the line. Remove those overrides and style the `line` or `inner-line` part instead. |
Since --border-width and --inner-border-width still set border-width on the item, an app with --border-width: 0 0 2px 0 now gets a 2px border with the new line on top of it. And --border-style: dashed comes out solid because the lines are gradient fills now. The @prop docs for those vars still describe the lines too, so I think they need the same update.
There was a problem hiding this comment.
Done in f2a42b7. The @prop docs for --border-width, --inner-border-width and --border-style now say they don't apply to the lines too.
|
|
||
| - **The key isn't part of the variable name**, unlike a state. The stylesheet reads one variable, `--ion-divider-thickness`, on every screen. | ||
| - **List values from smallest to largest.** When several queries match, the last one wins. | ||
| - **An app's value applies on every screen.** A custom theme that sets `IonDivider.thickness` drops the theme's `mediaQuery` values for `thickness`. To change the value per screen, the custom theme sets its own `mediaQuery`. |
There was a problem hiding this comment.
| - **An app's value applies on every screen.** A custom theme that sets `IonDivider.thickness` drops the theme's `mediaQuery` values for `thickness`. To change the value per screen, the custom theme sets its own `mediaQuery`. | |
| - **A value under the custom theme's `ios` or `md` key applies on every screen.** Setting `IonDivider.thickness` there drops the theme's `mediaQuery` values for `thickness`. A value merged straight into the theme's tokens, like `deepMerge(iosTheme, { components: { IonDivider: { thickness: '2px' } } })`, keeps them, so it only applies on 1x screens. To change the value on every screen or per screen, set `mediaQuery` alongside it. |
I think this only holds under the custom theme's ios or md key. The app merges its custom theme over the base tokens, which have no IonDivider, so an app that does deepMerge(iosTheme, ...) with a 2px thickness still gets 0.5px and 0.3334px on 2x and 3x screens and only sees 2px at 1x. The JSDoc on IonMediaQuery and IonDividerRecipe.mediaQuery says the same thing, so I'd scope those too.
There was a problem hiding this comment.
Done in 25d5d56. I called it the "per-mode" ios or md key so it doesn't read as the md theme, and scoped the IonMediaQuery and IonDividerRecipe.mediaQuery JSDoc the same way.
| * for that key, so it applies on every screen. | ||
| */ | ||
| export type IonMediaQuery<T> = { | ||
| /** Applies when the screen is at least the given value. When several match, the largest wins. */ |
There was a problem hiding this comment.
| /** Applies when the screen is at least the given value. When several match, the largest wins. */ | |
| /** | |
| * Applies when the screen is at least the given value. When several match, | |
| * the last key wins, so list values from smallest to largest. | |
| */ |
There's no sort in getMediaQueries, so the last key wins, which matches what the theme.ts JSDoc and the recipes doc say. A theme that lists 3dppx before 2dppx gets 0.5px on a 3x screen. Sorting min ascending would also work if you'd rather keep "the largest wins", but then it'd need a spec. Up to you!
There was a problem hiding this comment.
Done in afb4309. I kept "the last key wins" rather than adding a sort.
| /** | ||
| * `shift` and `scroll` set the starting shift and scroll offset, in pixels, | ||
| * so an automated check can screenshot the lines at exact positions. | ||
| */ |
There was a problem hiding this comment.
| /** | |
| * `shift` and `scroll` set the starting shift and scroll offset, in pixels, | |
| * so an automated check can screenshot the lines at exact positions. | |
| */ | |
| /** | |
| * `shift` and `scroll` set the starting shift and scroll offset, in pixels, | |
| * so a link can open the page with the lines at exact positions. | |
| */ |
Nothing loads this page or passes shift or scroll, so I think this points at a check that doesn't exist? I'm not asking for an e2e, since this doesn't reproduce in Playwright anyway, just the reword.
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
…lements Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
…de key Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
Issue number: resolves #30772
What is the current behavior?
On iOS, WebKit skips borders thinner than one CSS pixel at some positions on the page, so the 0.55px line between items disappears while scrolling.
What is the new behavior?
hairlinemixin that draws a line as a filled box along a top or bottom edge instead of a border. Without a thickness, it is one screen pixel thick at 1x, 2x and 3x.mediaQueryrecipe key: values undermediaQuery.min.resolutionset the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.ion-dividerdraws its line with the mixin, and the ios theme sets it to one screen pixel at each density.ion-itemdraws its full and inset lines with the mixin in every theme, as thelineandinner-lineparts. Lines sit on the item's bottom edge instead of below it. The ios theme sets them to one screen pixel at each density.colorwhen it has one.Does this introduce a breaking change?
In every theme:
--border-widthand--inner-border-widthno longer draw the lines between items. Uselines="none"to hide a line, or style it withion-item::part(line)(full width) orion-item::part(inner-line)(inset).--border-colorstill sets the line color.In the ios theme:
--border-coloron an accordion's header item no longer changes the line above it.Other information
Known gaps
thicknessonly shows on 1x screens.How to test
Lines draw one screen pixel thick, with none missing, in Safari on the iOS 17.5 and 26.2 simulators at every position the hairlines page reaches.
Lines look lighter than before in desktop browsers and in Chrome's device toolbar. Those drew the old 0.55px border two screen pixels thick, and the new line is one screen pixel, which is what iPhones always drew.
core/src/components/item/test/hairlines/index.htmlonnextand runnpm start