Skip to content

Commit

Permalink
fix: toastMsg css fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kcwww committed Dec 13, 2023
1 parent d9d1375 commit 3a15e74
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 12 additions & 3 deletions front/src/pages/Make/Snowball/MainDeco/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const ButtonBox = styled.div`

const ToastMsg = styled.div`
position: fixed;
top: 70%;
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
Expand All @@ -97,6 +97,7 @@ const ToastMsg = styled.div`
border-radius: 1rem;
text-align: center;
padding: 1rem;
font-size: 1rem;
`;

const Steps = () => {
Expand Down Expand Up @@ -186,13 +187,21 @@ const Steps = () => {

const [toast, setToast] = useState(false);

useEffect(() => {
const timer = useRef<number | null>(null);
const setToastMsg = () => {
if (timer.current) clearTimeout(timer.current);
if (step === selectDeco) {
setToast(true);
setTimeout(() => {
timer.current = setTimeout(() => {
setToast(false);
}, 1500);
} else {
setToast(false);
}
};

useEffect(() => {
setToastMsg();
}, [step]);

useEffect(() => {
Expand Down
15 changes: 12 additions & 3 deletions front/src/pages/Visit/Deco/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const ButtonBox = styled.div`

const ToastMsg = styled.div`
position: fixed;
top: 70%;
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
Expand All @@ -95,6 +95,7 @@ const ToastMsg = styled.div`
border-radius: 1rem;
text-align: center;
padding: 1rem;
font-size: 1rem;
`;

const Steps = () => {
Expand Down Expand Up @@ -176,13 +177,21 @@ const Steps = () => {

const [toast, setToast] = useState(false);

useEffect(() => {
const timer = useRef<number | null>(null);
const setToastMsg = () => {
if (timer.current) clearTimeout(timer.current);
if (step === selectDeco || step === selectMsgColor) {
setToast(true);
setTimeout(() => {
timer.current = setTimeout(() => {
setToast(false);
}, 1500);
} else {
setToast(false);
}
};

useEffect(() => {
setToastMsg();
}, [step]);

const renderStateBoxes = () => {
Expand Down

0 comments on commit 3a15e74

Please sign in to comment.