From ed3950b5d031b20b51ffaf8863537e471f7747e9 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Sat, 20 Dec 2025 19:38:27 +0100 Subject: [PATCH] feature: Migrate FileUpload to shadcn/ui and fix dark mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrated FileUpload component to use shadcn/ui Card, Button, Alert, and Progress components. Updated dark mode CSS variables to use media query approach for automatic system theme detection. Fixed Card component padding and button styling for better visual consistency. Changes: - Replaced custom div with shadcn Card and CardContent components - Migrated buttons to shadcn Button component with outline variant for Choose File - Replaced custom alerts with shadcn Alert components - Replaced custom progress bars with shadcn Progress component - Fixed Card padding by adding p-0 to Card and rounded-lg to CardContent - Changed dark mode from .dark class to @media (prefers-color-scheme: dark) - Fixed primary-foreground color in dark mode for proper white text contrast 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/App.css | 54 +++---- src/components/FileUpload.tsx | 199 ++++++++++++-------------- src/components/PatternSummaryCard.tsx | 4 +- 3 files changed, 125 insertions(+), 132 deletions(-) diff --git a/src/App.css b/src/App.css index 7f17468..8f860de 100644 --- a/src/App.css +++ b/src/App.css @@ -60,43 +60,45 @@ --radius: 0.5rem; } - .dark { - --background: 222.2 84% 4.9%; - --foreground: 210 40% 98%; + @media (prefers-color-scheme: dark) { + :root { + --background: 222.2 84% 4.9%; + --foreground: 210 40% 98%; - --card: 222.2 84% 4.9%; - --card-foreground: 210 40% 98%; + --card: 222.2 84% 4.9%; + --card-foreground: 210 40% 98%; - --popover: 222.2 84% 4.9%; - --popover-foreground: 210 40% 98%; + --popover: 222.2 84% 4.9%; + --popover-foreground: 210 40% 98%; - --primary: 217.2 91.2% 59.8%; /* blue-500 lighter for dark */ - --primary-foreground: 222.2 47.4% 11.2%; + --primary: 217.2 91.2% 59.8%; /* blue-500 lighter for dark */ + --primary-foreground: 210 40% 98%; - --secondary: 20.5 90.2% 48.2%; /* orange-600 for dark */ - --secondary-foreground: 210 40% 98%; + --secondary: 20.5 90.2% 48.2%; /* orange-600 for dark */ + --secondary-foreground: 210 40% 98%; - --muted: 217.2 32.6% 17.5%; - --muted-foreground: 215 20.2% 65.1%; + --muted: 217.2 32.6% 17.5%; + --muted-foreground: 215 20.2% 65.1%; - --accent: 263.4 70% 50.4%; /* purple-600 for dark */ - --accent-foreground: 210 40% 98%; + --accent: 263.4 70% 50.4%; /* purple-600 for dark */ + --accent-foreground: 210 40% 98%; - --destructive: 0 62.8% 30.6%; /* red-900 */ - --destructive-foreground: 210 40% 98%; + --destructive: 0 62.8% 30.6%; /* red-900 */ + --destructive-foreground: 210 40% 98%; - --success: 142.1 70.6% 45.3%; /* green-500 for dark */ - --success-foreground: 210 40% 98%; + --success: 142.1 70.6% 45.3%; /* green-500 for dark */ + --success-foreground: 210 40% 98%; - --warning: 47.9 95.8% 53.1%; /* amber-400 for dark */ - --warning-foreground: 26 83.3% 14.1%; + --warning: 47.9 95.8% 53.1%; /* amber-400 for dark */ + --warning-foreground: 26 83.3% 14.1%; - --info: 188.7 85.7% 53.3%; /* cyan-500 */ - --info-foreground: 210 40% 98%; + --info: 188.7 85.7% 53.3%; /* cyan-500 */ + --info-foreground: 210 40% 98%; - --border: 217.2 32.6% 17.5%; - --input: 217.2 32.6% 17.5%; - --ring: 224.3 76.3% 48%; + --border: 217.2 32.6% 17.5%; + --input: 217.2 32.6% 17.5%; + --ring: 224.3 76.3% 48%; + } } } diff --git a/src/components/FileUpload.tsx b/src/components/FileUpload.tsx index 30ebfc3..15309ca 100644 --- a/src/components/FileUpload.tsx +++ b/src/components/FileUpload.tsx @@ -21,6 +21,12 @@ import { } from "@heroicons/react/24/solid"; import { createFileService } from "../platform"; import type { IFileService } from "../platform/interfaces/IFileService"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent } from "@/components/ui/card"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Progress } from "@/components/ui/progress"; +import { Loader2 } from "lucide-react"; +import { cn } from "@/lib/utils"; export function FileUpload() { // Machine store @@ -202,31 +208,30 @@ export function FileUpload() { : "text-gray-600 dark:text-gray-400"; return ( -
-
- -
-

- Pattern File -

- {pesData && displayFileName ? ( -

- {displayFileName} -

- ) : ( -

- No pattern loaded -

- )} + + +
+ +
+

+ Pattern File +

+ {pesData && displayFileName ? ( +

+ {displayFileName} +

+ ) : ( +

+ No pattern loaded +

+ )} +
-
{resumeAvailable && resumeFileName && (
@@ -253,63 +258,66 @@ export function FileUpload() { className="hidden" disabled={isLoading || patternUploaded || isUploading} /> - + {pesData && canUploadPattern(machineStatus) && !patternUploaded && uploadProgress < 100 && ( - + )}
@@ -364,12 +354,7 @@ export function FileUpload() { {pyodideProgress.toFixed(0)}%
-
-
-
+

{isLoading && !pyodideReady ? "File dialog will open automatically when ready" @@ -393,15 +378,22 @@ export function FileUpload() { }} > {pesData && !canUploadPattern(machineStatus) && ( -

- Cannot upload while {getMachineStateCategory(machineStatus)} -
+ + + Cannot upload while {getMachineStateCategory(machineStatus)} + + )} {pesData && boundsCheck.error && ( -
- Pattern too large: {boundsCheck.error} -
+ + + Pattern too large: {boundsCheck.error} + + )}
@@ -417,14 +409,13 @@ export function FileUpload() { : "Starting..."}
-
-
-
+
)} - + + ); } diff --git a/src/components/PatternSummaryCard.tsx b/src/components/PatternSummaryCard.tsx index d80773f..354c66e 100644 --- a/src/components/PatternSummaryCard.tsx +++ b/src/components/PatternSummaryCard.tsx @@ -30,8 +30,8 @@ export function PatternSummaryCard() { const canDelete = canDeletePattern(machineStatus); return ( - - + +