Repository navigation
Keep profile avatar cutouts transparent and align the header gutter #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
020c9b9
Keep profile avatar cutouts transparent in every pointer state
klopez4212 919927b
Document approved avatar cutout appearance in both themes
klopez4212 ce4abd5
Align avatar browser coverage and viewer with transparent controls
klopez4212 4c16272
Keep avatar cutout snapshots in PR description
codex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import { test, expect } from "./fixture.mjs"; | ||
|
|
||
| // Real CSS paint and shell geometry require a browser, not DOM emulation. | ||
| test("profile avatar cutout shows the shell through hover, press and open menu", async ({ | ||
| page, | ||
| app, | ||
| browserName, | ||
| }, testInfo) => { | ||
| await page.goto(app.origin); | ||
| const control = page.getByRole("button", { | ||
| name: "Your profile", | ||
| exact: true, | ||
| includeHidden: true, | ||
| }); | ||
| await expect(control.locator(".buzz-avatar-status")).toHaveAttribute( | ||
| "data-status", | ||
| "online", | ||
| ); | ||
| await control.click(); | ||
| await page.getByRole("menuitem", { name: "Settings", exact: true }).click(); | ||
| await expect(page.getByRole("main")).toBeFocused(); | ||
| for (const width of [390, 639, 640, 650, 700, 701, 1280]) { | ||
| await page.setViewportSize({ width, height: 844 }); | ||
| const avatar = await control.boundingBox(); | ||
| const panel = await page | ||
| .locator('[aria-labelledby="settings-title"]') | ||
| .boundingBox(); | ||
| expect(avatar.width).toBe(40); | ||
| expect | ||
| .soft(avatar.x + avatar.width, `${width}px: avatar and card right edges`) | ||
| .toBe(panel.x + panel.width); | ||
| } | ||
| await page.setViewportSize({ width: 1280, height: 844 }); | ||
| for (const mode of ["light", "dark"]) { | ||
| await page.emulateMedia({ colorScheme: mode }); | ||
| await expect(page.locator("html")).toHaveAttribute("data-color-mode", mode); | ||
| // Return to an ordinary pointer state after the preceding keyboard check. | ||
| await page.mouse.click(400, 20); | ||
| await page.mouse.move(0, 0); | ||
| const bounds = await control.boundingBox(); | ||
| const clip = { | ||
| x: bounds.x - 4, | ||
| y: bounds.y - 4, | ||
| width: bounds.width + 8, | ||
| height: bounds.height + 8, | ||
| }; | ||
| await control.evaluate((el) => { | ||
| el.style.visibility = "hidden"; | ||
| }); | ||
| let background; | ||
| try { | ||
| background = await page.screenshot({ clip }); | ||
| } finally { | ||
| await control.evaluate((el) => { | ||
| el.style.removeProperty("visibility"); | ||
| }); | ||
| } | ||
| const sample = (png) => | ||
| page.evaluate(async (base64) => { | ||
| const image = new Image(); | ||
| image.src = `data:image/png;base64,${base64}`; | ||
| await image.decode(); | ||
| const canvas = document.createElement("canvas"); | ||
| canvas.width = image.width; | ||
| canvas.height = image.height; | ||
| const ctx = canvas.getContext("2d"); | ||
| ctx.drawImage(image, 0, 0); | ||
| const at = (x, y) => [...ctx.getImageData(x, y, 1, 1).data]; | ||
| return { | ||
| // The screenshot includes 4px outside the 40px control. Its gap | ||
| // is at avatar-local (29,29); the other samples detect a focus ring. | ||
| gap: at(33, 33), | ||
| left: at(1, 24), | ||
| top: at(24, 1), | ||
| right: at(46, 24), | ||
| }; | ||
| }, png.toString("base64")); | ||
| const expected = await sample(background); | ||
| for (const state of ["rest", "hover", "pressed", "open"]) { | ||
| if (state === "hover") await control.hover(); | ||
| if (state === "pressed") await page.mouse.down(); | ||
| if (state === "open") { | ||
| await expect(control).toHaveAttribute("aria-expanded", "true"); | ||
| } | ||
| try { | ||
| await expect(control).toHaveCSS("outline-style", "none"); | ||
| await expect(control).toHaveCSS("border-width", "0px"); | ||
| await expect(control).toHaveCSS("box-shadow", "none"); | ||
| const screenshot = await page.screenshot({ | ||
| clip, | ||
| path: testInfo.outputPath(`${mode}-${state}.png`), | ||
| }); | ||
| expect | ||
| .soft( | ||
| await sample(screenshot), | ||
| `${mode}/${state}: clear cutout and no pointer ring`, | ||
| ) | ||
| .toEqual(expected); | ||
| await page.screenshot({ | ||
| path: testInfo.outputPath(`${mode}-${state}-shell.png`), | ||
| }); | ||
| } finally { | ||
| if (state === "pressed") await page.mouse.up(); | ||
| } | ||
| } | ||
| await page.keyboard.press("Escape"); | ||
| await expect(control).toBeFocused(); | ||
| const tab = | ||
| browserName === "webkit" && process.platform === "darwin" | ||
| ? "Alt+Tab" | ||
| : "Tab"; | ||
| await page.keyboard.press(`Shift+${tab}`); | ||
| await page.keyboard.press(tab); | ||
| await expect(control).toBeFocused(); | ||
| await expect(control).toHaveCSS("outline-style", "solid"); | ||
| await expect(control).toHaveCSS("outline-width", "2px"); | ||
| await page.screenshot({ | ||
| path: testInfo.outputPath(`${mode}-keyboard-focus.png`), | ||
| }); | ||
| await control.press("Enter"); | ||
| await expect(control).toHaveAttribute("aria-expanded", "true"); | ||
| await page.keyboard.press("Escape"); | ||
| await expect(control).toHaveCSS("mask-image", "none"); | ||
| await page.mouse.click(400, 20); | ||
| await expect(control).not.toBeFocused(); | ||
| await expect(control).toHaveCSS("outline-style", "none"); | ||
| await page.screenshot({ path: testInfo.outputPath(`${mode}-shell.png`) }); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.