refactor: standardize string quotes and improve formatting in components
This commit is contained in:
parent
ee341522f5
commit
0f79ed14f0
@ -1,10 +1,10 @@
|
|||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Zap, Sparkles } from "lucide-react";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Button } from "@/components/ui/button";
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { Sparkles, Zap } from 'lucide-react';
|
||||||
|
|
||||||
export type QualityMode = "performance" | "quality";
|
export type QualityMode = 'performance' | 'quality';
|
||||||
|
|
||||||
interface QualityModeToggleProps {
|
interface QualityModeToggleProps {
|
||||||
value: QualityMode;
|
value: QualityMode;
|
||||||
@ -25,9 +25,9 @@ export function QualityModeToggle({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onValueChange("performance");
|
onValueChange('performance');
|
||||||
toast({
|
toast({
|
||||||
description: "Switching to faster models for quicker generation",
|
description: 'Switching to faster models for quicker generation',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@ -39,10 +39,10 @@ export function QualityModeToggle({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onValueChange("quality");
|
onValueChange('quality');
|
||||||
toast({
|
toast({
|
||||||
description:
|
description:
|
||||||
"Switching to higher quality models for better results",
|
'Switching to higher quality models for better results',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
export function Stopwatch({ startTime }: { startTime: number }) {
|
export function Stopwatch({ startTime }: { startTime: number }) {
|
||||||
const [elapsed, setElapsed] = useState(0);
|
const [elapsed, setElapsed] = useState(0);
|
||||||
@ -12,6 +12,8 @@ export function Stopwatch({ startTime }: { startTime: number }) {
|
|||||||
}, [startTime]);
|
}, [startTime]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-lg text-zinc-500 font-mono">{(elapsed / 1000).toFixed(1)}s</div>
|
<div className="text-lg text-zinc-500 font-mono">
|
||||||
|
{(elapsed / 1000).toFixed(1)}s
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const imageHelpers = {
|
export const imageHelpers = {
|
||||||
base64ToBlob: (base64Data: string, type = "image/png"): Blob => {
|
base64ToBlob: (base64Data: string, type = 'image/png'): Blob => {
|
||||||
const byteString = atob(base64Data);
|
const byteString = atob(base64Data);
|
||||||
const arrayBuffer = new ArrayBuffer(byteString.length);
|
const arrayBuffer = new ArrayBuffer(byteString.length);
|
||||||
const uint8Array = new Uint8Array(arrayBuffer);
|
const uint8Array = new Uint8Array(arrayBuffer);
|
||||||
@ -13,7 +13,7 @@ export const imageHelpers = {
|
|||||||
|
|
||||||
generateImageFileName: (provider: string): string => {
|
generateImageFileName: (provider: string): string => {
|
||||||
const uniqueId = Math.random().toString(36).substring(2, 8);
|
const uniqueId = Math.random().toString(36).substring(2, 8);
|
||||||
return `${provider}-${uniqueId}`.replace(/[^a-z0-9-]/gi, "");
|
return `${provider}-${uniqueId}`.replace(/[^a-z0-9-]/gi, '');
|
||||||
},
|
},
|
||||||
|
|
||||||
shareOrDownload: async (
|
shareOrDownload: async (
|
||||||
@ -22,7 +22,7 @@ export const imageHelpers = {
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const fileName = imageHelpers.generateImageFileName(provider);
|
const fileName = imageHelpers.generateImageFileName(provider);
|
||||||
const blob = imageHelpers.base64ToBlob(imageData);
|
const blob = imageHelpers.base64ToBlob(imageData);
|
||||||
const file = new File([blob], `${fileName}.png`, { type: "image/png" });
|
const file = new File([blob], `${fileName}.png`, { type: 'image/png' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (navigator.share) {
|
if (navigator.share) {
|
||||||
@ -31,13 +31,13 @@ export const imageHelpers = {
|
|||||||
title: `Image generated by ${provider}`,
|
title: `Image generated by ${provider}`,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Share API not available");
|
throw new Error('Share API not available');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fall back to download for any error (including share cancellation)
|
// Fall back to download for any error (including share cancellation)
|
||||||
console.error("Error sharing/downloading:", error);
|
console.error('Error sharing/downloading:', error);
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
const link = document.createElement("a");
|
const link = document.createElement('a');
|
||||||
link.href = blobUrl;
|
link.href = blobUrl;
|
||||||
link.download = `${fileName}.png`;
|
link.download = `${fileName}.png`;
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
@ -48,6 +48,6 @@ export const imageHelpers = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatModelId: (modelId: string): string => {
|
formatModelId: (modelId: string): string => {
|
||||||
return modelId.split("/").pop() || modelId;
|
return modelId.split('/').pop() || modelId;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user