29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
import { chromium } from "playwright";
|
|
import { mkdir } from "node:fs/promises";
|
|
const base = process.env.BASE_URL || "http://127.0.0.1:4173";
|
|
const browser = await chromium.launch({
|
|
executablePath:
|
|
process.env.PLAYWRIGHT_EXECUTABLE_PATH ||
|
|
(process.platform === "win32"
|
|
? "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
: undefined),
|
|
headless: true,
|
|
});
|
|
try {
|
|
await mkdir("references/approved-dock", { recursive: true });
|
|
const page = await browser.newPage({
|
|
viewport: { width: 1440, height: 390 },
|
|
});
|
|
await page.setContent(
|
|
`<style>*{box-sizing:border-box}body{margin:0;display:flex;background:#18272d;color:white;font:14px Arial}section{width:720px}header{height:40px;padding:12px}img{display:block;width:720px;height:350px;object-fit:contain}</style>${["light", "dark"].map((theme) => `<section><header>ANIDEV DOCK / ${theme.toUpperCase()} / ROW HOVER</header><img src="${base}/references/approved-dock/rows-${theme}-desktop.png"></section>`).join("")}`,
|
|
);
|
|
await page
|
|
.locator("img")
|
|
.evaluateAll((images) =>
|
|
Promise.all(images.map((image) => image.decode())),
|
|
);
|
|
await page.screenshot({ path: "references/approved-dock/preview.png" });
|
|
} finally {
|
|
await browser.close();
|
|
}
|