Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import clsx from "clsx";
|
||||
import { Fragment } from "react";
|
||||
import { MediaDto } from "~/application/dtos/entities/MediaDto";
|
||||
import DownloadIcon from "~/components/ui/icons/DownloadIcon";
|
||||
|
||||
export default function RowMediaCell({ media, layout = "table" }: { media: MediaDto[] | undefined; layout?: string }) {
|
||||
const onDownload = (media: MediaDto) => {
|
||||
const downloadLink = document.createElement("a");
|
||||
downloadLink.href = media.publicUrl ?? media.file;
|
||||
downloadLink.download = media.name;
|
||||
downloadLink.click();
|
||||
};
|
||||
function getFileName(name: string) {
|
||||
let fileName = name;
|
||||
if (name.includes("/")) {
|
||||
fileName = name.split("/").pop() ?? name;
|
||||
}
|
||||
if (name.includes("\\")) {
|
||||
fileName = name.split("\\").pop() ?? name;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
return (
|
||||
<Fragment>
|
||||
<div className={clsx(layout === "table" ? "flex max-h-12 items-center space-x-2 overflow-x-visible truncate" : "grid max-h-60 gap-1 overflow-auto")}>
|
||||
{media
|
||||
?.filter((f) => f.type.includes("image"))
|
||||
.map((item) => {
|
||||
return <img key={item.name} className={clsx("object-cover", layout === "table" ? "h-10" : "")} src={item.publicUrl ?? item.file} alt={item.name} />;
|
||||
})}
|
||||
|
||||
{media
|
||||
?.filter((f) => !f.type.includes("image"))
|
||||
.map((item, idx) => {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
key={idx}
|
||||
onClick={() => onDownload(item)}
|
||||
className={
|
||||
"hover:border-border text-muted-foreground hover:text-foreground flex items-center space-x-1 border-b border-transparent text-xs hover:border-dashed"
|
||||
}
|
||||
>
|
||||
<div className="font-normal">{getFileName(item.title)}</div>
|
||||
<DownloadIcon className="h-3 w-3" />
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user