Files
msw-open-music/web/src/component/FileEntry.jsx
heimoshuiyu aa2377df7f Replace webpack with only esbuild, replace react with preact
reduce node_modules size to only 18M

reduce js file bundle to 20%
2022-12-17 21:12:41 +08:00

47 lines
1.1 KiB
JavaScript

import * as React from 'react';
import { useState } from "react";
import { useNavigate } from "react-router";
import { CalcReadableFilesize } from "./Common";
import FileDialog from "./FileDialog";
function FileEntry(props) {
const [showStatus, setShowStatus] = useState(false);
let navigate = useNavigate();
return (
<tr>
<td
className="clickable"
onClick={() => {
// double click to play file and close dialog
if (showStatus) {
props.setPlayingFile(props.file);
setShowStatus(false);
return;
}
setShowStatus(true);
}}
>
{props.file.filename}
</td>
<td
className="clickable"
onClick={() => navigate(`/folders/${props.file.folder_id}`)}
>
{props.file.foldername}
</td>
<td>
{CalcReadableFilesize(props.file.filesize)}
<FileDialog
setPlayingFile={props.setPlayingFile}
showStatus={showStatus}
setShowStatus={setShowStatus}
file={props.file}
/>
</td>
</tr>
);
}
export default FileEntry;