From f158367eb2ca052c5ef980e1c7c26508aac12fe3 Mon Sep 17 00:00:00 2001
From: Jaydip Sanghani <91427591+jellydeck@users.noreply.github.com>
Date: Thu, 30 Oct 2025 22:22:03 +0530
Subject: [PATCH] chore: fixed QR code image, cleanup of unused imports
---
src/components/editor/Navbar.tsx | 211 +++++++++++++++++++------------
1 file changed, 130 insertions(+), 81 deletions(-)
diff --git a/src/components/editor/Navbar.tsx b/src/components/editor/Navbar.tsx
index 8175385..5243744 100644
--- a/src/components/editor/Navbar.tsx
+++ b/src/components/editor/Navbar.tsx
@@ -1,10 +1,15 @@
-import { useState } from 'react';
-import { Button } from '@/components/ui/button';
-import { Slider } from '@/components/ui/slider';
-import { Card, CardContent, CardHeader } from '@/components/ui/card';
-import { Dialog, DialogContent, DialogTrigger, DialogHeader, DialogTitle } from '@/components/ui/dialog';
-import { Badge } from '@/components/ui/badge';
-import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';
+import { useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Card, CardContent, CardHeader } from "@/components/ui/card";
+import {
+ Dialog,
+ DialogContent,
+ DialogTrigger,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
+import upiQR from "/assets/upiQR.png";
import {
Download,
ChevronDown,
@@ -16,29 +21,34 @@ import {
Twitter,
X,
CheckCircle,
- Github
-} from 'lucide-react';
-import { toast } from 'sonner';
-import { useMockupStore } from '@/contexts/MockupContext';
-import html2canvas from 'html2canvas';
+ Github,
+} from "lucide-react";
+import { toast } from "sonner";
+import { useMockupStore } from "@/contexts/MockupContext";
+import html2canvas from "html2canvas";
export function Navbar() {
const [showExportOptions, setShowExportOptions] = useState(false);
- const [exportFormat, setExportFormat] = useState('PNG');
+ const [exportFormat, setExportFormat] = useState("PNG");
const [quality, setQuality] = useState([2]);
const [isExporting, setIsExporting] = useState(false);
const [isDialogOpen, setIsDialogOpen] = useState(false);
const { uploadedImage, imageBorder, fixedMargin, margin } = useMockupStore();
- const isMobile = typeof window !== 'undefined' ? window.innerWidth < 768 : false;
+ const isMobile =
+ typeof window !== "undefined" ? window.innerWidth < 768 : false;
const getQualityLabel = (value) => {
switch (value) {
- case 1: return 'Standard (1x)';
- case 2: return 'High (2x)';
- case 3: return 'Ultra (3x)';
- default: return `${value}x`;
+ case 1:
+ return "Standard (1x)";
+ case 2:
+ return "High (2x)";
+ case 3:
+ return "Ultra (3x)";
+ default:
+ return `${value}x`;
}
};
@@ -46,11 +56,13 @@ export function Navbar() {
if (!uploadedImage) return;
try {
- const mockupElement = document.querySelector('[data-mockup-canvas]') as HTMLDivElement;
- if (!mockupElement) throw new Error('Mockup canvas not found');
+ const mockupElement = document.querySelector(
+ "[data-mockup-canvas]",
+ ) as HTMLDivElement;
+ if (!mockupElement) throw new Error("Mockup canvas not found");
- const imgElement = mockupElement.querySelector('img') as HTMLImageElement;
- if (!imgElement) throw new Error('Image element not found');
+ const imgElement = mockupElement.querySelector("img") as HTMLImageElement;
+ if (!imgElement) throw new Error("Image element not found");
// For fixed margin mode: capture the entire canvas (image + background margins)
const canvas = await html2canvas(mockupElement, {
@@ -62,13 +74,13 @@ export function Navbar() {
});
const mimeType = `image/${format.toLowerCase()}`;
- const imageQuality = format === 'JPEG' ? 1 : undefined;
+ const imageQuality = format === "JPEG" ? 1 : undefined;
canvas.toBlob(
(blob) => {
if (blob) {
const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
+ const a = document.createElement("a");
a.href = url;
a.download = `mockup-${Date.now()}.${format.toLowerCase()}`;
document.body.appendChild(a);
@@ -76,23 +88,21 @@ export function Navbar() {
document.body.removeChild(a);
URL.revokeObjectURL(url);
} else {
- throw new Error('Failed to create blob');
+ throw new Error("Failed to create blob");
}
},
mimeType,
- imageQuality
+ imageQuality,
);
-
-
} catch (error) {
- console.error('Export error:', error);
+ console.error("Export error:", error);
throw error;
}
};
const handleSingleExport = async () => {
if (!uploadedImage) {
- toast.error('Please upload an image first');
+ toast.error("Please upload an image first");
return;
}
@@ -100,10 +110,10 @@ export function Navbar() {
try {
await exportImage(exportFormat, quality[0]);
toast.success(`Successfully exported as ${exportFormat}!`, {
- icon:
+
moocup is a simple offline tool.
-+
focus on your craft, we'll take care of rest.
-+
you can show your support by sponsoring my work!
Scan with any UPI app @@ -322,13 +341,19 @@ export function Navbar() {