Repository navigation
feat(chip): sync the md theme with Material Design 2 - #31779
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me! Just a couple of small things on the states.
| state: { | ||
| disabled: { | ||
| opacity: '0.4', | ||
| opacity: '0.38', |
There was a problem hiding this comment.
I don't think anything tests the new md focus and disabled values yet. The states test only runs ios and ionic-md, with a comment saying md doesn't differ from ios, which isn't true after this PR. The regenerated md screenshots are all resting chips, so if these went back to 0.16 and 0.4 CI would still pass.
Could you add 'md' to that test's configs and drop the comment? If you'd rather not add more screenshots, something like this works too. It passes on this branch and fails on ionic-modular:
/**
* This behavior does not vary across directions.
*/
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('chip: md states'), () => {
test('should use the MD2 focus backgrounds', async ({ page }) => {
await page.setContent(
`
<ion-chip class="ion-focused" fill="solid">Solid</ion-chip>
<ion-chip class="ion-focused" fill="outline">Outline</ion-chip>
`,
config
);
const chips = page.locator('ion-chip');
await expect(chips.nth(0)).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.21)');
await expect(chips.nth(1)).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.1)');
});
test('should use the MD2 disabled opacity', async ({ page }) => {
await page.setContent(`<ion-chip disabled="true">Disabled</ion-chip>`, config);
await expect(page.locator('ion-chip')).toHaveCSS('opacity', '0.38');
});
});
});There was a problem hiding this comment.
basic/chip.e2e.ts has the same "md doesn't differ from ios" comment (line 60), so it might be worth updating that one too while you're in there.
There was a problem hiding this comment.
Added md to the states test and removed the comment in 0e17e58, so the md focus and disabled screenshots now cover these values. I went with screenshots over the toHaveCSS checks to match the rest of the spec.
There was a problem hiding this comment.
Updated in 0e17e58. The hue tests already screenshot the md outline and color chips, so the comment now points there instead of adding md to this test.
|
|
||
| activated: { | ||
| background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.2), | ||
| background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.21), |
There was a problem hiding this comment.
With the activated backgrounds removed, pressing a chip while hovering it with a mouse drops it back to its resting background, since the .ion-activated rule comes after :hover and falls back to the default. A bold solid chip goes from 0.16 on hover to 0.12 while pressed (it was 0.20 before), and an outline chip goes from 0.04 to transparent. The ripple still shows, but the chip gets lighter as you click it.
Was that intended for mouse too? Setting the activated backgrounds to the hover values would fix it on desktop, but I think it'd also tint touch presses, so I'm not sure which way is better here.
There was a problem hiding this comment.
One more case: colored chips do the same. A bold solid chip with a color goes from 12% of its color on hover to 8% while pressed, and a bold outline one goes from 12% to transparent, since the semantic activated backgrounds are gone too.
One way to fix it without tinting touch presses: move the @media (any-hover: hover) hover blocks after the .ion-activated rules in chip.scss, so hover wins while the pointer is over the chip and pressing just adds the ripple. That matches MDC, which keeps the hover layer under the press ripple.
There was a problem hiding this comment.
Not intended on desktop. Fixed in 29e7fe5: a hovered chip that's pressed now keeps its hover background, so it shows the hover tint plus the ripple. Touch presses stay untinted, since the new rule only applies inside (any-hover: hover) while the chip is hovered. Themes that set an activated background, like ios, still use it.
I also added a test that covers every hue, fill and color.
There was a problem hiding this comment.
Fixed in 29e7fe5, colored chips included. I didn't move the hover blocks after the activated rules: ios keeps a pressed background that's darker than its hover one, and on desktop hover would hide it. Instead, an .ion-activated:hover rule inside (any-hover: hover) falls back from the activated background to the hover one. md keeps the hover layer under the ripple like MDC, and ios keeps its pressed value.
brandyscarney
left a comment
There was a problem hiding this comment.
Looks good! Requesting changes for three things: the md outline chips are 2px taller than MD2 (34px large, 26px small), a hovered chip gets lighter when pressed now that the activated backgrounds are gone, and BREAKING.md is missing the subtle outline border change and the activated values to revert to. The rest are smaller questions and nits.
|
|
||
| activated: { | ||
| background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.2), | ||
| background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.21), |
There was a problem hiding this comment.
One more case: colored chips do the same. A bold solid chip with a color goes from 12% of its color on hover to 8% while pressed, and a bold outline one goes from 12% to transparent, since the semantic activated backgrounds are gone too.
One way to fix it without tinting touch presses: move the @media (any-hover: hover) hover blocks after the .ion-activated rules in chip.scss, so hover wins while the pointer is over the chip and pressing just adds the ripple. That matches MDC, which keeps the hover layer under the press ripple.
| state: { | ||
| disabled: { | ||
| opacity: '0.4', | ||
| opacity: '0.38', |
There was a problem hiding this comment.
basic/chip.e2e.ts has the same "md doesn't differ from ios" comment (line 60), so it might be worth updating that one too while you're in there.
# Conflicts: # core/src/components/avatar/test/basic/avatar.e2e.ts-snapshots/avatar-chip-diff-md-ltr-Mobile-Firefox-linux.png # core/src/components/chip/test/a11y/chip.e2e.ts-snapshots/chip-large-contents-md-ltr-Mobile-Firefox-linux.png
Issue number: internal
What is the current behavior?
The md chip has
8pxcorners and inherits its letter spacing and line height. It has8pxbetween an icon and the label, a32%outline border, and lighter focus backgrounds than Material Design 2. A pressed chip darkens under the ripple. Its rem and em values are rounded to two decimals, so it renders slightly larger than onnext(14.08pxinstead of14px).What is the new behavior?
The md chip matches Material Design 2 (Material Components Web 14 and the MD2 kit):
round).softstays8px0.0179em(0.25px) letter spacing. Thelargechip has a20pxline height. Thesmallchip has4px8pxpadding and a16pxline height, which keep it at24px, since MD2 has no small chip4pxbetween a slotted icon and the labelcolorhave a12%border21%(solid) and10%(outline). A pressed chip keeps its resting background, and the ripple shows the press0.38nextpadding,letterSpacingandline.heightmove under each size (for exampleIonChip.size.large.padding). The ionic theme looks the sameDoes this introduce a breaking change?
The md chip changes its shape, typography, icon spacing, outline border, focus and pressed backgrounds, and disabled opacity. The chip section of
BREAKING.mdlists each one with the global token and CSS variable that revert it.Other information
How to test