-
Notifications
You must be signed in to change notification settings - Fork 0
fix: fix mobile layout clipping for GitHub corner, Share Doom button, and grim reaper #67
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
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ coverage/ | |
| *.log | ||
| .DS_Store | ||
| test-results/ | ||
| screenshots/ | ||
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,99 @@ | ||
| #!/usr/bin/env node | ||
| // scripts/screenshots.js | ||
| // Headlessly capture desktop and mobile screenshots of the site. | ||
| // | ||
| // Usage: | ||
| // npm run screenshots | ||
| // | ||
| // Screenshots are saved to the `screenshots/` directory (gitignored). | ||
| // The script spins up a local static server on port 3001 automatically, | ||
| // so it can be run without a pre-existing server. To target a running | ||
| // server instead, set the SCREENSHOT_URL environment variable: | ||
| // SCREENSHOT_URL=https://nitrocode.github.io/token-deathclock/ npm run screenshots | ||
|
|
||
| 'use strict'; | ||
|
|
||
| const { chromium } = require('@playwright/test'); | ||
| const { spawn } = require('child_process'); | ||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
|
|
||
| const OUT_DIR = path.join(process.cwd(), 'screenshots'); | ||
| const PORT = 3001; | ||
| const BASE_URL = process.env.SCREENSHOT_URL || `http://localhost:${PORT}`; | ||
|
|
||
| /** Viewport + context configs to capture */ | ||
| const CONFIGS = [ | ||
| { | ||
| name: 'desktop', | ||
| viewport: { width: 1280, height: 800 }, | ||
| isMobile: false, | ||
| deviceScaleFactor: 1, | ||
| }, | ||
| { | ||
| name: 'mobile', | ||
| viewport: { width: 390, height: 844 }, | ||
| isMobile: true, | ||
| deviceScaleFactor: 3, | ||
| }, | ||
| ]; | ||
|
|
||
| /** Milliseconds to wait for the local server to start */ | ||
| const SERVER_STARTUP_MS = 2000; | ||
|
|
||
| async function waitMs(/** @type {number} */ ms) { | ||
| return new Promise(resolve => setTimeout(resolve, ms)); | ||
| } | ||
|
|
||
| async function main() { | ||
| fs.mkdirSync(OUT_DIR, { recursive: true }); | ||
|
|
||
| // Only start a local server when using the default localhost URL | ||
| let serverProcess = null; | ||
| if (!process.env.SCREENSHOT_URL) { | ||
| serverProcess = spawn( | ||
| 'npx', ['serve', '.', '-p', String(PORT), '-s'], | ||
| { stdio: 'ignore', detached: false } | ||
| ); | ||
| // Give the server time to start | ||
| await waitMs(SERVER_STARTUP_MS); | ||
| } | ||
|
|
||
| let exitCode = 0; | ||
|
|
||
| try { | ||
| const browser = await chromium.launch(); | ||
|
|
||
| for (const cfg of CONFIGS) { | ||
| const context = await browser.newContext({ | ||
| viewport: cfg.viewport, | ||
| isMobile: cfg.isMobile, | ||
| deviceScaleFactor: cfg.deviceScaleFactor, | ||
| }); | ||
|
|
||
| const page = await context.newPage(); | ||
| await page.goto(BASE_URL); | ||
| await page.waitForLoadState('networkidle'); | ||
|
|
||
| const outFile = path.join(OUT_DIR, `${cfg.name}.png`); | ||
| await page.screenshot({ path: outFile, fullPage: false }); | ||
| console.log(`[screenshots] Saved ${outFile}`); | ||
|
|
||
| await context.close(); | ||
| } | ||
|
|
||
| await browser.close(); | ||
| console.log(`[screenshots] Done. Files are in: ${OUT_DIR}`); | ||
| } catch (err) { | ||
| console.error('[screenshots] Error:', err instanceof Error ? err.message : String(err)); | ||
| exitCode = 1; | ||
| } finally { | ||
| if (serverProcess) { | ||
| serverProcess.kill(); | ||
| } | ||
| } | ||
|
|
||
| process.exit(exitCode); | ||
| } | ||
|
|
||
| main(); | ||
Large diffs are not rendered by default.
Oops, something went wrong.
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
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.