hezarfen_landing
Clone
https://git.tahinli.com/archive/hezarfen_landing.git
0 watching0 forksTypeScript581.6 KiB94b1804Burak Boduroğlu2 months ago15 commits
| 1 | /** |
| 2 | * Screenshots the running site, band by band, so a layout regression is |
| 3 | * something you can look at rather than something you have to notice. |
| 4 | * |
| 5 | * Usage: start a server (`bun .output/server/index.mjs`), then |
| 6 | * bun scripts/shoot.mjs [baseUrl] [outDir] |
| 7 | * |
| 8 | * Playwright is not a dependency of this project: the script resolves it from |
| 9 | * wherever it is installed via `PLAYWRIGHT` so CI does not have to carry a |
| 10 | * browser download for a tool only used by hand. |
| 11 | */ |
| 12 | const { chromium } = await import(process.env.PLAYWRIGHT ?? "playwright"); |
| 13 | |
| 14 | const base = process.argv[2] ?? "http://localhost:3000"; |
| 15 | const out = process.argv[3] ?? "/tmp/hezarfen-shots"; |
| 16 | |
| 17 | const shots = [ |
| 18 | { name: "hero", width: 1440, height: 900, y: 0 }, |
| 19 | { name: "mobile", width: 390, height: 844, y: 0 }, |
| 20 | ]; |
| 21 | |
| 22 | const browser = await chromium.launch(); |
| 23 | |
| 24 | for (const shot of shots) { |
| 25 | const page = await browser.newPage({ |
| 26 | viewport: { width: shot.width, height: shot.height }, |
| 27 | deviceScaleFactor: 1, |
| 28 | }); |
| 29 | await page.goto(base, { waitUntil: "networkidle" }); |
| 30 | await page.waitForTimeout(1200); |
| 31 | await page.screenshot({ path: `${out}/${shot.name}.png` }); |
| 32 | await page.close(); |
| 33 | } |
| 34 | |
| 35 | // Every band, at desktop width, in one tall pass. |
| 36 | const page = await browser.newPage({ viewport: { width: 1440, height: 900 } }); |
| 37 | await page.goto(base, { waitUntil: "networkidle" }); |
| 38 | |
| 39 | // Walk the whole page first: the reveal observer only fires for blocks that |
| 40 | // have been in the viewport, and a section taller than the window would |
| 41 | // otherwise be photographed with its lower half still at opacity 0. |
| 42 | const height = await page.evaluate(() => document.body.scrollHeight); |
| 43 | for (let y = 0; y < height; y += 600) { |
| 44 | await page.evaluate(offset => window.scrollTo(0, offset), y); |
| 45 | await page.waitForTimeout(120); |
| 46 | } |
| 47 | await page.waitForTimeout(900); |
| 48 | await page.evaluate(() => window.scrollTo(0, 0)); |
| 49 | for (const id of [ |
| 50 | "neden", |
| 51 | "urunler", |
| 52 | "moduller", |
| 53 | "nasil-calisir", |
| 54 | "roller", |
| 55 | "guven", |
| 56 | "kimler-icin", |
| 57 | "hakkimizda", |
| 58 | "sss", |
| 59 | "iletisim", |
| 60 | ]) { |
| 61 | const band = page.locator(`#${id}`); |
| 62 | await band.scrollIntoViewIfNeeded(); |
| 63 | // The reveal transitions run for 700ms plus an 80ms per-card stagger. |
| 64 | await page.waitForTimeout(1400); |
| 65 | await band.screenshot({ path: `${out}/${id}.png` }); |
| 66 | } |
| 67 | await browser.close(); |
| 68 | |
| 69 | console.log(`wrote ${out}`); |