refactor: streamline, refine and polish
This commit is contained in:
@@ -88,14 +88,14 @@ export function FaviconFileUpload({
|
||||
/>
|
||||
|
||||
{selectedFile ? (
|
||||
<div className="border border-border rounded-lg p-4 bg-card/50 backdrop-blur-sm">
|
||||
<div className="flex items-start gap-4">
|
||||
<div className="p-2 bg-primary/10 rounded-lg">
|
||||
<FileImage className="h-6 w-6 text-primary" />
|
||||
<div className="border border-border rounded-xl p-4 bg-card/50 backdrop-blur-sm">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="p-2 bg-primary/10 rounded-lg shrink-0">
|
||||
<FileImage className="h-5 w-5 text-primary" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<p className="text-sm font-semibold text-foreground truncate" title={selectedFile.name}>
|
||||
<p className="text-sm font-medium text-foreground truncate" title={selectedFile.name}>
|
||||
{selectedFile.name}
|
||||
</p>
|
||||
<Button
|
||||
@@ -103,18 +103,18 @@ export function FaviconFileUpload({
|
||||
size="icon-xs"
|
||||
onClick={onFileRemove}
|
||||
disabled={disabled}
|
||||
className="rounded-full hover:bg-destructive/10 hover:text-destructive"
|
||||
className="rounded-full hover:bg-destructive/10 hover:text-destructive shrink-0"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="mt-2 flex gap-4 text-[10px] text-muted-foreground uppercase tracking-wider font-bold">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="mt-1.5 flex gap-3 text-[10px] text-muted-foreground">
|
||||
<div className="flex items-center gap-1">
|
||||
<HardDrive className="h-3 w-3" />
|
||||
<span>{(selectedFile.size / 1024).toFixed(1)} KB</span>
|
||||
</div>
|
||||
{dimensions && (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="flex items-center gap-1">
|
||||
<FileImage className="h-3 w-3" />
|
||||
<span>{dimensions}</span>
|
||||
</div>
|
||||
@@ -131,23 +131,23 @@ export function FaviconFileUpload({
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
className={cn(
|
||||
'border-2 border-dashed rounded-xl p-10 text-center cursor-pointer transition-all duration-300',
|
||||
'hover:border-primary/50 hover:bg-primary/5',
|
||||
'border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all duration-200',
|
||||
'hover:border-primary/40 hover:bg-primary/5',
|
||||
{
|
||||
'border-primary bg-primary/10 scale-[0.98]': isDragging,
|
||||
'border-border bg-muted/30': !isDragging,
|
||||
'border-border/50': !isDragging,
|
||||
'opacity-50 cursor-not-allowed': disabled,
|
||||
}
|
||||
)}
|
||||
>
|
||||
<div className="bg-primary/10 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
|
||||
<Upload className="h-8 w-8 text-primary" />
|
||||
<div className="bg-primary/10 w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||
<Upload className="h-6 w-6 text-primary" />
|
||||
</div>
|
||||
<p className="text-sm font-semibold text-foreground mb-1">
|
||||
<p className="text-sm font-medium text-foreground mb-0.5">
|
||||
Drop icon source here
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Recommended: 512x512 PNG or SVG
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
512x512 PNG or SVG recommended
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Download, Loader2, RefreshCw, Code2, Globe, Layout, Palette } from 'lucide-react';
|
||||
import { Download, Loader2, Code2, Globe, Layout } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
@@ -76,22 +76,16 @@ export function FaviconGenerator() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
|
||||
{/* Settings Column */}
|
||||
<div className="lg:col-span-4 space-y-6">
|
||||
<Card className="glass">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Layout className="h-5 w-5 text-primary" />
|
||||
App Details
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
Configure how your app appears on devices
|
||||
</CardDescription>
|
||||
<CardTitle>App Details</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="app-name">Application Name</Label>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="app-name" className="text-xs">Application Name</Label>
|
||||
<Input
|
||||
id="app-name"
|
||||
value={options.name}
|
||||
@@ -99,8 +93,8 @@ export function FaviconGenerator() {
|
||||
placeholder="e.g. My Awesome Website"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="short-name">Short Name</Label>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="short-name" className="text-xs">Short Name</Label>
|
||||
<Input
|
||||
id="short-name"
|
||||
value={options.shortName}
|
||||
@@ -112,22 +106,19 @@ export function FaviconGenerator() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="glass">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Palette className="h-5 w-5 text-primary" />
|
||||
Theme Colors
|
||||
</CardTitle>
|
||||
<CardTitle>Theme Colors</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="bg-color">Background</Label>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="bg-color" className="text-xs">Background</Label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
id="bg-color"
|
||||
type="color"
|
||||
className="w-10 p-1 h-10 shrink-0"
|
||||
className="w-9 p-1 h-9 shrink-0"
|
||||
value={options.backgroundColor}
|
||||
onChange={(e) => setOptions({ ...options, backgroundColor: e.target.value })}
|
||||
/>
|
||||
@@ -138,13 +129,13 @@ export function FaviconGenerator() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="theme-color">Theme</Label>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="theme-color" className="text-xs">Theme</Label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
id="theme-color"
|
||||
type="color"
|
||||
className="w-10 p-1 h-10 shrink-0"
|
||||
className="w-9 p-1 h-9 shrink-0"
|
||||
value={options.themeColor}
|
||||
onChange={(e) => setOptions({ ...options, themeColor: e.target.value })}
|
||||
/>
|
||||
@@ -159,8 +150,8 @@ export function FaviconGenerator() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="glass overflow-hidden">
|
||||
<CardContent className="p-6">
|
||||
<Card className="overflow-hidden">
|
||||
<CardContent>
|
||||
<FaviconFileUpload
|
||||
selectedFile={sourceFile}
|
||||
onFileSelect={setSourceFile}
|
||||
@@ -168,21 +159,17 @@ export function FaviconGenerator() {
|
||||
disabled={isGenerating}
|
||||
/>
|
||||
<Button
|
||||
className="w-full mt-6"
|
||||
size="lg"
|
||||
className="w-full mt-4"
|
||||
disabled={!sourceFile || isGenerating}
|
||||
onClick={handleGenerate}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<>
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
<Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" />
|
||||
Generating... {progress}%
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<RefreshCw className="mr-2 h-4 w-4" />
|
||||
Generate Favicons
|
||||
</>
|
||||
'Generate Favicons'
|
||||
)}
|
||||
</Button>
|
||||
{result && (
|
||||
@@ -200,58 +187,51 @@ export function FaviconGenerator() {
|
||||
|
||||
{/* Results Column */}
|
||||
<div className="lg:col-span-8 space-y-6">
|
||||
{!result && !isGenerating ? (
|
||||
<Card className="glass h-full flex flex-col items-center justify-center p-12 text-center text-muted-foreground border-dashed border-2">
|
||||
<Globe className="h-12 w-12 mb-4 opacity-20" />
|
||||
<h3 className="text-lg font-semibold text-foreground">Ready to generate</h3>
|
||||
<p className="max-w-xs text-sm">Upload a square image (PNG or SVG recommended) and configure your app details to get started.</p>
|
||||
</Card>
|
||||
) : isGenerating ? (
|
||||
<Card className="glass h-full flex flex-col items-center justify-center p-12 space-y-6">
|
||||
<div className="relative">
|
||||
<div className="h-24 w-24 rounded-full border-4 border-primary/20 animate-pulse" />
|
||||
<Loader2 className="h-12 w-12 text-primary animate-spin absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2" />
|
||||
</div>
|
||||
<div className="w-full max-w-sm space-y-2">
|
||||
<div className="flex justify-between text-xs font-bold uppercase tracking-widest text-muted-foreground">
|
||||
<span>Processing Icons</span>
|
||||
<span>{progress}%</span>
|
||||
{isGenerating ? (
|
||||
<Card className="h-full flex flex-col items-center justify-center p-10 space-y-4">
|
||||
<Loader2 className="h-6 w-6 text-primary animate-spin" />
|
||||
<div className="w-full max-w-xs space-y-2">
|
||||
<div className="flex items-center justify-between text-[10px] text-muted-foreground">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="font-medium">Processing...</span>
|
||||
</div>
|
||||
<span className="tabular-nums">{progress}%</span>
|
||||
</div>
|
||||
<Progress value={progress} className="h-1.5" />
|
||||
<Progress value={progress} className="h-1" />
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<div className="space-y-6 animate-fadeIn">
|
||||
) : result ? (
|
||||
<div className="space-y-5 animate-fade-in">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<h2 className="text-2xl font-bold tracking-tight">Generated Assets</h2>
|
||||
<Button onClick={handleDownloadAll} variant="default" className="shadow-lg shadow-primary/20">
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
Download All (ZIP)
|
||||
<h2 className="text-lg font-bold">Generated Assets</h2>
|
||||
<Button onClick={handleDownloadAll}>
|
||||
<Download className="mr-1.5 h-3.5 w-3.5" />
|
||||
Download ZIP
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="icons" className="w-full">
|
||||
<TabsList className="w-full">
|
||||
<TabsTrigger value="icons" className="flex items-center gap-2">
|
||||
<Layout className="h-4 w-4" />
|
||||
<TabsTrigger value="icons" className="flex items-center gap-1.5">
|
||||
<Layout className="h-3.5 w-3.5" />
|
||||
Icons
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="html" className="flex items-center gap-2">
|
||||
<Code2 className="h-4 w-4" />
|
||||
HTML Code
|
||||
<TabsTrigger value="html" className="flex items-center gap-1.5">
|
||||
<Code2 className="h-3.5 w-3.5" />
|
||||
HTML
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="manifest" className="flex items-center gap-2">
|
||||
<Globe className="h-4 w-4" />
|
||||
<TabsTrigger value="manifest" className="flex items-center gap-1.5">
|
||||
<Globe className="h-3.5 w-3.5" />
|
||||
Manifest
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="icons" className="mt-6">
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-4">
|
||||
<TabsContent value="icons" className="mt-4">
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 gap-3">
|
||||
{result?.icons.map((icon) => (
|
||||
<Card key={icon.name} className="glass group overflow-hidden">
|
||||
<div className="p-4 flex flex-col items-center text-center space-y-3">
|
||||
<div className="relative h-20 w-20 flex items-center justify-center bg-black/20 rounded-lg p-2 border border-border group-hover:scale-110 transition-transform duration-300">
|
||||
<Card key={icon.name} className="group overflow-hidden">
|
||||
<div className="p-3 flex flex-col items-center text-center space-y-2">
|
||||
<div className="relative h-16 w-16 flex items-center justify-center bg-muted/50 rounded-lg p-1.5 border border-border/50 group-hover:scale-105 transition-transform duration-200">
|
||||
{icon.previewUrl && (
|
||||
<img
|
||||
src={icon.previewUrl}
|
||||
@@ -260,12 +240,12 @@ export function FaviconGenerator() {
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-1 w-full">
|
||||
<p className="text-[10px] font-bold text-foreground truncate uppercase tracking-tighter" title={icon.name}>
|
||||
<div className="space-y-0.5 w-full">
|
||||
<p className="text-[10px] font-medium text-foreground truncate" title={icon.name}>
|
||||
{icon.name}
|
||||
</p>
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
{icon.width}x{icon.height} • {(icon.size / 1024).toFixed(1)} KB
|
||||
{icon.width}x{icon.height} · {(icon.size / 1024).toFixed(1)} KB
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -274,27 +254,27 @@ export function FaviconGenerator() {
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="html" className="mt-6 space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label>Embed in your <head></Label>
|
||||
<TabsContent value="html" className="mt-4 space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-xs">Embed in your <head></Label>
|
||||
{result && <CodeSnippet code={result.htmlCode} />}
|
||||
</div>
|
||||
<div className="p-4 rounded-lg bg-info/5 border border-info/20">
|
||||
<p className="text-xs text-info leading-relaxed">
|
||||
<strong>Note:</strong> Make sure to place the generated files in your website's root directory or update the <code>href</code> paths accordingly.
|
||||
<div className="p-3 rounded-lg bg-primary/5 border border-primary/10">
|
||||
<p className="text-[11px] text-muted-foreground leading-relaxed">
|
||||
Place generated files in your site root or update the <code className="text-primary">href</code> paths.
|
||||
</p>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="manifest" className="mt-6">
|
||||
<div className="space-y-2">
|
||||
<Label>site.webmanifest</Label>
|
||||
<TabsContent value="manifest" className="mt-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-xs">site.webmanifest</Label>
|
||||
{result && <CodeSnippet code={result.manifest} />}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user