Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-crews-guess.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Add support for prefers-reduced-motion animations on TooltipV2 & Overlay
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 27 additions & 15 deletions e2e/components/SelectPanel.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ const scenarios = matrix({
{
id: 'components-selectpanel-examples--height-initial-with-underflowing-items-after-fetch',
name: 'Height Initial with Underflowing Items After Fetch',
visual: false,
},
{
id: 'components-selectpanel-dev--with-css',
Expand DownExpand Up@@ -61,17 +62,22 @@ test.describe('SelectPanel', () => {
featureFlags: {primer_react_select_panel_with_modern_action_list: scenario.modernActionList},
}

test(`${name} @vrt ${theme} ${flag}`, async ({page}) => {
await visit(page, {id: scenario.story.id, globals})

// Open select panel
const isPanelOpen = await page.isVisible('[role="listbox"]')
if (!isPanelOpen) {
await page.keyboard.press('Tab')
await page.keyboard.press('Enter')
}
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`SelectPanel.${name}.${theme}${flag}.png`)
})
if (scenario.story.visual !== false) {
test(`${name} @vrt ${theme} ${flag}`, async ({page}) => {
await visit(page, {id: scenario.story.id, globals})
await page.emulateMedia({reducedMotion: 'reduce'})

// Open select panel
const isPanelOpen = await page.isVisible('[role="listbox"]')
if (!isPanelOpen) {
await page.keyboard.press('Tab')
await page.keyboard.press('Enter')
}
expect(await page.screenshot({animations: 'disabled', caret: 'hide'})).toMatchSnapshot(
`SelectPanel.${name}.${theme}${flag}.png`,
)
})
}

test(`${name} axe @aat ${theme} ${flag}`, async ({page}) => {
await visit(page, {id: scenario.story.id, globals})
Expand DownExpand Up@@ -99,14 +105,20 @@ test.describe('SelectPanel', () => {
}

// windows high contrast mode: light
await page.emulateMedia({forcedColors: 'active', colorScheme: 'light'})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
await page.emulateMedia({forcedColors: 'active', colorScheme: 'light', reducedMotion: 'reduce'})
await page.getByRole('listbox').waitFor({state: 'visible'})
await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(255, 255, 255)')

expect(await page.screenshot({animations: 'disabled', caret: 'hide'})).toMatchSnapshot(
`SelectPanel-Default-forced-colors-light-modern-action-list--true.png`,
)

// windows high contrast mode: dark
await page.emulateMedia({forcedColors: 'active', colorScheme: 'dark'})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
await page.emulateMedia({forcedColors: 'active', colorScheme: 'dark', reducedMotion: 'reduce'})
await page.getByRole('listbox').waitFor({state: 'visible'})
await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(0, 0, 0)')

expect(await page.screenshot({animations: 'disabled', caret: 'hide'})).toMatchSnapshot(
`SelectPanel-Default-forced-colors-dark-modern-action-list--true.png`,
)
})
Expand Down
6 changes: 2 additions & 4 deletions e2e/components/TooltipV2.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,6 @@ const stories = [
{
title: 'Calculated Direction',
id: 'components-tooltipv2-features--calculated-direction',
disableAnimations: true,
},
{
title: 'Icon Button With Description',
Expand DownExpand Up@@ -45,9 +44,8 @@ test.describe('TooltipV2', () => {

// Default state
await page.keyboard.press('Tab')
await expect(page).toHaveScreenshot(`TooltipV2.${story.title}.${theme}.png`, {
animations: 'disabled',
})
await page.emulateMedia({reducedMotion: 'reduce'})
await expect(page).toHaveScreenshot(`TooltipV2.${story.title}.${theme}.png`)
})
})
}
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/Overlay/Overlay.module.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,6 @@
background-color: var(--overlay-bgColor);
border-radius: var(--borderRadius-large);
box-shadow: var(--shadow-floating-small);
animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);

&:focus {
outline: none;
Expand DownExpand Up@@ -178,3 +177,9 @@
}
}
}

@media (prefers-reduced-motion: no-preference) {
.Overlay {
animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);
}
}
38 changes: 20 additions & 18 deletions packages/react/src/TooltipV2/Tooltip.module.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,6 @@
background: var(--tooltip-bgColor);
border: 0;
border-radius: var(--borderRadius-medium);
opacity: 0;
-webkit-font-smoothing: subpixel-antialiased;
inset: auto;
}
Expand DownExpand Up@@ -99,24 +98,27 @@
content: '';
}

/* Animation styles */
&:popover-open,
&:popover-open::before {
animation-name: tooltip-appear;
animation-duration: 0.1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: 0s;
}
/* Only show animations if users don't have a preference for reduced motion */
@media screen and (prefers-reduced-motion: no-preference) {
/* Animation styles */
&:popover-open,
&:popover-open::before {
animation-name: tooltip-appear;
animation-duration: 0.1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: 0s;
}

/* Animation styles */
&:global(.\\:popover-open) /* stylelint-disable-line selector-class-pattern */,
&:global(.\\:popover-open)::before /* stylelint-disable-line selector-class-pattern */ {
animation-name: tooltip-appear;
animation-duration: 0.1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: 0s;
/* Animation styles */
&:global(.\\:popover-open) /* stylelint-disable-line selector-class-pattern */,
&:global(.\\:popover-open)::before /* stylelint-disable-line selector-class-pattern */ {
animation-name: tooltip-appear;
animation-duration: 0.1s;
animation-fill-mode: forwards;
animation-timing-function: ease-in;
animation-delay: 0s;
}
}
}
Comment thread
adierkens marked this conversation as resolved.

Expand Down