update ui
This commit is contained in:
1 parent
7674f12c5e
commit
d3a5df6387
9 files changed
+1476
-1317
No files matched your search
Generated
+807
-915
File diff suppressed because it is too large.
Load diff
@@ -9,7 +9,12 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.474.0",
|
||||
"@emotion/cache": "^11.14.0",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@mui/icons-material": "^7.3.9",
|
||||
"@mui/material": "^7.3.9",
|
||||
"@mui/material-nextjs": "^7.3.9",
|
||||
"next": "^16.1.6",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4"
|
||||
@@ -18,9 +23,6 @@
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"autoprefixer": "^10.0.1",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/** @type {import('postcss-load-config').Config} */
|
||||
const config = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,19 +1,21 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--background: #282828;
|
||||
--foreground: #ebdbb2;
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #282828;
|
||||
color: #ebdbb2;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
@@ -23,19 +25,7 @@ body {
|
||||
color: #ebdbb2;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #1d2021;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #504945;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #665c54;
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist } from "next/font/google";
|
||||
import { Roboto } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const geist = Geist({ subsets: ["latin"] });
|
||||
import Providers from "./providers";
|
||||
|
||||
const roboto = Roboto({
|
||||
subsets: ["latin"],
|
||||
weight: ["300", "400", "500", "700"],
|
||||
variable: "--font-roboto",
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "File Host",
|
||||
@@ -16,7 +22,9 @@ export default function RootLayout({
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={geist.className}>{children}</body>
|
||||
<body className={roboto.variable}>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
+410
-342
@@ -1,15 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
||||
import CloudUploadIcon from "@mui/icons-material/CloudUpload";
|
||||
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
||||
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
|
||||
import LockIcon from "@mui/icons-material/Lock";
|
||||
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
||||
import ReplayIcon from "@mui/icons-material/Replay";
|
||||
import {
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
Copy,
|
||||
ExternalLink,
|
||||
Lock,
|
||||
RotateCcw,
|
||||
Upload,
|
||||
} from "lucide-react";
|
||||
import { ChangeEvent, DragEvent, useCallback, useRef, useState } from "react";
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Chip,
|
||||
Divider,
|
||||
LinearProgress,
|
||||
Stack,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import type { ChangeEvent, DragEvent } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
type Status = "idle" | "authenticated" | "uploading" | "done";
|
||||
|
||||
@@ -23,12 +34,16 @@ export default function Home() {
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [pendingFileName, setPendingFileName] = useState("");
|
||||
const [uploadedFile, setUploadedFile] = useState<{
|
||||
name: string;
|
||||
type: string;
|
||||
size: number;
|
||||
previewUrl?: string;
|
||||
} | null>(null);
|
||||
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const preUploadStatus = useRef<"idle" | "authenticated">("idle");
|
||||
|
||||
// ── Auth ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const handleUnlock = async () => {
|
||||
if (!password.trim()) return;
|
||||
const body = new URLSearchParams({ password });
|
||||
@@ -41,8 +56,6 @@ export default function Home() {
|
||||
}
|
||||
};
|
||||
|
||||
// ── Upload ────────────────────────────────────────────────────────────────
|
||||
|
||||
const uploadFile = useCallback(
|
||||
(file: File) => {
|
||||
preUploadStatus.current =
|
||||
@@ -53,6 +66,16 @@ export default function Home() {
|
||||
setErrorMessage("");
|
||||
setPendingFileName(file.name);
|
||||
|
||||
const isPreviewable =
|
||||
file.type.startsWith("image/") || file.type.startsWith("video/");
|
||||
const previewUrl = isPreviewable ? URL.createObjectURL(file) : undefined;
|
||||
setUploadedFile({
|
||||
name: file.name,
|
||||
type: file.type || "application/octet-stream",
|
||||
size: file.size,
|
||||
previewUrl,
|
||||
});
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
if (status === "authenticated") {
|
||||
@@ -63,9 +86,6 @@ export default function Home() {
|
||||
|
||||
xhr.upload.onprogress = (e) => {
|
||||
if (e.lengthComputable) {
|
||||
// Cap at 99 — the final 100 is set only once the server responds,
|
||||
// because the file is still being streamed to R2 after the browser
|
||||
// finishes sending bytes.
|
||||
setProgress(Math.min(99, Math.round((e.loaded / e.total) * 100)));
|
||||
}
|
||||
};
|
||||
@@ -103,9 +123,6 @@ export default function Home() {
|
||||
setStatus(preUploadStatus.current);
|
||||
};
|
||||
|
||||
// Explicitly set responseType to "text" so Firefox does not attempt to
|
||||
// parse the JSON response body as XML (which would log a benign but
|
||||
// confusing "XML Parsing Error" in the console).
|
||||
xhr.responseType = "text";
|
||||
xhr.open("POST", "/api/upload");
|
||||
xhr.send(formData);
|
||||
@@ -113,8 +130,6 @@ export default function Home() {
|
||||
[status, password],
|
||||
);
|
||||
|
||||
// ── Drag and drop ─────────────────────────────────────────────────────────
|
||||
|
||||
const handleDragOver = useCallback(
|
||||
(e: DragEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
@@ -149,28 +164,21 @@ export default function Home() {
|
||||
[uploadFile],
|
||||
);
|
||||
|
||||
// ── Copy ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const handleCopy = async () => {
|
||||
await navigator.clipboard.writeText(resultUrl);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
const isAuthenticated = status === "authenticated";
|
||||
const isUploading = status === "uploading";
|
||||
const isInteractable = status !== "uploading";
|
||||
|
||||
// Show the auth badge when authenticated, or when uploading/done from an
|
||||
// authenticated session (preUploadStatus tells us what we came from).
|
||||
const showAuthBadge =
|
||||
status === "authenticated" ||
|
||||
((status === "uploading" || status === "done") &&
|
||||
preUploadStatus.current === "authenticated");
|
||||
|
||||
// Show the auth row at all when there is something to render inside it.
|
||||
const showAuthRow = status === "idle" || showAuthBadge;
|
||||
|
||||
const limitLabel =
|
||||
@@ -178,337 +186,397 @@ export default function Home() {
|
||||
? "250 MB"
|
||||
: "50 MB";
|
||||
|
||||
// ── Render ────────────────────────────────────────────────────────────────
|
||||
const formatBytes = (bytes: number) => {
|
||||
if (!Number.isFinite(bytes)) return "—";
|
||||
if (bytes === 0) return "0 B";
|
||||
const k = 1024;
|
||||
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const value = bytes / Math.pow(k, i);
|
||||
return `${value.toFixed(value >= 10 ? 0 : 1)} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (uploadedFile?.previewUrl) {
|
||||
URL.revokeObjectURL(uploadedFile.previewUrl);
|
||||
}
|
||||
};
|
||||
}, [uploadedFile]);
|
||||
|
||||
return (
|
||||
<main
|
||||
className="min-h-screen flex flex-col items-center justify-center px-4 py-12"
|
||||
style={{
|
||||
background: "#282828",
|
||||
paddingTop: "max(3rem, env(safe-area-inset-top))",
|
||||
paddingBottom: "max(3rem, env(safe-area-inset-bottom))",
|
||||
<Box
|
||||
component="main"
|
||||
sx={{
|
||||
minHeight: "100vh",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
px: { xs: 2, md: 4 },
|
||||
py: { xs: 3, md: 6 },
|
||||
backgroundColor: "background.default",
|
||||
fontFamily:
|
||||
"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
||||
}}
|
||||
>
|
||||
<div className="w-full max-w-sm">
|
||||
{/* ── Header ─────────────────────────────────────────────────────── */}
|
||||
<div className="flex flex-col items-center text-center mb-8 gap-3">
|
||||
<div
|
||||
className="w-12 h-12 rounded-[14px] flex items-center justify-center"
|
||||
style={{
|
||||
background: "#3c3836",
|
||||
border: "1px solid #504945",
|
||||
<Box sx={{ width: "100%", maxWidth: 980 }}>
|
||||
<Stack spacing={2.5}>
|
||||
<Stack
|
||||
direction={{ xs: "column", sm: "row" }}
|
||||
alignItems={{ xs: "flex-start", sm: "center" }}
|
||||
justifyContent="space-between"
|
||||
spacing={2}
|
||||
sx={{
|
||||
px: { xs: 1.5, sm: 2 },
|
||||
py: { xs: 1, sm: 1.5 },
|
||||
border: "1px solid",
|
||||
borderColor: "divider",
|
||||
borderRadius: 0,
|
||||
backgroundColor: "background.paper",
|
||||
}}
|
||||
>
|
||||
<Upload
|
||||
className="w-5 h-5"
|
||||
style={{ color: "#d79921" }}
|
||||
strokeWidth={1.75}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h1
|
||||
className="text-[22px] font-semibold tracking-tight leading-snug"
|
||||
style={{ color: "#ebdbb2" }}
|
||||
>
|
||||
filehost
|
||||
</h1>
|
||||
<p className="text-[13px] mt-0.5" style={{ color: "#a89984" }}>
|
||||
<Stack direction="row" spacing={1.5} alignItems="center">
|
||||
<Box
|
||||
sx={{
|
||||
width: 10,
|
||||
height: 10,
|
||||
borderRadius: "50%",
|
||||
backgroundColor: "success.main",
|
||||
boxShadow: "0 0 10px rgba(34, 197, 94, 0.6)",
|
||||
}}
|
||||
/>
|
||||
<Typography variant="body2" sx={{ letterSpacing: "0.08em" }}>
|
||||
filehost
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{limitLabel} max · expires in 24 h
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
{/* ── Card ───────────────────────────────────────────────────────── */}
|
||||
<div
|
||||
className="rounded-2xl overflow-hidden"
|
||||
style={{ background: "#32302f", border: "1px solid #504945" }}
|
||||
>
|
||||
{/* Auth row */}
|
||||
{showAuthRow && (
|
||||
<div
|
||||
className="px-5 pt-5 pb-5"
|
||||
style={{ borderBottom: "1px solid #504945" }}
|
||||
>
|
||||
{showAuthBadge ? (
|
||||
<div className="flex items-center gap-2.5 py-0.5">
|
||||
<div
|
||||
className="w-2 h-2 rounded-full shrink-0"
|
||||
style={{ background: "#b8bb26" }}
|
||||
/>
|
||||
<span
|
||||
className="text-[14px] font-medium"
|
||||
style={{ color: "#b8bb26" }}
|
||||
>
|
||||
Authenticated · 250 MB limit
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
/* status === "idle" — show the optional unlock form */
|
||||
<div className="flex flex-col gap-3">
|
||||
<label
|
||||
className="text-[13px] font-medium"
|
||||
style={{ color: "#a89984" }}
|
||||
>
|
||||
Password{" "}
|
||||
<span style={{ color: "#665c54" }} className="font-normal">
|
||||
— optional, unlocks 250 MB
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => {
|
||||
setPassword(e.target.value);
|
||||
setPasswordError(false);
|
||||
}}
|
||||
onKeyDown={(e) => e.key === "Enter" && handleUnlock()}
|
||||
placeholder="Enter password"
|
||||
className={[
|
||||
"w-full h-11 px-3.5 rounded-xl text-[15px] outline-none",
|
||||
"border transition-all duration-150",
|
||||
passwordError ? "ring-2" : "",
|
||||
].join(" ")}
|
||||
style={{
|
||||
background: "#1d2021",
|
||||
color: "#ebdbb2",
|
||||
caretColor: "#d79921",
|
||||
borderColor: passwordError ? "#fb4934" : "#504945",
|
||||
boxShadow: passwordError
|
||||
? "0 0 0 2px rgba(251,73,52,0.2)"
|
||||
: undefined,
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
if (!passwordError)
|
||||
(e.target as HTMLInputElement).style.borderColor =
|
||||
"#d79921";
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (!passwordError)
|
||||
(e.target as HTMLInputElement).style.borderColor =
|
||||
"#504945";
|
||||
}}
|
||||
/>
|
||||
{passwordError && (
|
||||
<p
|
||||
className="text-[12px] -mt-1"
|
||||
style={{ color: "#fb4934" }}
|
||||
<Box
|
||||
sx={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: { xs: "1fr", md: "1.3fr 0.9fr" },
|
||||
gap: 2,
|
||||
}}
|
||||
>
|
||||
<Card>
|
||||
<Box
|
||||
sx={{
|
||||
px: 2.5,
|
||||
py: 1.25,
|
||||
borderBottom: "1px solid",
|
||||
borderColor: "divider",
|
||||
backgroundColor: "background.default",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ letterSpacing: "0.2em", color: "text.secondary" }}
|
||||
>
|
||||
UPLOAD_BUFFER
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box sx={{ px: { xs: 2, md: 3 }, py: { xs: 2.5, md: 3 } }}>
|
||||
{isUploading ? (
|
||||
<Stack spacing={2}>
|
||||
<Stack direction="row" spacing={2} alignItems="center">
|
||||
<Box
|
||||
sx={{
|
||||
width: 36,
|
||||
height: 36,
|
||||
borderRadius: 2,
|
||||
display: "grid",
|
||||
placeItems: "center",
|
||||
backgroundColor: "action.selected",
|
||||
}}
|
||||
>
|
||||
<CloudUploadIcon fontSize="small" />
|
||||
</Box>
|
||||
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{ fontWeight: 600 }}
|
||||
noWrap
|
||||
>
|
||||
{pendingFileName}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{progress}%
|
||||
</Typography>
|
||||
</Stack>
|
||||
<LinearProgress variant="determinate" value={progress} />
|
||||
</Stack>
|
||||
) : status === "done" && resultUrl ? (
|
||||
<Stack spacing={2}>
|
||||
<Stack direction="row" spacing={1} alignItems="center">
|
||||
<CheckCircleIcon color="success" fontSize="small" />
|
||||
<Typography variant="body2" sx={{ fontWeight: 600 }}>
|
||||
Transfer complete
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Button
|
||||
size="small"
|
||||
color="inherit"
|
||||
startIcon={<ReplayIcon />}
|
||||
onClick={() => {
|
||||
setResultUrl("");
|
||||
setErrorMessage("");
|
||||
setUploadedFile(null);
|
||||
setStatus(isAuthenticated ? "authenticated" : "idle");
|
||||
}}
|
||||
>
|
||||
Incorrect password.
|
||||
</p>
|
||||
)}
|
||||
<button
|
||||
onClick={handleUnlock}
|
||||
className="w-full h-11 rounded-xl text-[15px] font-semibold tracking-tight transition-opacity active:opacity-75 select-none flex items-center justify-center gap-2"
|
||||
style={{ background: "#d79921", color: "#1d2021" }}
|
||||
>
|
||||
<Lock className="w-3.5 h-3.5" strokeWidth={2.5} />
|
||||
Unlock 250 MB
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Upload / progress / result */}
|
||||
<div className="px-5 py-5 flex flex-col gap-4">
|
||||
{isUploading ? (
|
||||
/* ── Uploading ─────────────────────────────────────────────── */
|
||||
<div className="flex flex-col gap-3 py-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className="w-9 h-9 rounded-[10px] flex items-center justify-center shrink-0"
|
||||
style={{ background: "#3c3836" }}
|
||||
>
|
||||
<Upload
|
||||
className="w-4 h-4"
|
||||
style={{ color: "#a89984" }}
|
||||
strokeWidth={1.75}
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
className="text-[14px] font-medium truncate flex-1 min-w-0"
|
||||
style={{ color: "#ebdbb2" }}
|
||||
>
|
||||
{pendingFileName}
|
||||
</p>
|
||||
<span
|
||||
className="text-[13px] tabular-nums shrink-0 ml-2"
|
||||
style={{ color: "#a89984" }}
|
||||
>
|
||||
{progress}%
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="h-[3px] w-full rounded-full overflow-hidden"
|
||||
style={{ background: "#3c3836" }}
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-full transition-all duration-300 ease-out"
|
||||
style={{ width: `${progress}%`, background: "#d79921" }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : status === "done" && resultUrl ? (
|
||||
/* ── Done ─────────────────────────────────────────────────── */
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<CheckCircle2
|
||||
className="w-4 h-4 shrink-0"
|
||||
style={{ color: "#b8bb26" }}
|
||||
strokeWidth={2}
|
||||
/>
|
||||
<span
|
||||
className="text-[14px] font-medium"
|
||||
style={{ color: "#ebdbb2" }}
|
||||
>
|
||||
Upload complete
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<input
|
||||
readOnly
|
||||
value={resultUrl}
|
||||
onClick={(e) => (e.target as HTMLInputElement).select()}
|
||||
className="w-full h-10 px-3 rounded-xl text-[12px] font-mono outline-none cursor-text transition-colors"
|
||||
style={{
|
||||
background: "#1d2021",
|
||||
border: "1px solid #504945",
|
||||
color: "#d5c4a1",
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="flex-1 h-11 rounded-xl text-[14px] font-medium flex items-center justify-center gap-1.5 transition-all active:opacity-70 select-none"
|
||||
style={
|
||||
copied
|
||||
? {
|
||||
background: "rgba(184,187,38,0.12)",
|
||||
color: "#b8bb26",
|
||||
border: "1px solid rgba(184,187,38,0.25)",
|
||||
}
|
||||
: {
|
||||
background: "#3c3836",
|
||||
color: "#ebdbb2",
|
||||
border: "1px solid #504945",
|
||||
}
|
||||
Upload another
|
||||
</Button>
|
||||
</Stack>
|
||||
) : (
|
||||
<Box
|
||||
onDragOver={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
onClick={() =>
|
||||
isInteractable && fileInputRef.current?.click()
|
||||
}
|
||||
sx={{
|
||||
border: "2px dashed",
|
||||
borderColor: isDragging ? "info.main" : "divider",
|
||||
borderRadius: 0,
|
||||
px: { xs: 2.5, md: 4 },
|
||||
py: { xs: 4, md: 6 },
|
||||
textAlign: "center",
|
||||
cursor: isUploading ? "default" : "pointer",
|
||||
backgroundColor: isDragging
|
||||
? "rgba(56, 189, 248, 0.08)"
|
||||
: "transparent",
|
||||
transition: "all 0.15s ease",
|
||||
}}
|
||||
>
|
||||
<Copy className="w-3.5 h-3.5" strokeWidth={2} />
|
||||
{copied ? "Copied" : "Copy"}
|
||||
</button>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
hidden
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
<Stack spacing={1.5} alignItems="center">
|
||||
<Box
|
||||
sx={{
|
||||
width: 44,
|
||||
height: 44,
|
||||
borderRadius: 3,
|
||||
display: "grid",
|
||||
placeItems: "center",
|
||||
backgroundColor: isDragging
|
||||
? "rgba(56, 189, 248, 0.12)"
|
||||
: "action.selected",
|
||||
}}
|
||||
>
|
||||
<CloudUploadIcon
|
||||
fontSize="small"
|
||||
color={isDragging ? "info" : "inherit"}
|
||||
/>
|
||||
</Box>
|
||||
<Typography variant="body2" sx={{ fontWeight: 600 }}>
|
||||
{isDragging
|
||||
? "Drop to upload"
|
||||
: "Drop file or tap to browse"}
|
||||
</Typography>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
Any file type · up to {limitLabel}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Card>
|
||||
|
||||
<a
|
||||
href={resultUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex-1 h-11 rounded-xl text-[14px] font-semibold flex items-center justify-center gap-1.5 transition-opacity active:opacity-80 select-none"
|
||||
style={{ background: "#d79921", color: "#1d2021" }}
|
||||
>
|
||||
<ExternalLink className="w-3.5 h-3.5" strokeWidth={2} />
|
||||
Open
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => {
|
||||
setResultUrl("");
|
||||
setErrorMessage("");
|
||||
setStatus(isAuthenticated ? "authenticated" : "idle");
|
||||
}}
|
||||
className="flex items-center justify-center gap-1.5 text-[13px] transition-colors active:opacity-80 select-none"
|
||||
style={{ color: "#a89984" }}
|
||||
>
|
||||
<RotateCcw className="w-3 h-3" strokeWidth={2} />
|
||||
Upload another
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
/* ── Drop zone ─────────────────────────────────────────────── */
|
||||
<div
|
||||
onDragOver={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
onClick={() => isInteractable && fileInputRef.current?.click()}
|
||||
className="rounded-xl border-2 border-dashed flex flex-col items-center justify-center gap-2.5 py-10 px-4 text-center transition-all duration-150 select-none"
|
||||
style={{
|
||||
borderColor: isDragging ? "#83a598" : "#504945",
|
||||
background: isDragging
|
||||
? "rgba(131,165,152,0.06)"
|
||||
: "transparent",
|
||||
cursor: isUploading ? "default" : "pointer",
|
||||
<Card>
|
||||
<Box
|
||||
sx={{
|
||||
px: 2.5,
|
||||
py: 1.25,
|
||||
borderBottom: "1px solid",
|
||||
borderColor: "divider",
|
||||
backgroundColor: "background.default",
|
||||
}}
|
||||
>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
className="hidden"
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
<div
|
||||
className="w-10 h-10 rounded-[12px] flex items-center justify-center transition-colors"
|
||||
style={{
|
||||
background: isDragging
|
||||
? "rgba(131,165,152,0.12)"
|
||||
: "#3c3836",
|
||||
}}
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ letterSpacing: "0.2em", color: "text.secondary" }}
|
||||
>
|
||||
<Upload
|
||||
className="w-4.5 h-4.5 transition-colors"
|
||||
style={{ color: isDragging ? "#83a598" : "#7c6f64" }}
|
||||
strokeWidth={1.75}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
className="text-[14px] font-medium transition-colors"
|
||||
style={{ color: isDragging ? "#83a598" : "#ebdbb2" }}
|
||||
SESSION
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box sx={{ px: { xs: 2, md: 3 }, py: { xs: 2.5, md: 3 } }}>
|
||||
{showAuthRow && (
|
||||
<Stack spacing={2} sx={{ mb: 2.5 }}>
|
||||
{showAuthBadge ? (
|
||||
<Stack direction="row" spacing={1} alignItems="center">
|
||||
<Chip
|
||||
label="Authenticated · 250 MB limit"
|
||||
color="success"
|
||||
variant="outlined"
|
||||
sx={{
|
||||
color: "success.main",
|
||||
borderColor: "rgba(34, 197, 94, 0.5)",
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
) : (
|
||||
<Stack spacing={2}>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
Password{" "}
|
||||
<Typography
|
||||
component="span"
|
||||
variant="body2"
|
||||
color="text.disabled"
|
||||
>
|
||||
— optional, unlocks 250 MB
|
||||
</Typography>
|
||||
</Typography>
|
||||
<TextField
|
||||
type="password"
|
||||
placeholder="Enter password"
|
||||
value={password}
|
||||
error={passwordError}
|
||||
helperText={
|
||||
passwordError ? "Incorrect password." : " "
|
||||
}
|
||||
onChange={(e) => {
|
||||
setPassword(e.target.value);
|
||||
setPasswordError(false);
|
||||
}}
|
||||
onKeyDown={(e) => e.key === "Enter" && handleUnlock()}
|
||||
fullWidth
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<LockIcon />}
|
||||
onClick={handleUnlock}
|
||||
>
|
||||
Unlock 250 MB
|
||||
</Button>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{uploadedFile?.previewUrl && (
|
||||
<Box
|
||||
sx={{
|
||||
borderRadius: 3,
|
||||
overflow: "hidden",
|
||||
border: "1px solid",
|
||||
borderColor: "divider",
|
||||
backgroundColor: "background.default",
|
||||
mb: 2,
|
||||
}}
|
||||
>
|
||||
{isDragging
|
||||
? "Drop to upload"
|
||||
: "Drop file or tap to browse"}
|
||||
</p>
|
||||
<p className="text-[12px] mt-1" style={{ color: "#7c6f64" }}>
|
||||
Any file type · up to {limitLabel}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{uploadedFile.type.startsWith("image/") ? (
|
||||
<Box
|
||||
component="img"
|
||||
src={uploadedFile.previewUrl}
|
||||
alt={uploadedFile.name}
|
||||
sx={{ display: "block", width: "100%", height: "auto" }}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
component="video"
|
||||
src={uploadedFile.previewUrl}
|
||||
controls
|
||||
sx={{ display: "block", width: "100%" }}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* ── Error ────────────────────────────────────────────────── */}
|
||||
{errorMessage && (
|
||||
<div
|
||||
className="flex items-start gap-2.5 px-3.5 py-3 rounded-xl"
|
||||
style={{
|
||||
background: "rgba(251,73,52,0.08)",
|
||||
border: "1px solid rgba(251,73,52,0.2)",
|
||||
}}
|
||||
>
|
||||
<AlertCircle
|
||||
className="w-4 h-4 shrink-0 mt-px"
|
||||
style={{ color: "#fb4934" }}
|
||||
strokeWidth={2}
|
||||
/>
|
||||
<p
|
||||
className="text-[13px] break-all leading-relaxed"
|
||||
style={{ color: "#fb4934" }}
|
||||
>
|
||||
{errorMessage}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{uploadedFile && (
|
||||
<Stack
|
||||
spacing={0.5}
|
||||
sx={{
|
||||
px: 2,
|
||||
py: 1.5,
|
||||
borderRadius: 2,
|
||||
border: "1px solid",
|
||||
borderColor: "divider",
|
||||
backgroundColor: "background.default",
|
||||
mb: 2,
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ fontWeight: 600 }} noWrap>
|
||||
{uploadedFile.name}
|
||||
</Typography>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={2}
|
||||
sx={{ color: "text.secondary" }}
|
||||
>
|
||||
<Typography variant="caption">
|
||||
{formatBytes(uploadedFile.size)}
|
||||
</Typography>
|
||||
<Typography variant="caption">
|
||||
{uploadedFile.type}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{/* ── Footer ─────────────────────────────────────────────────────── */}
|
||||
<p
|
||||
className="text-center text-[12px] mt-6"
|
||||
style={{ color: "#665c54" }}
|
||||
>
|
||||
Files are automatically deleted after 24 hours
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
{resultUrl && (
|
||||
<Stack spacing={2}>
|
||||
<TextField
|
||||
value={resultUrl}
|
||||
fullWidth
|
||||
onClick={(e) => (e.target as HTMLInputElement).select()}
|
||||
InputProps={{ readOnly: true }}
|
||||
/>
|
||||
<Stack direction={{ xs: "column", sm: "row" }} spacing={1}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<ContentCopyIcon />}
|
||||
onClick={handleCopy}
|
||||
color={copied ? "success" : "inherit"}
|
||||
fullWidth
|
||||
>
|
||||
{copied ? "Copied" : "Copy"}
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
endIcon={<OpenInNewIcon />}
|
||||
href={resultUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
fullWidth
|
||||
>
|
||||
Open
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{errorMessage && (
|
||||
<Alert
|
||||
severity="error"
|
||||
icon={<ErrorOutlineIcon />}
|
||||
sx={{ mt: 2 }}
|
||||
>
|
||||
{errorMessage}
|
||||
</Alert>
|
||||
)}
|
||||
</Box>
|
||||
</Card>
|
||||
</Box>
|
||||
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="text.secondary"
|
||||
sx={{ textAlign: "center" }}
|
||||
>
|
||||
Files are automatically deleted after 24 hours
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter";
|
||||
import CssBaseline from "@mui/material/CssBaseline";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import theme from "./theme";
|
||||
|
||||
type Props = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export default function Providers({ children }: Props) {
|
||||
return (
|
||||
<AppRouterCacheProvider options={{ enableCssLayer: true }}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<CssBaseline />
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</AppRouterCacheProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
|
||||
const gruvbox = {
|
||||
background: "#0b0e0b",
|
||||
surface: "#0f1410",
|
||||
surfaceAlt: "#121a13",
|
||||
border: "#1f2a22",
|
||||
textPrimary: "#d1fae5",
|
||||
textSecondary: "#86efac",
|
||||
textMuted: "#4ade80",
|
||||
primary: "#22c55e",
|
||||
success: "#22c55e",
|
||||
info: "#22d3ee",
|
||||
error: "#f87171",
|
||||
};
|
||||
|
||||
const theme = createTheme({
|
||||
palette: {
|
||||
mode: "dark",
|
||||
background: {
|
||||
default: gruvbox.background,
|
||||
paper: gruvbox.surface,
|
||||
},
|
||||
primary: {
|
||||
main: gruvbox.primary,
|
||||
contrastText: "#0b0f19",
|
||||
},
|
||||
success: {
|
||||
main: gruvbox.success,
|
||||
},
|
||||
info: {
|
||||
main: gruvbox.info,
|
||||
},
|
||||
error: {
|
||||
main: gruvbox.error,
|
||||
},
|
||||
text: {
|
||||
primary: gruvbox.textPrimary,
|
||||
secondary: gruvbox.textSecondary,
|
||||
disabled: gruvbox.textMuted,
|
||||
},
|
||||
divider: gruvbox.border,
|
||||
},
|
||||
typography: {
|
||||
fontFamily:
|
||||
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
||||
h1: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
h2: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
h3: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
h4: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
h5: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
h6: {
|
||||
fontWeight: 600,
|
||||
letterSpacing: "-0.01em",
|
||||
},
|
||||
button: {
|
||||
textTransform: "none",
|
||||
fontWeight: 600,
|
||||
},
|
||||
},
|
||||
shape: {
|
||||
borderRadius: 0,
|
||||
},
|
||||
components: {
|
||||
MuiCssBaseline: {
|
||||
styleOverrides: {
|
||||
body: {
|
||||
backgroundColor: gruvbox.background,
|
||||
color: gruvbox.textPrimary,
|
||||
WebkitFontSmoothing: "antialiased",
|
||||
MozOsxFontSmoothing: "grayscale",
|
||||
},
|
||||
"*": {
|
||||
boxSizing: "border-box",
|
||||
},
|
||||
"::selection": {
|
||||
background: "rgba(34, 197, 94, 0.3)",
|
||||
color: gruvbox.textPrimary,
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
width: "6px",
|
||||
},
|
||||
"::-webkit-scrollbar-track": {
|
||||
background: "#0a0d0a",
|
||||
},
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
background: gruvbox.border,
|
||||
borderRadius: "3px",
|
||||
},
|
||||
"::-webkit-scrollbar-thumb:hover": {
|
||||
background: "#2f3b32",
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiCard: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
backgroundColor: gruvbox.surface,
|
||||
border: `1px solid ${gruvbox.border}`,
|
||||
borderRadius: 0,
|
||||
boxShadow: "0 0 0 1px rgba(34, 197, 94, 0.08)",
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiTextField: {
|
||||
defaultProps: {
|
||||
size: "small",
|
||||
},
|
||||
},
|
||||
MuiOutlinedInput: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
backgroundColor: "#0b0e0b",
|
||||
"& .MuiOutlinedInput-notchedOutline": {
|
||||
borderColor: gruvbox.border,
|
||||
},
|
||||
"&:hover .MuiOutlinedInput-notchedOutline": {
|
||||
borderColor: gruvbox.primary,
|
||||
},
|
||||
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
||||
borderColor: gruvbox.primary,
|
||||
boxShadow: "0 0 0 2px rgba(34, 197, 94, 0.25)",
|
||||
},
|
||||
},
|
||||
input: {
|
||||
color: gruvbox.textPrimary,
|
||||
caretColor: gruvbox.primary,
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiInputLabel: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
color: gruvbox.textSecondary,
|
||||
"&.Mui-focused": {
|
||||
color: gruvbox.primary,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiButton: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
borderRadius: 0,
|
||||
},
|
||||
containedPrimary: {
|
||||
color: "#0b0e0b",
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiLinearProgress: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
height: 6,
|
||||
borderRadius: 999,
|
||||
backgroundColor: gruvbox.surfaceAlt,
|
||||
},
|
||||
bar: {
|
||||
borderRadius: 999,
|
||||
backgroundColor: gruvbox.primary,
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiAlert: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
borderRadius: 0,
|
||||
},
|
||||
standardError: {
|
||||
backgroundColor: "rgba(248, 113, 113, 0.12)",
|
||||
border: "1px solid rgba(248, 113, 113, 0.35)",
|
||||
color: gruvbox.error,
|
||||
},
|
||||
icon: {
|
||||
color: gruvbox.error,
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiDivider: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
borderColor: gruvbox.border,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type ThemeType = typeof theme;
|
||||
|
||||
export default theme;
|
||||
@@ -1,21 +0,0 @@
|
||||
import type { Config } from "tailwindcss";
|
||||
|
||||
const config: Config = {
|
||||
content: [
|
||||
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
slate: {
|
||||
950: "#0f172a",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
|
||||
export default config;
|
||||
Reference in new issue
Block a user