0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

Hide the dev toolbar on print (#11496)

* Hide the dev toolbar on print

* Run checkset

* Add a test case
This commit is contained in:
Abdulrahman Alfawal 2024-07-19 00:14:57 +03:00 committed by GitHub
parent ee21ac761f
commit 53ccd206f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Hide the dev toolbar on `window.print()` (CTRL + P)

View file

@ -413,4 +413,28 @@ test.describe('Dev Toolbar', () => {
}
}
});
test('hidden on print media', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
const toolbar = page.locator('astro-dev-toolbar');
const settingsAppButton = toolbar.locator('button[data-app-id="astro:settings"]');
await settingsAppButton.click();
const settingsAppCanvas = toolbar.locator(
'astro-dev-toolbar-app-canvas[data-app-id="astro:settings"]'
);
const settingsWindow = settingsAppCanvas.locator('astro-dev-toolbar-window');
await expect(settingsWindow).toBeVisible();
await page.emulateMedia({ media: 'print' });
await expect(settingsWindow).not.toBeVisible();
await page.emulateMedia({ media: 'screen' });
await expect(settingsWindow).toBeVisible();
await settingsAppButton.click();
await expect(settingsWindow).not.toBeVisible();
});
});

View file

@ -49,6 +49,11 @@ export class AstroDevToolbar extends HTMLElement {
z-index: 999999;
view-transition-name: astro-dev-toolbar;
display: contents;
/* Hide the dev toolbar on window.print() (CTRL + P) */
@media print {
display: none;
}
}
::view-transition-old(astro-dev-toolbar),