Build Anidev design laboratory with six interactive concepts
This commit is contained in:
commit
ae037908ab
60 files changed
+5084
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { chromium } from "playwright";
|
||||
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 {
|
||||
const page = await browser.newPage();
|
||||
for (const device of ["desktop", "mobile"])
|
||||
for (const theme of ["light", "dark"]) {
|
||||
const width = device === "desktop" ? 640 : 300,
|
||||
height = device === "desktop" ? 570 : 780;
|
||||
await page.setViewportSize({
|
||||
width: width * 3,
|
||||
height: (height + 35) * 2,
|
||||
});
|
||||
await page.setContent(
|
||||
`<style>*{box-sizing:border-box}body{margin:0;background:#303335;color:white;display:grid;grid-template-columns:repeat(3,${width}px);font:14px Arial}section{width:${width}px;height:${height + 35}px;padding:0 8px 8px}header{height:35px;padding:10px}img{width:100%;height:${height - 8}px;object-fit:contain;object-position:top;background:#202224}</style>${["relay", "ledger", "signal", "axis", "dock", "grid"].map((c) => `<section><header>${c.toUpperCase()} / ${theme} / ${device}</header><img src="${base}/test-results/screenshots/${c}-${theme}-${device}-dashboard.png"></section>`).join("")}`,
|
||||
);
|
||||
await page
|
||||
.locator("img")
|
||||
.evaluateAll((imgs) => Promise.all(imgs.map((i) => i.decode())));
|
||||
await page.screenshot({
|
||||
path: `references/concepts-${theme}-${device}.jpg`,
|
||||
type: "jpeg",
|
||||
quality: 90,
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Reference in new issue
Block a user