From c189654cd976b9ea5e5a27d95577b0b2eba6cc88 Mon Sep 17 00:00:00 2001 From: boojack Date: Wed, 15 Mar 2023 23:29:43 +0800 Subject: [PATCH] chore: update resource dashboard style (#1362) --- web/src/components/ResourceCard.tsx | 17 +++--- web/src/components/ResourceCover.tsx | 25 ++++++++- web/src/components/ResourceSearchBar.tsx | 2 +- web/src/less/resource-card.less | 20 +++---- web/src/less/resource-cover.less | 6 +- web/src/pages/ResourcesDashboard.tsx | 71 ++++++++++++------------ 6 files changed, 80 insertions(+), 61 deletions(-) diff --git a/web/src/components/ResourceCard.tsx b/web/src/components/ResourceCard.tsx index 1ee9a86f..7b8fd7c9 100644 --- a/web/src/components/ResourceCard.tsx +++ b/web/src/components/ResourceCard.tsx @@ -75,18 +75,15 @@ const ResourceCard = ({ resource, handlecheckClick, handleUncheckClick }: Resour return (
-
+
handleSelectBtnClick()}> - {isSelected ? ( - - ) : ( - - )} + {isSelected ? : }
} actions={ <>
-
+
-
-
{resource.filename}
-
{dayjs(resource.createdTs).locale("en").format("YYYY/MM/DD HH:mm:ss")}
+
+
{resource.filename}
+
{dayjs(resource.createdTs).locale("en").format("YYYY/MM/DD HH:mm:ss")}
); diff --git a/web/src/components/ResourceCover.tsx b/web/src/components/ResourceCover.tsx index a70cb9ef..8a69666f 100644 --- a/web/src/components/ResourceCover.tsx +++ b/web/src/components/ResourceCover.tsx @@ -6,8 +6,31 @@ interface ResourceCoverProps { resource: Resource; } +const getResourceType = (resource: Resource) => { + if (resource.type.startsWith("image")) { + return "image/*"; + } else if (resource.type.startsWith("video")) { + return "video/*"; + } else if (resource.type.startsWith("audio")) { + return "audio/*"; + } else if (resource.type.startsWith("text")) { + return "text/*"; + } else if (resource.type.startsWith("application/epub+zip")) { + return "application/epub+zip"; + } else if (resource.type.startsWith("application/pdf")) { + return "application/pdf"; + } else if (resource.type.startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) { + return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + } else if (resource.type.startsWith("application/msword")) { + return "application/msword"; + } else { + return "application/octet-stream"; + } +}; + const ResourceCover = ({ resource }: ResourceCoverProps) => { - switch (resource.type) { + const resourceType = getResourceType(resource); + switch (resourceType) { case "image/*": return ; case "video/*": diff --git a/web/src/components/ResourceSearchBar.tsx b/web/src/components/ResourceSearchBar.tsx index 6a364f4d..1985d4d9 100644 --- a/web/src/components/ResourceSearchBar.tsx +++ b/web/src/components/ResourceSearchBar.tsx @@ -23,7 +23,7 @@ const ResourceSearchBar = ({ setQuery }: ResourceSearchBarProps) => { ); return ( -
+
{ }; return ( -
+
-

+

{t("common.resources")}

-
-
-
-
- {isVisiable && ( - - )} -
- -
- + )} + + + -
- - - - - } - /> -
+ } + actions={ + <> + + + } + /> +
+
{loadingState.isLoading ? ( -
+

{t("resources.fetching-data")}

) : ( -
+
{resources.length === 0 ? (

{t("resources.no-resources")}

) : (