-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Safari 브라우저 + 최초 로그인 시 보여줄 가이드 모달 구현
- Loading branch information
Showing
10 changed files
with
102 additions
and
203 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters