import clsx from 'clsx'; import { HTMLAttributes } from 'react'; import { ExplorerItem } from '@sd/client'; import FileThumb from './FileThumb'; interface Props extends HTMLAttributes { data: ExplorerItem; index: number; selected: boolean; } function FileRow({ data, index, selected, ...props }: Props) { return (
{columns.map((col) => (
))}
); } const RenderCell: React.FC<{ colKey: ColumnKey; data: ExplorerItem; }> = ({ colKey, data }) => { switch (colKey) { case 'name': return (
{/* {colKey == 'name' && (() => { switch (row.extension.toLowerCase()) { case 'mov' || 'mp4': return ; default: if (row.is_dir) return ; return ; } })()} */} {data[colKey]}
); // case 'size_in_bytes': // return {byteSize(Number(value || 0))}; case 'extension': return {data[colKey]}; // case 'meta_integrity_hash': // return {value}; // case 'tags': // return renderCellWithIcon(MusicNoteIcon); default: return <>; } }; interface IColumn { column: string; key: string; width: number; } // Function ensure no types are lost, but guarantees that they are Column[] function ensureIsColumns(data: T) { return data; } const columns = ensureIsColumns([ { column: 'Name', key: 'name', width: 280 } as const, // { column: 'Size', key: 'size_in_bytes', width: 120 } as const, { column: 'Type', key: 'extension', width: 100 } as const ]); type ColumnKey = (typeof columns)[number]['key']; export default FileRow;