-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SP0] 404, 500 에러페이지 제작 #378
Changes from 17 commits
e9d9368
3e1c365
ca02867
4e9bf13
090fbd3
919f0ee
35d4b9e
4773b42
6881ab1
7098f14
b9da14c
6df42d2
778c9d5
4b75d5f
e06df57
7a357b6
2cdb9f4
2755c54
418429a
a76cd00
eecee68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
|
||
interface StyleProps { | ||
isReverse?: boolean; | ||
} | ||
|
||
export const Root = styled.button<StyleProps>` | ||
export const Root = styled.button` | ||
display: flex; | ||
align-items: center; | ||
|
||
height: 50px; | ||
padding: 10px 30px; | ||
height: 60px; | ||
padding: 12px 28px; | ||
border-radius: 99px; | ||
background: ${colors.gray10}; | ||
|
||
color: ${colors.gray950}; | ||
font-size: 24px; | ||
font-size: 22px; | ||
font-weight: 600; | ||
line-height: 150%; /* 36px */ | ||
letter-spacing: -0.48px; | ||
cursor: pointer; | ||
|
||
@media (max-width: 428px) { | ||
padding: 8px 22px; | ||
font-size: 18px; | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,3 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
import { useRouter } from 'next/router'; | ||
import { Header } from '@src/components'; | ||
import RoundButton from '@src/components/common/RoundButton'; | ||
import { Page404 } from '@src/views/ErrorPage'; | ||
|
||
function Wrong() { | ||
const router = useRouter(); | ||
|
||
const handleButtonClick = () => { | ||
router.push('/'); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Header /> | ||
<Styled.Root> | ||
<span>잘못된 경로예요</span> | ||
<RoundButton onClick={handleButtonClick} isReverse={true}> | ||
홈으로 가기 | ||
</RoundButton> | ||
</Styled.Root> | ||
</> | ||
); | ||
} | ||
|
||
export default Wrong; | ||
|
||
const Styled = { | ||
Root: styled.section` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 48px; | ||
|
||
width: 100%; | ||
height: 100vh; | ||
|
||
& span { | ||
color: ${colors.gray10}; | ||
|
||
font-size: 48px; | ||
font-weight: 600; | ||
line-height: 150%; /* 72px */ | ||
letter-spacing: -0.96px; | ||
} | ||
`, | ||
}; | ||
export default Page404; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Page500 } from '@src/views/ErrorPage'; | ||
|
||
export default Page500; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useRouter } from 'next/router'; | ||
import { Header } from '@src/components'; | ||
import RoundButton from '@src/components/common/RoundButton'; | ||
import * as S from './styles'; | ||
import ERROR_MESSAGE from './constants/errorMessage'; | ||
import ERROR_BUTTON from './constants/errorButton'; | ||
import ErrorCode from './components/ErrorCode'; | ||
|
||
interface ErrorPageProps { | ||
code: 404 | 500; | ||
} | ||
|
||
function ErrorPage({ code }: ErrorPageProps) { | ||
const router = useRouter(); | ||
const CODE_KEY : 'CODE404' | 'CODE500' = `CODE${code}`; | ||
|
||
const handleButtonClick = () => { | ||
code===404? router.push('/') : router.back(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Header /> | ||
<S.Root> | ||
<S.TopSection> | ||
<ErrorCode code={code}/> | ||
<S.ErrorText>{ERROR_MESSAGE[CODE_KEY]}</S.ErrorText> | ||
<RoundButton onClick={handleButtonClick}> | ||
{ERROR_BUTTON[CODE_KEY]} | ||
</RoundButton> | ||
</S.TopSection> | ||
{code === 500 && ( | ||
<S.ContactLink | ||
href="https://walla.my/sopt_official" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
문의하기 | ||
</S.ContactLink> | ||
)} | ||
</S.Root> | ||
</> | ||
); | ||
} | ||
|
||
export const Page404 = () => <ErrorPage code={404} />; | ||
export const Page500 = () => <ErrorPage code={500} />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ReactComponent as Ic404Front } from './ic_404_front.svg'; | ||
import { ReactComponent as Ic404Back } from './ic_404_back.svg'; | ||
import { ReactComponent as Ic404Ghost } from './ic_404_ghost.svg'; | ||
import { ReactComponent as Ic404GhostDark } from './ic_404_ghost_dark.svg'; | ||
import { ReactComponent as Ic500Front } from './ic_500_front.svg'; | ||
import { ReactComponent as Ic500Back } from './ic_500_back.svg'; | ||
import { ReactComponent as Ic500Cone } from './ic_500_cone.svg'; | ||
import { ReactComponent as Ic500ConeDark } from './ic_500_cone_dark.svg'; | ||
|
||
export { Ic404Front, Ic404Back, Ic404Ghost, Ic404GhostDark, Ic500Cone, Ic500Back, Ic500Front, Ic500ConeDark }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useIsMobile } from '@src/hooks/useDevice'; | ||
import { Ic404Back, Ic404Front, Ic404Ghost, Ic404GhostDark, Ic500Back, Ic500Cone, Ic500ConeDark, Ic500Front } from '../assets'; | ||
import * as S from '../styles'; | ||
|
||
interface ErrorCodeProps { | ||
code: 404 | 500; | ||
} | ||
export default function ErrorCode({ code }: ErrorCodeProps) { | ||
const isMobile = useIsMobile('428px'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모바일 뷰를 대응해야 하는데 다른 컴포넌트들 처럼 css로 스타일링하는게 아닌 svg 컴포넌트를 조건부로 렌더링해야 하는 케이스이기 때문에 media-query를 사용하기 부적절해서 기존에 만들어져있던 공통 훅인 useDevice를 활용해보았습니당 useIsMobile 안에 브레이크포인트를 넣어주면 isMobile boolean 값으로 브레이크포인트 이상 / 이하에 따라 조건부 렌더링을 해줄 수 있어요! |
||
const SIZE = { | ||
height: 92, | ||
icon: 150, | ||
}; | ||
Comment on lines
+19
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이친구들은 굳이 왜 상수화를 했냐... 하는 의문이 드실텐데 기존에는 768px 이상 / 이하에 따라 모든 svg들의 크기를 조절해야했어요. 근데 이후에 모바일뷰를 제외하고는 아이콘 사이즈를 모두 통일하는 것으로 디자인이 바뀌어서 해당 커밋 보시면 isTablet 값에 따라 사이즈를 조정해준 방식 확인하실 수 있습니다 ! |
||
|
||
const codeVariant = { | ||
initial: { gap: '6px' }, | ||
whileHover: { gap: '159px' }, | ||
}; | ||
|
||
const iconVariant = { | ||
initial: { opacity: 0 }, | ||
whileHover: { opacity: 1 }, | ||
}; | ||
|
||
const animationProps = { | ||
initial : 'initial', | ||
whileHover : 'whileHover', | ||
transition : { duration: 0.3 }, | ||
}; | ||
|
||
return ( | ||
<S.ErrorCode {...animationProps} variants={codeVariant}> | ||
{code === 404 ? ( | ||
<> | ||
{!isMobile && | ||
<> | ||
<Ic404Front height={SIZE.height} /> | ||
<Ic404Back height={SIZE.height} /> | ||
</> | ||
} | ||
{isMobile ? <Ic404GhostDark /> : | ||
<S.ErrorIcon {...animationProps} variants={iconVariant}> | ||
<Ic404Ghost height={SIZE.icon} /> | ||
</S.ErrorIcon> | ||
} | ||
</> | ||
) : ( | ||
<> | ||
{!isMobile && | ||
<> | ||
<Ic500Front height={SIZE.height} /> | ||
<Ic500Back height={SIZE.height} /> | ||
</> | ||
} | ||
{isMobile ? <Ic500ConeDark /> : | ||
<S.ErrorIcon {...animationProps} variants={iconVariant}> | ||
<Ic500Cone height={SIZE.icon} /> | ||
</S.ErrorIcon> | ||
} | ||
</> | ||
)} | ||
</S.ErrorCode> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const ERROR_BUTTON = { | ||
CODE404 : '홈으로 가기', | ||
CODE500 : '이전 페이지로 가기', | ||
}; | ||
|
||
export default ERROR_BUTTON; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const ERROR_MESSAGE = { | ||
CODE404 : '존재하지 않는 페이지예요', | ||
CODE500 : '알 수 없는 오류가 발생했어요', | ||
}; | ||
|
||
export default ERROR_MESSAGE; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Page404, Page500 } from './ErrorPage'; | ||
|
||
export { Page404, Page500 }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import styled from '@emotion/styled'; | ||
import { motion } from 'framer-motion'; | ||
import Link from 'next/link'; | ||
|
||
export const Root = styled.main` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
position: relative; | ||
|
||
width: 100%; | ||
height: 100vh; | ||
padding-bottom: 20vh; | ||
`; | ||
export const TopSection = styled.section` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 34px; | ||
|
||
width: 100%; | ||
`; | ||
export const ErrorText = styled.p` | ||
color: #FCFCFC; | ||
|
||
font-size: calc(24px + 1vw); | ||
font-weight: 600; | ||
line-height: 150%; | ||
letter-spacing: -0.96px; | ||
`; | ||
export const ContactLink = styled(Link)` | ||
position: fixed; | ||
bottom: 17vh; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 두 콘텐츠 사이의 gap을 잡아주는 것이 아닌, 모쪼록 저도 찝찝했던 부분이라 해당 부분
요 방법으로 대응했습니다! 👍 |
||
color: #FFF; | ||
font-size: 24px; | ||
font-weight: 600; | ||
line-height: 150%; /* 36px */ | ||
letter-spacing: -0.48px; | ||
text-decoration-line: underline; | ||
|
||
cursor: pointer; | ||
|
||
@media (max-width: 428px) { | ||
font-size: 18px; | ||
} | ||
`; | ||
export const ErrorCode = styled(motion.div)` | ||
display: flex; | ||
align-items: center; | ||
gap: 6px; | ||
|
||
position: relative; | ||
`; | ||
export const ErrorIcon = styled(motion.div)` | ||
display: flex; | ||
justify-content: center; | ||
position: absolute; | ||
width: 100%; | ||
`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ErrorCode.tsx에서 사용되는 css 코드인 거 같은데 여기에 넣으신 이유가 따로 있으실까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 너무 작은 컴포넌트를 위한 스타일 파일을 별도로 만들어주기 싫고, 그렇다고 한 파일 내에 스타일을 정의해주고 싶지는 않아서 선택한 방식인데, 일관성을 위해 기존의 컨벤션에 맞춰서 파일분리하겠습니다! 오프라인으로 논의한 것처럼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 prettier가 적용이 안 되나요?
ErrorCode에 space가 2칸 더 들어가 있네용~