Unverified Commit 34913cfc authored by Athurg Gooth's avatar Athurg Gooth Committed by GitHub

feat: show thumbnail in resource dashboard (#1666)

* Add image thumbnail instead of an icon

* Change thumbnail size of dashboard to fixed

* Fix for eslint-checks

* Fix for eslint-checks

* Replace css with tailwind

* Remove the parent div used for style

* Show preview while click on the resource

* Change for review Suggested by @Zeng1998

---------
Co-authored-by: 's avatarAthurg Feng <athurg@gooth.org>
parent 88799d46
import React from "react"; import React from "react";
import Icon from "./Icon"; import Icon from "./Icon";
import { getResourceUrl } from "@/utils/resource";
import showPreviewImageDialog from "./PreviewImageDialog";
import "@/less/resource-cover.less"; import "@/less/resource-cover.less";
interface ResourceCoverProps { interface ResourceCoverProps {
...@@ -34,9 +36,12 @@ const getResourceType = (resource: Resource) => { ...@@ -34,9 +36,12 @@ const getResourceType = (resource: Resource) => {
const ResourceCover = ({ resource }: ResourceCoverProps) => { const ResourceCover = ({ resource }: ResourceCoverProps) => {
const resourceType = getResourceType(resource); const resourceType = getResourceType(resource);
const resourceUrl = getResourceUrl(resource);
switch (resourceType) { switch (resourceType) {
case "image/*": case "image/*":
return <Icon.FileImage className="resource-cover" />; return (
<img className="resource-cover h-20 w-20" src={resourceUrl + "?thumbnail=1"} onClick={() => showPreviewImageDialog(resourceUrl)} />
);
case "video/*": case "video/*":
return <Icon.FileVideo2 className="resource-cover" />; return <Icon.FileVideo2 className="resource-cover" />;
case "audio/*": case "audio/*":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment