mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 06:12:24 +00:00
Add id to media card menu
This commit is contained in:
parent
897d63fb57
commit
e985f454d6
1 changed files with 34 additions and 1 deletions
|
|
@ -75,11 +75,15 @@ function MediaCardContent({
|
||||||
|
|
||||||
const dotListContent = [t(`media.types.${media.type}`)];
|
const dotListContent = [t(`media.types.${media.type}`)];
|
||||||
|
|
||||||
|
const altDotListContent = [t(`ID: ${media.id}`)];
|
||||||
|
|
||||||
const [searchQuery] = useSearchQuery();
|
const [searchQuery] = useSearchQuery();
|
||||||
|
|
||||||
const [, copyToClipboard] = useCopyToClipboard();
|
const [, copyToClipboard] = useCopyToClipboard();
|
||||||
const [hasCopied, setHasCopied] = useState(false);
|
const [hasCopied, setHasCopied] = useState(false);
|
||||||
|
|
||||||
|
const [hasCopiedID, setHasCopiedID] = useState(false);
|
||||||
|
|
||||||
if (closable) {
|
if (closable) {
|
||||||
setOverlayVisible(false);
|
setOverlayVisible(false);
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +119,15 @@ function MediaCardContent({
|
||||||
setTimeout(() => setHasCopied(false), 2000);
|
setTimeout(() => setHasCopied(false), 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyIDClick = (
|
||||||
|
e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,
|
||||||
|
) => {
|
||||||
|
e.preventDefault();
|
||||||
|
copyToClipboard(media.id);
|
||||||
|
setHasCopiedID(true);
|
||||||
|
setTimeout(() => setHasCopiedID(false), 2000);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
|
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
|
||||||
<Flare.Base
|
<Flare.Base
|
||||||
|
|
@ -292,7 +305,27 @@ function MediaCardContent({
|
||||||
<span>{media.title}</span>
|
<span>{media.title}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<div className="media-info-container justify-content-center flex flex-wrap">
|
<div className="media-info-container justify-content-center flex flex-wrap">
|
||||||
<DotList className="text-xs" content={dotListContent} />
|
{!overlayVisible ? (
|
||||||
|
<DotList className="text-xs" content={dotListContent} />
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleCopyIDClick}
|
||||||
|
className="z-50"
|
||||||
|
>
|
||||||
|
{!hasCopiedID ? (
|
||||||
|
<DotList className="text-xs" content={altDotListContent} />
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<DotList className="text-xs" content={altDotListContent} />
|
||||||
|
<Icon
|
||||||
|
className="text-xs text-type-secondary"
|
||||||
|
icon={Icons.CHECKMARK}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!overlayVisible && !closable ? (
|
{!overlayVisible && !closable ? (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue