WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 50 additions & 10 deletions apps/web/app/(org)/dashboard/caps/components/Folders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ export const NormalFolder = React.forwardRef<
() => ({
play: (animationName: string) => {
if (!rive) return;
rive.play(animationName);
try {
rive.play(animationName);
} catch (error) {
console.warn("Failed to play folder animation", error);
}
},
stop: () => {
if (!rive) return;
rive.stop();
try {
rive.stop();
} catch (error) {
console.warn("Failed to stop folder animation", error);
}
},
}),
[rive],
Expand Down Expand Up @@ -66,11 +74,19 @@ export const BlueFolder = React.forwardRef<
() => ({
play: (animationName: string) => {
if (!rive) return;
rive.play(animationName);
try {
rive.play(animationName);
} catch (error) {
console.warn("Failed to play folder animation", error);
}
},
stop: () => {
if (!rive) return;
rive.stop();
try {
rive.stop();
} catch (error) {
console.warn("Failed to stop folder animation", error);
}
},
}),
[rive],
Expand Down Expand Up @@ -98,11 +114,19 @@ export const RedFolder = React.forwardRef<
() => ({
play: (animationName: string) => {
if (!rive) return;
rive.play(animationName);
try {
rive.play(animationName);
} catch (error) {
console.warn("Failed to play folder animation", error);
}
},
stop: () => {
if (!rive) return;
rive.stop();
try {
rive.stop();
} catch (error) {
console.warn("Failed to stop folder animation", error);
}
},
}),
[rive],
Expand Down Expand Up @@ -130,11 +154,19 @@ export const YellowFolder = React.forwardRef<
() => ({
play: (animationName: string) => {
if (!rive) return;
rive.play(animationName);
try {
rive.play(animationName);
} catch (error) {
console.warn("Failed to play folder animation", error);
}
},
stop: () => {
if (!rive) return;
rive.stop();
try {
rive.stop();
} catch (error) {
console.warn("Failed to stop folder animation", error);
}
},
}),
[rive],
Expand Down Expand Up @@ -177,11 +209,19 @@ export const AllFolders = React.forwardRef<FolderHandle, AllFoldersProps>(
() => ({
play: (animationName: string) => {
if (!rive) return;
rive.play(animationName);
try {
rive.play(animationName);
} catch (error) {
console.warn("Failed to play folder animation", error);
}
},
stop: () => {
if (!rive) return;
rive.stop();
try {
rive.stop();
} catch (error) {
console.warn("Failed to stop folder animation", error);
}
},
}),
[rive],
Expand Down
20 changes: 16 additions & 4 deletions apps/web/app/(org)/dashboard/caps/components/NewFolderDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ export const NewFolderDialog: React.FC<Props> = ({
});

useEffect(() => {
if (!open) setSelectedColor(null);
if (!open) {
setSelectedColor(null);
// Stop all animations when dialog closes
Object.values(folderRefs.current).forEach((ref) => {
ref.current?.stop();
});
}
}, [open]);

const folderRefs = useRef(
Expand Down Expand Up @@ -156,21 +162,27 @@ export const NewFolderDialog: React.FC<Props> = ({
setSelectedColor(option.value);
}}
onMouseEnter={() => {
if (!riveFile) return;
const folderRef = folderRefs.current[option.value]?.current;
if (!folderRef) return;
folderRef.stop();
folderRef.play("folder-open");
}}
onMouseLeave={() => {
if (!riveFile) return;
const folderRef = folderRefs.current[option.value]?.current;
if (!folderRef) return;
folderRef.stop();
folderRef.play("folder-close");
}}
>
{option.component(
riveFile as RiveFile,
folderRefs.current[option.value],
{riveFile &&
option.component(
riveFile as RiveFile,
folderRefs.current[option.value],
)}
{!riveFile && (
<div className="w-[50px] h-[50px] bg-gray-4 rounded animate-pulse" />
)}
<p className="text-xs text-gray-10">{option.label}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export const SubfolderDialog: React.FC<Props> = ({
if (!open) {
setSelectedColor(null);
setFolderName("");
// Stop any running animations when the dialog closes
Object.values(folderRefs.current).forEach((ref) => {
ref.current?.stop();
});
}
}, [open]);

Expand Down Expand Up @@ -163,21 +167,27 @@ export const SubfolderDialog: React.FC<Props> = ({
setSelectedColor(option.value);
}}
onMouseEnter={() => {
if (!riveFile) return;
const folderRef = folderRefs.current[option.value]?.current;
if (!folderRef) return;
folderRef.stop();
folderRef.play("folder-open");
}}
onMouseLeave={() => {
if (!riveFile) return;
const folderRef = folderRefs.current[option.value]?.current;
if (!folderRef) return;
folderRef.stop();
folderRef.play("folder-close");
}}
>
{option.component(
riveFile as RiveFile,
folderRefs.current[option.value],
{riveFile &&
option.component(
riveFile as RiveFile,
folderRefs.current[option.value],
)}
{!riveFile && (
<div className="w-[50px] h-[50px] rounded bg-gray-4 animate-pulse" />
)}
<p className="text-xs text-gray-10">{option.label}</p>
</div>
Expand Down