diff --git a/components/Sigil.js b/components/Sigil.js
index 7826954321..3b1bb140bd 100644
--- a/components/Sigil.js
+++ b/components/Sigil.js
@@ -12,11 +12,19 @@ export const foregroundFromBackground = (background) => {
return whiteBrightness - brightness < 50 ? "black" : "white";
};
-export const Sigil = ({ patp, size, color = "#24201E", icon }) => {
+export const Sigil = ({
+ patp,
+ size,
+ color = "#24201E",
+ foregroundColor = false,
+ icon,
+}) => {
if (patp.length > 14) {
return
{
return whiteBrightness - brightness < 50 ? "black" : "white";
};
-const Sigil = ({ patp, size, color = "#24201E", icon }) => {
- if (patp.length > 14) {
- return
;
- }
- const foreground = foregroundFromBackground(color);
- return (
-
- {sigil({
- patp: patp,
- renderer: stringRenderer,
- size: icon ? size / 2 : size,
- colors: [color, foreground],
- icon: icon || false,
- })}
-
- );
-};
-
export default (req, res) => {
- const foreground = foregroundFromBackground(
- `#${req.query.color || "24201E"}`
- );
+ const foreground = req?.query?.foreground
+ ? `#${req?.query?.foreground}`
+ : foregroundFromBackground(`#${req.query.color || "24201E"}`);
+ const { patp = "~zod", color = "24201E", filetype = "png" } = req?.query;
const svg = sigil({
- patp: req.query.patp,
+ patp: patp,
renderer: stringRenderer,
size: 1024,
- colors: [`#${req.query.color || "24201E"}`, foreground],
+ colors: [`#${color}`, foreground],
icon: false,
});
const svgDataString = "data:image/svg+xml," + svg;
- const canvas = createCanvas(1024, 1024);
+ const canvas = createCanvas(
+ 1024,
+ 1024,
+ filetype === "svg" ? "svg" : undefined
+ );
const ctx = canvas.getContext("2d");
const canvasImage = new Image();
canvasImage.src = svgDataString;
ctx.drawImage(canvasImage, 0, 0);
- const buffer = canvas.toBuffer();
+ const buffer =
+ filetype === "png" ? canvas.toBuffer() : canvas.toBuffer("image/svg+xml");
res.writeHead(200, {
- "Content-Type": "image/png",
+ "Content-Type": filetype === "png" ? "image/png" : "image/svg+xml",
+ ...(filetype === "svg" && {
+ "Content-Disposition": `attachment; filename=${patp}.svg`,
+ }),
"Content-Length": buffer.length,
});
res.end(buffer, "binary");
diff --git a/pages/ids/index.js b/pages/ids/index.js
new file mode 100644
index 0000000000..4cc583f69f
--- /dev/null
+++ b/pages/ids/index.js
@@ -0,0 +1,117 @@
+import Header from "../../components/Header";
+import Footer from "../../components/Footer";
+import {
+ Container,
+ IntraNav,
+ SingleColumn,
+ Section,
+} from "@urbit/foundation-design-system";
+import { useState } from "react";
+import ob from "urbit-ob";
+import Sigil from "../../components/Sigil";
+
+export default function SigilGenerator({ search }) {
+ const [background, setBackground] = useState("#24201E");
+ const [foreground, setForeground] = useState("#ffffff");
+ const [patp, setPatp] = useState("~wolref-podlex");
+ return (
+
+
+
+
+
+ Urbit ID
+
+
+
+
Urbit ID
+
setPatp(e.target.value)}
+ value={patp}
+ className="h-full min-w-0 p-4 bg-white text-black border-l"
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}