app/components/media/format.ts
10 lines and 2 functions in DrDustinEdwards/carrel, at commit d5d5e82 on 2026-10-24. This file on GitHub.
Functions
Imports
It imports no other module of this repo. Imported by app/components/media/detail-panel.tsx, app/components/media/results.tsx, app/routes/media.tsx.
Source
// Sizes and dimensions as the media library says them, and the shape of a place that uses a file.
export type MediaUse = { type: string; id: string; title: string; detail: string };
export function size(bytes: number): string {
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`;
return `${bytes} bytes`;
}
export function dims(width: number | null, height: number | null): string {
return width && height ? `${width} by ${height}` : "not measured";
}