Skip to content

Commit 193de99

Browse files
committed
style: enhance drag-and-drop UI with visual improvements
1 parent 76efbaf commit 193de99

File tree

2 files changed

+36
-57
lines changed

2 files changed

+36
-57
lines changed

frontend/src/pages/ContentPage.tsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -538,25 +538,7 @@ export default function ContentPage() {
538538
animate={{ opacity: 1, y: 0 }}
539539
transition={{ duration: 0.25 }}
540540
>
541-
<AnimatePresence>
542-
{dragActive ? (
543-
<motion.div
544-
className="absolute inset-0 z-40 flex items-center justify-center cursor-copy bg-black/10"
545-
onDragOver={(e) => { e.preventDefault(); e.stopPropagation(); try { e.dataTransfer.dropEffect = "copy"; } catch {} }}
546-
onDragEnter={(e) => { e.preventDefault(); e.stopPropagation(); dragCounter.current++; }}
547-
onDragLeave={(e) => { e.preventDefault(); e.stopPropagation(); dragCounter.current = Math.max(0, dragCounter.current - 1); if (dragCounter.current === 0) setDragActive(false); }}
548-
onDrop={(e) => e.preventDefault()}
549-
initial={{ opacity: 0 }}
550-
animate={{ opacity: 1 }}
551-
exit={{ opacity: 0 }}
552-
transition={{ duration: 0.2 }}
553-
>
554-
<div className="pointer-events-none text-primary-600 text-xl font-semibold drop-shadow-sm">
555-
{t("contentpage.drop_hint", { defaultValue: "拖入 .mcworld/.mcpack/.mcaddon 以导入" })}
556-
</div>
557-
</motion.div>
558-
) : null}
559-
</AnimatePresence>
541+
560542
<Modal size="sm" isOpen={importing} hideCloseButton isDismissable={false}>
561543
<ModalContent>
562544
{() => (<>
@@ -620,8 +602,23 @@ export default function ContentPage() {
620602
initial={{ opacity: 0, y: 8 }}
621603
animate={{ opacity: 1, y: 0 }}
622604
transition={{ duration: 0.25 }}
623-
className="rounded-2xl border border-default-200 bg-white/60 dark:bg-neutral-900/60 backdrop-blur-md p-5"
605+
className={`relative overflow-hidden rounded-2xl border border-default-200 bg-white/60 dark:bg-neutral-900/60 backdrop-blur-md p-5 ${dragActive ? "border-2 border-dashed border-primary" : ""}`}
624606
>
607+
<AnimatePresence>
608+
{dragActive ? (
609+
<motion.div
610+
className="pointer-events-none absolute inset-0 z-40 flex items-center justify-center bg-black/10 rounded-2xl"
611+
initial={{ opacity: 0 }}
612+
animate={{ opacity: 1 }}
613+
exit={{ opacity: 0 }}
614+
transition={{ duration: 0.2 }}
615+
>
616+
<div className="text-primary-600 text-xl font-semibold">
617+
{t("contentpage.drop_hint", { defaultValue: "拖入 .mcworld/.mcpack/.mcaddon 以导入" })}
618+
</div>
619+
</motion.div>
620+
) : null}
621+
</AnimatePresence>
625622
<div className="flex items-center justify-between">
626623
<h1 className="text-2xl font-bold">
627624
{t("launcherpage.content_manage", { defaultValue: "内容管理" })}

frontend/src/pages/ModsPage.tsx

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -830,42 +830,7 @@ export const ModsPage: React.FC = () => {
830830
animate={{ opacity: 1, y: 0 }}
831831
transition={{ duration: 0.25 }}
832832
>
833-
<AnimatePresence>
834-
{dragActive ? (
835-
<motion.div
836-
className="absolute inset-0 z-40 flex items-center justify-center cursor-copy bg-black/10"
837-
onDragOver={(e) => {
838-
e.preventDefault();
839-
e.stopPropagation();
840-
try {
841-
e.dataTransfer.dropEffect = "copy";
842-
} catch {}
843-
}}
844-
onDragEnter={(e) => {
845-
e.preventDefault();
846-
e.stopPropagation();
847-
dragCounter.current++;
848-
}}
849-
onDragLeave={(e) => {
850-
e.preventDefault();
851-
e.stopPropagation();
852-
dragCounter.current = Math.max(0, dragCounter.current - 1);
853-
if (dragCounter.current === 0) setDragActive(false);
854-
}}
855-
onDrop={handleDrop}
856-
initial={{ opacity: 0 }}
857-
animate={{ opacity: 1 }}
858-
exit={{ opacity: 0 }}
859-
transition={{ duration: 0.2 }}
860-
>
861-
<div className="pointer-events-none text-primary-600 text-xl font-semibold drop-shadow-sm">
862-
{t("mods.drop_hint", {
863-
defaultValue: "拖入 .zip 或 .dll 以导入模组/插件",
864-
})}
865-
</div>
866-
</motion.div>
867-
) : null}
868-
</AnimatePresence>
833+
869834
<Modal
870835
size="sm"
871836
isOpen={importing && !dllOpen}
@@ -1200,10 +1165,27 @@ export const ModsPage: React.FC = () => {
12001165
transition={{ duration: 0.25 }}
12011166
>
12021167
<Card
1203-
className={`rounded-3xl bg-white/60 dark:bg-black/30 backdrop-blur-md border border-white/30 ${
1168+
className={`relative overflow-hidden rounded-3xl bg-white/60 dark:bg-black/30 backdrop-blur-md border border-white/30 ${
12041169
dragActive ? "border-2 border-dashed border-primary" : ""
12051170
}`}
12061171
>
1172+
<AnimatePresence>
1173+
{dragActive ? (
1174+
<motion.div
1175+
className="pointer-events-none absolute inset-0 z-40 flex items-center justify-center bg-black/10 rounded-3xl"
1176+
initial={{ opacity: 0 }}
1177+
animate={{ opacity: 1 }}
1178+
exit={{ opacity: 0 }}
1179+
transition={{ duration: 0.2 }}
1180+
>
1181+
<div className="text-primary-600 text-xl font-semibold">
1182+
{t("mods.drop_hint", {
1183+
defaultValue: "拖入 .zip 或 .dll 以导入模组/插件",
1184+
})}
1185+
</div>
1186+
</motion.div>
1187+
) : null}
1188+
</AnimatePresence>
12071189
<CardHeader className="flex items-center justify-between p-3 sm:p-4">
12081190
<div className="flex items-center gap-2">
12091191
<FaPuzzlePiece />

0 commit comments

Comments
 (0)