mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
chore: update shortcut list style
This commit is contained in:
parent
b3640699e0
commit
9ad2eaebc5
@ -127,13 +127,16 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
<span className="mb-2">
|
<span className="mb-2">
|
||||||
Name <span className="text-red-600">*</span>
|
Name <span className="text-red-600">*</span>
|
||||||
</span>
|
</span>
|
||||||
<Input
|
<div className="relative w-full">
|
||||||
className="w-full"
|
<span className="absolute z-1 top-2 left-3 text-gray-400">o/</span>
|
||||||
type="text"
|
<Input
|
||||||
placeholder="shortcut-name"
|
className="w-full !pl-7"
|
||||||
value={state.shortcutCreate.name}
|
type="text"
|
||||||
onChange={handleNameInputChange}
|
placeholder="shortcut-name"
|
||||||
/>
|
value={state.shortcutCreate.name}
|
||||||
|
onChange={handleNameInputChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-col justify-start items-start mb-3">
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
<span className="mb-2">
|
<span className="mb-2">
|
||||||
@ -159,7 +162,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-col justify-start items-start mb-3">
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
<span className="mb-2">Tags</span>
|
<span className="mb-2">Tags</span>
|
||||||
<Input className="w-full" type="text" placeholder="Tags" value={tag} onChange={handleTagsInputChange} />
|
<Input className="w-full" type="text" placeholder="Separated by spaces" value={tag} onChange={handleTagsInputChange} />
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-col justify-start items-start mb-3">
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
<span className="mb-2">
|
<span className="mb-2">
|
||||||
|
@ -2,7 +2,6 @@ import { Tooltip } from "@mui/joy";
|
|||||||
import copy from "copy-to-clipboard";
|
import copy from "copy-to-clipboard";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { UNKNOWN_ID } from "../helpers/consts";
|
|
||||||
import { shortcutService } from "../services";
|
import { shortcutService } from "../services";
|
||||||
import { useAppSelector } from "../stores";
|
import { useAppSelector } from "../stores";
|
||||||
import { absolutifyLink } from "../helpers/utils";
|
import { absolutifyLink } from "../helpers/utils";
|
||||||
@ -15,16 +14,10 @@ interface Props {
|
|||||||
shortcutList: Shortcut[];
|
shortcutList: Shortcut[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
|
||||||
currentEditingShortcutId: ShortcutId;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ShortcutListView: React.FC<Props> = (props: Props) => {
|
const ShortcutListView: React.FC<Props> = (props: Props) => {
|
||||||
const { shortcutList } = props;
|
const { shortcutList } = props;
|
||||||
const user = useAppSelector((state) => state.user.user as User);
|
const user = useAppSelector((state) => state.user.user as User);
|
||||||
const [state, setState] = useState<State>({
|
const [editingShortcutId, setEditingShortcutId] = useState<ShortcutId | undefined>();
|
||||||
currentEditingShortcutId: UNKNOWN_ID,
|
|
||||||
});
|
|
||||||
|
|
||||||
const havePermission = (shortcut: Shortcut) => {
|
const havePermission = (shortcut: Shortcut) => {
|
||||||
return user.role === "ADMIN" || shortcut.creatorId === user.id;
|
return user.role === "ADMIN" || shortcut.creatorId === user.id;
|
||||||
@ -35,13 +28,6 @@ const ShortcutListView: React.FC<Props> = (props: Props) => {
|
|||||||
toast.success("Shortcut link copied to clipboard.");
|
toast.success("Shortcut link copied to clipboard.");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditShortcutButtonClick = (shortcut: Shortcut) => {
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
currentEditingShortcutId: shortcut.id,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteShortcutButtonClick = (shortcut: Shortcut) => {
|
const handleDeleteShortcutButtonClick = (shortcut: Shortcut) => {
|
||||||
showCommonDialog({
|
showCommonDialog({
|
||||||
title: "Delete Shortcut",
|
title: "Delete Shortcut",
|
||||||
@ -61,49 +47,48 @@ const ShortcutListView: React.FC<Props> = (props: Props) => {
|
|||||||
<div key={shortcut.id} className="w-full flex flex-row justify-between items-start border px-4 py-3 mb-2 rounded-lg">
|
<div key={shortcut.id} className="w-full flex flex-row justify-between items-start border px-4 py-3 mb-2 rounded-lg">
|
||||||
<div className="flex flex-col justify-start items-start mr-4">
|
<div className="flex flex-col justify-start items-start mr-4">
|
||||||
<p>
|
<p>
|
||||||
<span>{shortcut.name}</span>
|
<span className="cursor-pointer hover:opacity-80" onClick={() => handleCopyButtonClick(shortcut)}>
|
||||||
{shortcut.description && <span className="text-gray-500 ml-1">({shortcut.description})</span>}
|
<span className="text-gray-400">o/</span>
|
||||||
|
{shortcut.name}
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<div className="space-x-2">
|
{shortcut.description && <p className="mt-1 text-gray-400 text-sm">{shortcut.description}</p>}
|
||||||
|
<div className="mt-2 flex flex-row justify-start items-start gap-2">
|
||||||
|
<Icon.Tag className="text-gray-400 w-4 h-auto" />
|
||||||
{shortcut.tags.map((tag) => {
|
{shortcut.tags.map((tag) => {
|
||||||
return (
|
return (
|
||||||
<span key={tag} className="text-gray-400 text-sm font-mono">
|
<span key={tag} className="text-gray-400 text-sm font-mono leading-4">
|
||||||
#{tag}
|
#{tag}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row justify-end items-center">
|
<div className="flex flex-row justify-end items-center space-x-2">
|
||||||
<span className="w-16 truncate mr-2 text-gray-600">{shortcut.creator.nickname}</span>
|
|
||||||
<Tooltip title="Copy link" variant="solid" placement="top">
|
<Tooltip title="Copy link" variant="solid" placement="top">
|
||||||
<button
|
<button className="cursor-pointer hover:opacity-80" onClick={() => handleCopyButtonClick(shortcut)}>
|
||||||
className="cursor-pointer mr-4 hover:opacity-80"
|
<Icon.Copy className="w-4 h-auto" />
|
||||||
onClick={() => {
|
|
||||||
handleCopyButtonClick(shortcut);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon.Copy className="w-5 h-auto" />
|
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title="Go to link" variant="solid" placement="top">
|
<Tooltip title="Go to link" variant="solid" placement="top">
|
||||||
<a className="cursor-pointer mr-4 hover:opacity-80" target="_blank" href={shortcut.link}>
|
<a className="cursor-pointer hover:opacity-80" target="_blank" href={shortcut.link}>
|
||||||
<Icon.ExternalLink className="w-5 h-auto" />
|
<Icon.ExternalLink className="w-4 h-auto" />
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
actionsClassName="!w-20"
|
||||||
actions={
|
actions={
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
disabled={!havePermission(shortcut)}
|
disabled={!havePermission(shortcut)}
|
||||||
className="w-full px-3 text-left leading-10 cursor-pointer rounded hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
className="w-full px-2 text-left leading-8 text-sm cursor-pointer rounded hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||||
onClick={() => handleEditShortcutButtonClick(shortcut)}
|
onClick={() => setEditingShortcutId(shortcut.id)}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
disabled={!havePermission(shortcut)}
|
disabled={!havePermission(shortcut)}
|
||||||
className="w-full px-3 text-left leading-10 cursor-pointer rounded text-red-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
className="w-full px-2 text-left leading-8 text-sm cursor-pointer rounded text-red-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:opacity-60"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDeleteShortcutButtonClick(shortcut);
|
handleDeleteShortcutButtonClick(shortcut);
|
||||||
}}
|
}}
|
||||||
@ -112,7 +97,6 @@ const ShortcutListView: React.FC<Props> = (props: Props) => {
|
|||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
actionsClassName="!w-24"
|
|
||||||
></Dropdown>
|
></Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -120,21 +104,11 @@ const ShortcutListView: React.FC<Props> = (props: Props) => {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{state.currentEditingShortcutId !== UNKNOWN_ID && (
|
{editingShortcutId && (
|
||||||
<CreateShortcutDialog
|
<CreateShortcutDialog
|
||||||
shortcutId={state.currentEditingShortcutId}
|
shortcutId={editingShortcutId}
|
||||||
onClose={() => {
|
onClose={() => setEditingShortcutId(undefined)}
|
||||||
setState({
|
onConfirm={() => setEditingShortcutId(undefined)}
|
||||||
...state,
|
|
||||||
currentEditingShortcutId: UNKNOWN_ID,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
onConfirm={() => {
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
currentEditingShortcutId: UNKNOWN_ID,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -37,8 +37,8 @@ const Dropdown: React.FC<Props> = (props: Props) => {
|
|||||||
{trigger ? (
|
{trigger ? (
|
||||||
trigger
|
trigger
|
||||||
) : (
|
) : (
|
||||||
<button className="flex flex-row justify-center items-center p-1 rounded text-gray-600 cursor-pointer border hover:opacity-80">
|
<button className="flex flex-row justify-center items-center rounded text-gray-600 cursor-pointer hover:opacity-80">
|
||||||
<Icon.MoreHorizontal className="w-4 h-auto" />
|
<Icon.MoreVertical className="w-4 h-auto" />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user