홈화면 배너 처리
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
import moment from 'moment';
|
||||
import { motion } from 'framer-motion';
|
||||
import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
|
||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||
import { setLocalStorage } from '@/shared/lib/web-view-bridge';
|
||||
import { HomeBottomBannerProps } from '../model/types';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
import { BottomSheetMotionDuration, BottomSheetMotionVaiants } from '@/entities/common/model/constant';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const HomeBottomBanner = ({
|
||||
setBottomBannerOn,
|
||||
bottomBannerOn
|
||||
}: HomeBottomBannerProps) => {
|
||||
const { navigate } = useNavigate();
|
||||
|
||||
const [isFirstOpen, setIsFirstOpen] = useState<boolean>(false);
|
||||
|
||||
const onClickToClose = () => {
|
||||
// close
|
||||
setBottomBannerOn(false);
|
||||
useStore.getState().BannerStore.setBannerInfo({
|
||||
HomneBottomBanner: true
|
||||
});
|
||||
};
|
||||
const onClickToCloseDay = () => {
|
||||
// 오늘 날짜 기록
|
||||
@@ -23,22 +30,28 @@ export const HomeBottomBanner = ({
|
||||
onClickToClose();
|
||||
};
|
||||
|
||||
const variants = {
|
||||
hidden: { y: '100%' },
|
||||
visible: { y: '0%' },
|
||||
};
|
||||
useEffect(() => {
|
||||
let bannerInfo = useStore.getState().BannerStore.bannerInfo;
|
||||
if(!!bannerInfo.HomneBottomBanner){
|
||||
setIsFirstOpen(false);
|
||||
}
|
||||
else{
|
||||
setIsFirstOpen(true);
|
||||
}
|
||||
}, [bottomBannerOn]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{bottomBannerOn &&
|
||||
{bottomBannerOn && isFirstOpen &&
|
||||
<div className="bg-dim"></div>
|
||||
}
|
||||
<motion.div
|
||||
className="bottomsheet banner"
|
||||
initial="hidden"
|
||||
animate={ (bottomBannerOn)? 'visible': 'hidden' }
|
||||
variants={ variants }
|
||||
transition={{ duration: 0.5 }}
|
||||
animate={ (bottomBannerOn && isFirstOpen)? 'visible': 'hidden' }
|
||||
variants={ BottomSheetMotionVaiants }
|
||||
transition={ BottomSheetMotionDuration }
|
||||
>
|
||||
<div className="bottomsheet-content">
|
||||
<img
|
||||
|
||||
Reference in New Issue
Block a user