chore: update share memo buttons (#1498)

This commit is contained in:
boojack 2023-04-09 11:38:30 +08:00 committed by GitHub
parent 91a24ef9ce
commit df30304d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 38 deletions

View File

@ -1,4 +1,3 @@
import copy from "copy-to-clipboard";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { memo, useEffect, useRef, useState } from "react"; import { memo, useEffect, useRef, useState } from "react";
import { toast } from "react-hot-toast"; import { toast } from "react-hot-toast";
@ -12,7 +11,6 @@ import MemoContent from "./MemoContent";
import MemoResources from "./MemoResources"; import MemoResources from "./MemoResources";
import showShareMemo from "./ShareMemoDialog"; import showShareMemo from "./ShareMemoDialog";
import showPreviewImageDialog from "./PreviewImageDialog"; import showPreviewImageDialog from "./PreviewImageDialog";
import showEmbedMemoDialog from "./EmbedMemoDialog";
import showChangeMemoCreatedTsDialog from "./ChangeMemoCreatedTsDialog"; import showChangeMemoCreatedTsDialog from "./ChangeMemoCreatedTsDialog";
import "@/less/memo.less"; import "@/less/memo.less";
@ -58,15 +56,6 @@ const Memo: React.FC<Props> = (props: Props) => {
navigate(`/m/${memo.id}`); navigate(`/m/${memo.id}`);
}; };
const handleShowEmbedMemoDialog = () => {
showEmbedMemoDialog(memo.id);
};
const handleCopyLink = () => {
copy(`${window.location.origin}/m/${memo.id}`);
toast.success(t("message.succeed-copy-link"));
};
const handleTogglePinMemoBtnClick = async () => { const handleTogglePinMemoBtnClick = async () => {
try { try {
if (memo.pinned) { if (memo.pinned) {
@ -253,15 +242,9 @@ const Memo: React.FC<Props> = (props: Props) => {
/> />
</Tooltip> </Tooltip>
</div> </div>
<span className="btn" onClick={handleCopyLink}>
{t("memo.copy-link")}
</span>
<span className="btn" onClick={handleViewMemoDetailPage}> <span className="btn" onClick={handleViewMemoDetailPage}>
{t("memo.view-detail")} {t("memo.view-detail")}
</span> </span>
<span className="btn" onClick={handleShowEmbedMemoDialog}>
{t("memo.embed")}
</span>
<span className="btn text-orange-500" onClick={handleArchiveMemoClick}> <span className="btn text-orange-500" onClick={handleArchiveMemoClick}>
{t("common.archive")} {t("common.archive")}
</span> </span>

View File

@ -15,6 +15,7 @@ import Icon from "./Icon";
import { generateDialog } from "./Dialog"; import { generateDialog } from "./Dialog";
import MemoContent from "./MemoContent"; import MemoContent from "./MemoContent";
import MemoResources from "./MemoResources"; import MemoResources from "./MemoResources";
import showEmbedMemoDialog from "./EmbedMemoDialog";
import "@/less/share-memo-dialog.less"; import "@/less/share-memo-dialog.less";
interface Props extends DialogProps { interface Props extends DialogProps {
@ -96,6 +97,10 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
}); });
}; };
const handleShowEmbedMemoDialog = () => {
showEmbedMemoDialog(memo.id);
};
const handleCopyLinkBtnClick = () => { const handleCopyLinkBtnClick = () => {
copy(`${window.location.origin}/m/${memo.id}`); copy(`${window.location.origin}/m/${memo.id}`);
toast.success(t("message.succeed-copy-link")); toast.success(t("message.succeed-copy-link"));
@ -121,14 +126,15 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
return ( return (
<> <>
<div className="dialog-header-container py-3 px-4 pl-6 !mb-0 rounded-t-lg"> <div className="dialog-header-container py-3 px-4 !mb-0 rounded-t-lg">
<p className="">{t("common.share")} Memo</p> <p className="">{t("common.share")} Memo</p>
<button className="btn close-btn" onClick={handleCloseBtnClick}> <button className="btn close-btn" onClick={handleCloseBtnClick}>
<Icon.X className="icon-img" /> <Icon.X className="icon-img" />
</button> </button>
</div> </div>
<div className="dialog-content-container w-full flex flex-col justify-start items-start relative"> <div className="dialog-content-container w-full flex flex-col justify-start items-start relative">
<div className="px-4 pb-3 border-b w-full flex flex-row justify-between items-center"> <div className="px-4 pb-3 w-full flex flex-row justify-start items-center">
<span className="text-sm mr-2">{t("common.visibility")}:</span>
<Select <Select
className="!min-w-[10rem] w-auto text-sm" className="!min-w-[10rem] w-auto text-sm"
value={state.memoVisibility} value={state.memoVisibility}
@ -144,24 +150,28 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
</Option> </Option>
))} ))}
</Select> </Select>
<div className="flex flex-row justify-end items-center">
<button disabled={createLoadingState.isLoading} className="btn-normal h-8 mr-2" onClick={handleDownloadBtnClick}>
{createLoadingState.isLoading ? (
<Icon.Loader className="w-4 h-auto sm:mr-1 animate-spin" />
) : (
<Icon.Download className="w-4 h-auto sm:mr-1" />
)}
<span className="hidden sm:block">{t("common.image")}</span>
</button>
<button className="btn-normal h-8" onClick={handleCopyLinkBtnClick}>
<Icon.Link className="w-4 h-auto sm:mr-1" />
<span className="hidden sm:block">{t("common.link")}</span>
</button>
</div>
</div> </div>
<div className="w-full rounded-lg overflow-clip"> <div className="px-4 pb-3 w-full flex flex-row justify-start items-center space-x-2">
<button disabled={createLoadingState.isLoading} className="btn-normal h-8" onClick={handleDownloadBtnClick}>
{createLoadingState.isLoading ? (
<Icon.Loader className="w-4 h-auto mr-1 animate-spin" />
) : (
<Icon.Download className="w-4 h-auto mr-1" />
)}
{t("common.image")}
</button>
<button className="btn-normal h-8" onClick={handleShowEmbedMemoDialog}>
<Icon.Code className="w-4 h-auto mr-1" />
{t("memo.embed")}
</button>
<button className="btn-normal h-8" onClick={handleCopyLinkBtnClick}>
<Icon.Link className="w-4 h-auto mr-1" />
{t("common.link")}
</button>
</div>
<div className="w-full rounded-lg border-t overflow-clip">
<div <div
className="w-96 max-w-full h-auto select-none relative flex flex-col justify-start items-start bg-white dark:bg-zinc-800" className="w-full h-auto select-none relative flex flex-col justify-start items-start bg-white dark:bg-zinc-800"
ref={memoElRef} ref={memoElRef}
> >
<span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{memo.createdAtStr}</span> <span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{memo.createdAtStr}</span>

View File

@ -1,5 +1,5 @@
.share-memo-dialog { .share-memo-dialog {
> .dialog-container { > .dialog-container {
@apply w-96 max-w-full p-0 bg-white dark:bg-zinc-800; @apply w-112 max-w-full p-0 bg-white dark:bg-zinc-800;
} }
} }

View File

@ -51,7 +51,8 @@
"preview": "Preview", "preview": "Preview",
"rename": "Rename", "rename": "Rename",
"clear": "Clear", "clear": "Clear",
"name": "Name" "name": "Name",
"visibility": "Visibility"
}, },
"router": { "router": {
"back-to-home": "Back to Home" "back-to-home": "Back to Home"
@ -76,7 +77,7 @@
"memo": { "memo": {
"view-detail": "View Detail", "view-detail": "View Detail",
"copy-link": "Copy Link", "copy-link": "Copy Link",
"embed": "Embed memo", "embed": "Embed",
"archived-memos": "Archived Memos", "archived-memos": "Archived Memos",
"no-archived-memos": "No archived memos.", "no-archived-memos": "No archived memos.",
"fetching-data": "fetching data...", "fetching-data": "fetching data...",