Skip to content

Commit

Permalink
Merge pull request #194 from Step3-kakao-tech-campus/feat/#180
Browse files Browse the repository at this point in the history
Safari 브라우저 + 최초 로그인 시 보여줄 가이드 모달 구현
  • Loading branch information
JeonDoGyun authored Nov 10, 2023
2 parents 9c198e8 + faa1ee3 commit e6de6c1
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 203 deletions.
59 changes: 0 additions & 59 deletions public/data/profileHomeMock.json

This file was deleted.

67 changes: 0 additions & 67 deletions public/data/profileNewMock.json

This file was deleted.

67 changes: 0 additions & 67 deletions public/data/profileUrgentMock.json

This file was deleted.

File renamed without changes.
7 changes: 0 additions & 7 deletions src/commons/modals/AutoplayGuideModal.tsx

This file was deleted.

87 changes: 87 additions & 0 deletions src/commons/modals/SafariAutoplayGuideModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { getCookie, setCookie } from 'commons/cookie/cookie';
import React, { useEffect, useState } from 'react';

interface AutoplayGuideModalProps {
browserInfo: string;
}

const SafariAutoplayGuideModal = ({ browserInfo }: AutoplayGuideModalProps) => {
const browsers = [
'Chrome',
'Opera',
'WebTV',
'Whale',
'Beonex',
'Chimera',
'NetPositive',
'Phoenix',
'Firefox',
'Safari',
'SkipStone',
'Netscape',
'Mozilla',
];
const [isSafari, setIsSafari] = useState<boolean>(false);
const [currentBrowser, setCurrentBrowser] = useState<string>('');
const [isClose, setIsClose] = useState<boolean>(false);
const isFirstTime = getCookie('isFirstTime');

const handleCloseButton = () => {
setIsClose(true);
setCookie('isFirstTime', 'false', {
maxAge: 60000 * 60 * 24 * 30,
});
};

const handleBrowserInfo = async () => {
switch (true) {
case browserInfo.includes('edg'):
setCurrentBrowser('Edge');
break;
case browserInfo.includes('trident') || browserInfo.includes('msie'):
setCurrentBrowser('Internet Explorer');
break;
default:
if (currentBrowser === 'Safari') {
setIsSafari(true);
}

setCurrentBrowser(
browsers.find((browser) =>
browserInfo.includes(browser.toLowerCase()),
) || 'Other',
);

break;
}
};

useEffect(() => {
handleBrowserInfo();
}, [currentBrowser]);

return isSafari && !isClose && Boolean(isFirstTime) ? (
<dialog
open={isClose}
className="w-[400px] h-[400px] rounded-md flex flex-col justify-around items-center z-50"
>
<button
className="absolute top-3 right-3 text-lg font-bold"
onClick={handleCloseButton}
>
X
</button>
<div className="flex flex-col gap-2 items-center">
<span className="font-bold text-3xl">Safari</span>
<span className="font-bold text-xl">자동재생 가이드</span>
</div>
<img></img>
<div className="flex flex-col gap-2 items-center font-normal text-lg">
<span className="">원활한 컨텐츠 사용을 위해</span>
<span className="">Safari 환경설정의 자동 재생을 켜주세요.</span>
</div>
</dialog>
) : null;
};

export default SafariAutoplayGuideModal;
3 changes: 3 additions & 0 deletions src/pages/home/components/HomeVideo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useRef, useEffect } from 'react';
import AutoplayGuideModal from 'commons/modals/SafariAutoplayGuideModal';
import VideoOverlay from './VideoOverlay';
import { HomeVideoProps, VideoOverlayProps } from '../homeType';

Expand All @@ -17,6 +18,7 @@ const HomeVideo = (props: HomeVideoProps) => {
const videoRef = useRef(null);
const videoPlayerRef = useRef<HTMLVideoElement>(null);
const [loading, setLoading] = useState(true);
const browserInfo = window.navigator.userAgent.toLowerCase();

useEffect(() => {
if (videoPlayerRef.current) {
Expand Down Expand Up @@ -110,6 +112,7 @@ const HomeVideo = (props: HomeVideoProps) => {
<source src={url} type="video/mp4" />
</video>
</div>
<AutoplayGuideModal browserInfo={browserInfo} />
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/components/VideoMuteIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VideoMuteIconProps } from '../homeType';
const VideoMuteIcon = (props: VideoMuteIconProps) => {
const { muted, opacity } = props;
return (
<div className="absolute z-10 w-16 h-16 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
<div className="absolute z-10 pointer-events-none w-16 h-16 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
{!muted && (
<img
src="/assets/images/speaker.svg"
Expand Down
11 changes: 10 additions & 1 deletion src/pages/login/components/LoginInputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ShelterLoginType, shelterLoginState } from 'recoil/shelterState';
import * as Yup from 'yup';
import { useMutation } from '@tanstack/react-query';
import VLoginInputForm from './VLoginInputForm';
import { setCookie } from '../../../commons/cookie/cookie';
import { getCookie, setCookie } from '../../../commons/cookie/cookie';

const LoginInputForm = () => {
const [userInfo, setUserInfo] = useRecoilState(shelterLoginState);
Expand All @@ -21,6 +21,14 @@ const LoginInputForm = () => {
password: Yup.string().required('비밀번호를 입력해주세요.'),
});

const setBeginnerState = () => {
if (!getCookie('isFirstTime')) {
setCookie('isFirstTime', 'True', {
maxAge: 60000 * 60 * 24 * 30,
});
}
};

const userFetch = async () => {
const res = await fetch(`${process.env.REACT_APP_URI}/account/login`, {
method: 'POST',
Expand Down Expand Up @@ -82,6 +90,7 @@ const LoginInputForm = () => {
setCookie('loginState', 'Login', {
maxAge: 60000 * 60 * 24,
});
setBeginnerState();

navigate('/');
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/notFound/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NotFound = () => {
<h2 className="text-2xl font-bold">집으로 돌아가요!</h2>
<Link
to="/"
className="border flex items-center justify-center box-border border-brand-color border-2 bg-brand-color text-white rounded-md w-20 py-1 hover:bg-white hover:text-brand-color transition duration-300 ease-in-out"
className="flex items-center justify-center box-border border-brand-color border-2 bg-brand-color text-white rounded-md w-20 py-1 hover:bg-white hover:text-brand-color transition duration-300 ease-in-out"
>
홈으로
</Link>
Expand Down

0 comments on commit e6de6c1

Please sign in to comment.