mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat(v4): update home page * fix * fix: cards * feat(v4): charts page * feat: update pages * feat: colors * fix * feat: add docs * feat: mdx work * fix * fix * fix: sidebar * fix: lint * feat: updates * feat: update components * feat: fix docs * fix: responsive * feat: implement cmdk * fix: update navigation menu demo * fix: code style * fix: themes * feat: implement blocks page * fix: docs config * refactor * fix: outputFileTracingIncludes * fix * fix: output * fix * fix: registry * refactor: move docs * debug: docs * debug * revert * fix: mjs * deps: pin fumadocs * debug * fix: downgrade next * fix: index page * refactor: move mdx components * fix: remove copy button * fix * was it zod * yes it was * remove copy page * fix: color page * fix: colors page * fix: meta colors * fix: copy button * feat: sync registry * fix: registry build script * feat: update port * feat: clean up examples * fix * fix: mobile nav * fix: blur for mobile * fix: sidebar nav * feat: update examples * fix: build scripts * feat: update components * feat: restyle * fix: types * fix: styles * fix: margins * fix: screenshots * fix * feat: update theme * fix: charts nav * fix: image * feat: optimize images * fix: menu * fix: card * fix: border * check * feat: implement charts page * fix: charts * fix: og images * feat: extend touch * fix: static * fix: sizing * fix: mobile screenshots * fix: page nav * fix * feat: update favicon * fix: theme selector * fix: feedback * fix: sink * docs: update * fix: styles * chore: update registry * fix: command * fix * fix: minor updates * fix: typography on smaller devices * fix: format * fix: remove unused icon * feat: update favicon * fix: typography * docs: typography page * fix: steps
101 lines
2.5 KiB
TypeScript
101 lines
2.5 KiB
TypeScript
import { existsSync } from "fs"
|
|
import path from "path"
|
|
import puppeteer from "puppeteer"
|
|
|
|
import { getAllBlockIds } from "../lib/blocks"
|
|
|
|
const REGISTRY_PATH = path.join(process.cwd(), "public/r")
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Capture screenshots.
|
|
// ----------------------------------------------------------------------------
|
|
async function captureScreenshots() {
|
|
const blockIds = await getAllBlockIds()
|
|
const blocks = blockIds.filter((block) => {
|
|
// Check if screenshots already exist
|
|
const lightPath = path.join(
|
|
REGISTRY_PATH,
|
|
`styles/new-york-v4/${block}-light.png`
|
|
)
|
|
const darkPath = path.join(
|
|
REGISTRY_PATH,
|
|
`styles/new-york-v4/${block}-dark.png`
|
|
)
|
|
return !existsSync(lightPath) || !existsSync(darkPath)
|
|
})
|
|
|
|
if (blocks.length === 0) {
|
|
console.log("✨ All screenshots exist, nothing to capture")
|
|
return
|
|
}
|
|
|
|
const browser = await puppeteer.launch({
|
|
defaultViewport: {
|
|
width: 1440,
|
|
height: 900,
|
|
deviceScaleFactor: 2,
|
|
},
|
|
})
|
|
|
|
for (const block of blocks) {
|
|
const pageUrl = `http://localhost:4000/view/${block}`
|
|
|
|
const page = await browser.newPage()
|
|
await page.goto(pageUrl, {
|
|
waitUntil: "networkidle2",
|
|
})
|
|
|
|
console.log(`- Capturing ${block}...`)
|
|
|
|
for (const theme of ["light", "dark"]) {
|
|
const screenshotPath = path.join(
|
|
REGISTRY_PATH,
|
|
`styles/new-york-v4/${block}${theme === "dark" ? "-dark" : "-light"}.png`
|
|
)
|
|
|
|
if (existsSync(screenshotPath)) {
|
|
continue
|
|
}
|
|
|
|
// Set theme and reload page
|
|
await page.evaluate((currentTheme) => {
|
|
localStorage.setItem("theme", currentTheme)
|
|
}, theme)
|
|
|
|
await page.reload({ waitUntil: "networkidle2" })
|
|
|
|
// Wait for animations to complete
|
|
if (block.startsWith("chart") || block.startsWith("dashboard")) {
|
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
}
|
|
|
|
// Hide Tailwind indicator
|
|
await page.evaluate(() => {
|
|
const indicator = document.querySelector("[data-tailwind-indicator]")
|
|
if (indicator) {
|
|
indicator.remove()
|
|
}
|
|
})
|
|
|
|
await page.screenshot({
|
|
path: screenshotPath,
|
|
})
|
|
}
|
|
|
|
await page.close()
|
|
}
|
|
|
|
await browser.close()
|
|
}
|
|
|
|
try {
|
|
console.log("🔍 Capturing screenshots...")
|
|
|
|
await captureScreenshots()
|
|
|
|
console.log("✅ Done!")
|
|
} catch (error) {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}
|