forked from innovacion/playground
Initial commit
This commit is contained in:
26
frontend/lib/utils.ts
Normal file
26
frontend/lib/utils.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { type ClassValue, clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
// Helper para descargar imagen
|
||||
export function downloadImage(base64Data: string, filename: string) {
|
||||
const link = document.createElement('a');
|
||||
link.href = `data:image/png;base64,${base64Data}`;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
// Helper para generar nombre de archivo único
|
||||
export function generateImageFilename(prompt: string): string {
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const safePrompt = prompt
|
||||
.slice(0, 30)
|
||||
.replace(/[^a-z0-9]/gi, '_')
|
||||
.toLowerCase();
|
||||
return `image_${safePrompt}_${timestamp}.png`;
|
||||
}
|
||||
Reference in New Issue
Block a user