Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7e7b78d

Browse files
committed
Add png component
1 parent 3128671 commit 7e7b78d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

‎apps/web/app/landing/download.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use client"
2+
import * as htmlToImage from "html-to-image"
3+
4+
export function Download({ selector }: { selector: string }) {
5+
const onClick = async () => {
6+
const nodes = document.querySelectorAll(selector) as any
7+
for (const node of nodes) {
8+
const dataUrl = await htmlToImage.toPng(node as HTMLElement)
9+
var img = new Image()
10+
img.src = dataUrl
11+
document.getElementById("out")!.appendChild(img)
12+
}
13+
}
14+
return (
15+
<div>
16+
<button onClick={onClick}>As PNG</button>
17+
<div id="out" className="min-w-6 min-h-6 border"></div>
18+
</div>
19+
)
20+
}

‎apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"diff": "^5.1.0",
2727
"dotenv": "^16.4.1",
2828
"estree-util-to-js": "^2.0.0",
29+
"html-to-image": "^1.11.11",
2930
"lucide-react": "^0.303.0",
3031
"next": "14.1.0",
3132
"next-docs-mdx": "7.1.2",

‎pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /