From 9ad2eaebc52b37811458bb4b605903888b2be4c4 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 23 Jun 2023 20:24:40 +0800 Subject: [PATCH] chore: update shortcut list style --- web/src/components/CreateShortcutDialog.tsx | 19 +++--- web/src/components/ShortcutListView.tsx | 70 +++++++-------------- web/src/components/common/Dropdown.tsx | 4 +- 3 files changed, 35 insertions(+), 58 deletions(-) diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsx index dcfdffd..1bfee97 100644 --- a/web/src/components/CreateShortcutDialog.tsx +++ b/web/src/components/CreateShortcutDialog.tsx @@ -127,13 +127,16 @@ const CreateShortcutDialog: React.FC = (props: Props) => { Name * - +
+ o/ + +
@@ -159,7 +162,7 @@ const CreateShortcutDialog: React.FC = (props: Props) => {
Tags - +
diff --git a/web/src/components/ShortcutListView.tsx b/web/src/components/ShortcutListView.tsx index b68024e..32d4c36 100644 --- a/web/src/components/ShortcutListView.tsx +++ b/web/src/components/ShortcutListView.tsx @@ -2,7 +2,6 @@ import { Tooltip } from "@mui/joy"; import copy from "copy-to-clipboard"; import { useState } from "react"; import { toast } from "react-hot-toast"; -import { UNKNOWN_ID } from "../helpers/consts"; import { shortcutService } from "../services"; import { useAppSelector } from "../stores"; import { absolutifyLink } from "../helpers/utils"; @@ -15,16 +14,10 @@ interface Props { shortcutList: Shortcut[]; } -interface State { - currentEditingShortcutId: ShortcutId; -} - const ShortcutListView: React.FC = (props: Props) => { const { shortcutList } = props; const user = useAppSelector((state) => state.user.user as User); - const [state, setState] = useState({ - currentEditingShortcutId: UNKNOWN_ID, - }); + const [editingShortcutId, setEditingShortcutId] = useState(); const havePermission = (shortcut: Shortcut) => { return user.role === "ADMIN" || shortcut.creatorId === user.id; @@ -35,13 +28,6 @@ const ShortcutListView: React.FC = (props: Props) => { toast.success("Shortcut link copied to clipboard."); }; - const handleEditShortcutButtonClick = (shortcut: Shortcut) => { - setState({ - ...state, - currentEditingShortcutId: shortcut.id, - }); - }; - const handleDeleteShortcutButtonClick = (shortcut: Shortcut) => { showCommonDialog({ title: "Delete Shortcut", @@ -61,49 +47,48 @@ const ShortcutListView: React.FC = (props: Props) => {

- {shortcut.name} - {shortcut.description && ({shortcut.description})} + handleCopyButtonClick(shortcut)}> + o/ + {shortcut.name} +

-
+ {shortcut.description &&

{shortcut.description}

} +
+ {shortcut.tags.map((tag) => { return ( - + #{tag} ); })}
-
- {shortcut.creator.nickname} +
- - - + + } - actionsClassName="!w-24" >
@@ -120,21 +104,11 @@ const ShortcutListView: React.FC = (props: Props) => { })}
- {state.currentEditingShortcutId !== UNKNOWN_ID && ( + {editingShortcutId && ( { - setState({ - ...state, - currentEditingShortcutId: UNKNOWN_ID, - }); - }} - onConfirm={() => { - setState({ - ...state, - currentEditingShortcutId: UNKNOWN_ID, - }); - }} + shortcutId={editingShortcutId} + onClose={() => setEditingShortcutId(undefined)} + onConfirm={() => setEditingShortcutId(undefined)} /> )} diff --git a/web/src/components/common/Dropdown.tsx b/web/src/components/common/Dropdown.tsx index 0a9ba3f..8662e95 100644 --- a/web/src/components/common/Dropdown.tsx +++ b/web/src/components/common/Dropdown.tsx @@ -37,8 +37,8 @@ const Dropdown: React.FC = (props: Props) => { {trigger ? ( trigger ) : ( - )}