Files hub frontend

This commit is contained in:
2026-10-29 17:50:21 -03:00
parent 8272636310
commit ec9bdb8e8e
9 changed files with 364 additions and 9 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { ComponentChildren } from "preact";
import { FileIcon } from "@/components/Icons.tsx";
import { format_bytes } from "@/src/files.ts";
interface FileInfoProps {
name: string;
size: number;
detail?: string;
action?: ComponentChildren;
}
export default function FileInfo(props: FileInfoProps) {
return (
<div class="flex w-full flex-row items-center gap-4">
<FileIcon class="h-8 w-7 flex-none text-white dark:text-gray-900" />
<div class="min-w-0 flex-1">
<p class="font-medium break-all">{props.name}</p>
<p class="pt-1 text-sm opacity-75">
{format_bytes(props.size)}
{props.detail && ` · ${props.detail}`}
</p>
</div>
{props.action}
</div>
);
}
+48
View File
@@ -0,0 +1,48 @@
// SVG icons from Mozilla Send (__vces/send/assets), colored with currentColor
interface IconProps {
class?: string;
}
export function PlusIcon(props: IconProps) {
return (
<svg class={props.class} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path d="M12 22.667c5.891 0 10.667-4.776 10.667-10.667S17.89 1.333 12 1.333 1.333 6.11 1.333 12 6.11 22.667 12 22.667M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12" />
<path d="M11.143 6v5.143H6v1.714h5.143V18h1.714v-5.143H18v-1.714h-5.143V6z" />
</svg>
);
}
// The page is drawn in primary-400, the lines in currentColor so they can match the background
export function FileIcon(props: IconProps) {
return (
<svg class={props.class} viewBox="0 0 26 32" fill="none" aria-hidden="true">
<path
class="fill-primary-400"
d="M21.848 31.665H2.89c-1.563 0-2.786-1.29-2.786-2.786V2.786C.104 1.223 1.395 0 2.89 0h11.824c.747 0 1.495.272 1.97.815l7.135 7.135c.544.544.816 1.224.816 1.97v18.959c0 1.495-1.223 2.786-2.786 2.786"
/>
<path
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
d="M24.303 10.647h-7.52a2.73 2.73 0 0 1-2.731-2.73V.395M7.283 8.939h1.636M7.283 15.78h10.258M7.283 22.62h10.258"
/>
</svg>
);
}
export function CloseIcon(props: IconProps) {
return (
<svg class={props.class} viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
<path d="M9.414 8l5.293-5.293a1 1 0 0 0-1.414-1.414L8 6.586 2.707 1.293a1 1 0 0 0-1.414 1.414L6.586 8l-5.293 5.293a1 1 0 1 0 1.414 1.414L8 9.414l5.293 5.293a1 1 0 0 0 1.414-1.414z" />
</svg>
);
}
export function DownloadIcon(props: IconProps) {
return (
<svg class={props.class} viewBox="0 0 12 16" fill="currentColor" aria-hidden="true">
<path d="M5.293 12.707a1 1 0 0 0 1.414 0l5-5a1 1 0 0 0-1.414-1.414L7 9.586V1a1 1 0 0 0-2 0v8.586L1.707 6.293A1 1 0 0 0 .293 7.707zM11 14H1a1 1 0 0 0 0 2h10a1 1 0 0 0 0-2" />
</svg>
);
}