From 10cb78c11f79614720a8b9de8dd7c658bf44c0f6 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 22 Aug 2023 01:24:36 -0700 Subject: [PATCH] Move GridRep/Collection and add fade in --- components/{ => reps}/GridRep/index.module.scss | 10 ++++++++++ components/{ => reps}/GridRep/index.tsx | 16 +++++++++++++++- .../GridRepCollection/index.module.scss | 0 .../{ => reps}/GridRepCollection/index.tsx | 0 4 files changed, 25 insertions(+), 1 deletion(-) rename components/{ => reps}/GridRep/index.module.scss (97%) rename components/{ => reps}/GridRep/index.tsx (93%) rename components/{ => reps}/GridRepCollection/index.module.scss (100%) rename components/{ => reps}/GridRepCollection/index.tsx (100%) diff --git a/components/GridRep/index.module.scss b/components/reps/GridRep/index.module.scss similarity index 97% rename from components/GridRep/index.module.scss rename to components/reps/GridRep/index.module.scss index e208225d..b1929dd2 100644 --- a/components/GridRep/index.module.scss +++ b/components/reps/GridRep/index.module.scss @@ -9,6 +9,16 @@ padding: $unit-2x; min-width: 320px; width: 100%; + opacity: 1; + transition: opacity 0.3s ease-in-out; + + &.visible { + opacity: 1; + } + + &.hidden { + opacity: 0; + } &:hover { background: var(--grid-rep-hover); diff --git a/components/GridRep/index.tsx b/components/reps/GridRep/index.tsx similarity index 93% rename from components/GridRep/index.tsx rename to components/reps/GridRep/index.tsx index d720fe25..5be3da86 100644 --- a/components/GridRep/index.tsx +++ b/components/reps/GridRep/index.tsx @@ -40,10 +40,16 @@ const GridRep = (props: Props) => { const locale = router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en' + const [visible, setVisible] = useState(false) const [mainhand, setMainhand] = useState() const [weapons, setWeapons] = useState>({}) const [grid, setGrid] = useState>({}) + const gridRepStyles = classNames({ + [styles.gridRep]: true, + [styles.visible]: visible, + [styles.hidden]: !visible, + }) const titleClass = classNames({ empty: !props.name, }) @@ -68,6 +74,14 @@ const GridRep = (props: Props) => { [styles.grid]: true, }) + useEffect(() => { + setVisible(false) // Trigger fade out + const timeout = setTimeout(() => { + setVisible(true) // Trigger fade in + }, 300) // You can adjust the timing based on your preference + return () => clearTimeout(timeout) + }, []) + useEffect(() => { const newWeapons = Array(numWeapons) const gridWeapons = Array(numWeapons) @@ -249,7 +263,7 @@ const GridRep = (props: Props) => { return ( - + {detailsWithUsername}
{generateMainhandImage()}
diff --git a/components/GridRepCollection/index.module.scss b/components/reps/GridRepCollection/index.module.scss similarity index 100% rename from components/GridRepCollection/index.module.scss rename to components/reps/GridRepCollection/index.module.scss diff --git a/components/GridRepCollection/index.tsx b/components/reps/GridRepCollection/index.tsx similarity index 100% rename from components/GridRepCollection/index.tsx rename to components/reps/GridRepCollection/index.tsx