-
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.
Merge branch 'develop-client' into feature/CK-211
- Loading branch information
Showing
29 changed files
with
723 additions
and
132 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
client/src/components/_common/privateRouter/PrivateRouter.tsx
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,24 @@ | ||
import { PropsWithChildren, useEffect } from 'react'; | ||
import { useUserInfoContext } from '@components/_providers/UserInfoProvider'; | ||
import useToast from '@hooks/_common/useToast'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { getCookie } from '@utils/_common/cookies'; | ||
|
||
const PrivateRouter = (props: PropsWithChildren) => { | ||
const { children } = props; | ||
const { userInfo } = useUserInfoContext(); | ||
const { triggerToast } = useToast(); | ||
const navigate = useNavigate(); | ||
const accessToken = getCookie('access_token'); | ||
|
||
useEffect(() => { | ||
if (userInfo.id === null && !accessToken) { | ||
navigate('/login'); | ||
triggerToast({ message: '로그인이 필요한 서비스입니다.' }); | ||
} | ||
}, [userInfo.id, navigate]); | ||
|
||
return <>{children}</>; | ||
}; | ||
|
||
export default PrivateRouter; |
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,58 @@ | ||
import media from '@styles/media'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
export const Slider = styled.div` | ||
position: relative; | ||
overflow: hidden; | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
`; | ||
|
||
export const Button = styled.button<{ isHovered: boolean }>` | ||
position: absolute; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 7rem; | ||
height: 12rem; | ||
background-color: rgba(1, 1, 1, 0.2); | ||
border-radius: 8px; | ||
box-shadow: ${({ theme }) => theme.shadows.box}; | ||
${({ isHovered }) => | ||
media.desktop(css` | ||
opacity: ${isHovered ? 1 : 0}; | ||
transition: opacity 0.2s ease; | ||
`)} | ||
`; | ||
|
||
export const PrevButton = styled(Button)<{ isFirstContentIndex: boolean }>` | ||
left: 2rem; | ||
display: ${({ isFirstContentIndex }) => isFirstContentIndex && 'none'}; | ||
`; | ||
|
||
export const NextButton = styled(Button)<{ isLastContentIndex: boolean }>` | ||
right: 2rem; | ||
display: ${({ isLastContentIndex }) => isLastContentIndex && 'none'}; | ||
`; | ||
|
||
export const Contents = styled.article<{ curIndex: number; length: number }>` | ||
transform: ${({ curIndex }) => `translateX(${-curIndex * 100}%)`}; | ||
display: flex; | ||
width: ${({ length }) => `${length * 100}%`}; | ||
transition: transform 0.3s ease; | ||
`; | ||
|
||
export const Content = styled.div` | ||
flex-shrink: 0; | ||
width: 100%; | ||
& > * { | ||
min-height: 12rem; | ||
} | ||
`; |
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,43 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import * as S from './Slider.styles'; | ||
import useHover from '@hooks/_common/useHover'; | ||
import SVGIcon from '@components/icons/SVGIcon'; | ||
import useSlider from '@hooks/_common/useSlider'; | ||
|
||
const Slider = ({ children }: PropsWithChildren) => { | ||
const { | ||
curIndex, | ||
slideToPrevContent, | ||
slideToNextContent, | ||
isFirstContentIndex, | ||
isLastContentIndex, | ||
childrenArray, | ||
} = useSlider(children); | ||
const { isHovered, handleMouseEnter, handleMouseLeave } = useHover(); | ||
|
||
return ( | ||
<S.Slider onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> | ||
<S.Contents curIndex={curIndex} length={childrenArray.length}> | ||
{childrenArray.map((child, index) => ( | ||
<S.Content key={child?.props?.id || index}>{child}</S.Content> | ||
))} | ||
</S.Contents> | ||
<S.PrevButton | ||
onClick={slideToPrevContent} | ||
isHovered={isHovered} | ||
isFirstContentIndex={isFirstContentIndex} | ||
> | ||
<SVGIcon name='LeftIcon' /> | ||
</S.PrevButton> | ||
<S.NextButton | ||
onClick={slideToNextContent} | ||
isHovered={isHovered} | ||
isLastContentIndex={isLastContentIndex} | ||
> | ||
<SVGIcon name='RightIcon' /> | ||
</S.NextButton> | ||
</S.Slider> | ||
); | ||
}; | ||
|
||
export default Slider; |
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
Oops, something went wrong.