Skip to content

Instantly share code, notes, and snippets.

@sergeyt
Created August 5, 2021 18:27
Show Gist options
  • Save sergeyt/1a24bf1206b75bd8dbcfe10c424a9baa to your computer and use it in GitHub Desktop.
Save sergeyt/1a24bf1206b75bd8dbcfe10c424a9baa to your computer and use it in GitHub Desktop.
multidisk item list
import isEmpty from "lodash/isEmpty";
import List from "@material-ui/core/List";
import { Item, File } from "../types";
import FileItem from "./FileItem";
import FolderItem from "./FolderItem";
import Placeholder from "./Placeholder";
export default function ItemList({ data }: { data: Item[] }) {
if (isEmpty(data)) {
return (
<Placeholder>
This drive is empty, but you can fill it out with something :)
</Placeholder>
);
}
const items = data.map((item, k) => {
switch (item.type) {
case "file":
return <FileItem key={k} item={item as File} />;
case "folder":
return <FolderItem key={k} item={item as Item} />;
default:
return null;
}
});
return <List>{items}</List>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment