mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-09-20 18:20:12 +00:00
Dashboard Redesign (#48)
* feat: add user_template setting * style: header * style: page padding * style: header * feat: header now time * style: login page * feat: nav indicator * style: button inset shadow * style: footer text size * feat: header show login_ip * fix: error toast * fix: frontend_templates setting * fix: lint * feat: pr auto format * chore: auto-fix linting and formatting issues --------- Co-authored-by: hamster1963 <hamster1963@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
hamster1963
parent
811835ffe5
commit
540bb0185d
@@ -1,53 +1,69 @@
|
||||
import { ButtonProps } from "@/components/ui/button"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { ButtonProps } from "@/components/ui/button"
|
||||
import { copyToClipboard } from "@/lib/utils"
|
||||
import { forwardRef, useState } from "react"
|
||||
import { IconButton } from "./xui/icon-button"
|
||||
import { toast } from "sonner";
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { copyToClipboard } from "@/lib/utils";
|
||||
import { IconButton } from "./xui/icon-button"
|
||||
|
||||
interface NoteMenuProps extends ButtonProps {
|
||||
note: { private?: string, public?: string };
|
||||
note: { private?: string; public?: string }
|
||||
}
|
||||
|
||||
export const NoteMenu = forwardRef<HTMLButtonElement, NoteMenuProps>((props, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const [copy, setCopy] = useState(false);
|
||||
const { t } = useTranslation()
|
||||
const [copy, setCopy] = useState(false)
|
||||
|
||||
const switchState = async (text?: string) => {
|
||||
if (!text) {
|
||||
toast("Warning", {
|
||||
description: "You didn't have any note."
|
||||
description: "You didn't have any note.",
|
||||
})
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (!copy) {
|
||||
setCopy(true);
|
||||
await copyToClipboard(text);
|
||||
setCopy(true)
|
||||
await copyToClipboard(text)
|
||||
setTimeout(() => {
|
||||
setCopy(false);
|
||||
}, 2 * 1000);
|
||||
setCopy(false)
|
||||
}, 2 * 1000)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<IconButton {...props} ref={ref} variant="outline" size="icon" icon={
|
||||
copy ? "check" : "clipboard"
|
||||
} />
|
||||
<IconButton
|
||||
{...props}
|
||||
ref={ref}
|
||||
variant="outline"
|
||||
size="icon"
|
||||
icon={copy ? "check" : "clipboard"}
|
||||
/>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem onClick={() => { switchState(props.note.private) }}>{t("Private")}</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { switchState(props.note.public) }}>{t("Public")}</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
switchState(props.note.private)
|
||||
}}
|
||||
>
|
||||
{t("Private")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
switchState(props.note.public)
|
||||
}}
|
||||
>
|
||||
{t("Public")}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user