-
Notifications
You must be signed in to change notification settings - Fork 4
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
레이아웃 컴포넌트 구현 #87
Merged
레이아웃 컴포넌트 구현 #87
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,86 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Category } from '@type/category'; | ||
import type { User } from '@type/user'; | ||
|
||
import Skeleton from '../Skeleton'; | ||
|
||
import Layout from '.'; | ||
|
||
const meta: Meta<typeof Layout> = { | ||
component: Layout, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Layout>; | ||
|
||
const MOCK_USER_INFO: User = { | ||
nickname: '우아한 코끼리', | ||
postCount: 4, | ||
voteCount: 128, | ||
userPoint: 200, | ||
}; | ||
|
||
const MOCK_FAVORITE_CATEGORIES: Category[] = [ | ||
{ id: 12312, name: '음식', isFavorite: false }, | ||
{ id: 12, name: '연애', isFavorite: true }, | ||
{ id: 13, name: '패션', isFavorite: true }, | ||
{ id: 14, name: '금융', isFavorite: false }, | ||
{ id: 12312, name: '음식', isFavorite: false }, | ||
{ id: 12, name: '연애', isFavorite: true }, | ||
{ id: 13, name: '패션', isFavorite: true }, | ||
{ id: 14, name: '금융', isFavorite: false }, | ||
{ id: 12312, name: '음식', isFavorite: false }, | ||
{ id: 12, name: '연애', isFavorite: true }, | ||
{ id: 13, name: '패션', isFavorite: true }, | ||
{ id: 14, name: '금융', isFavorite: false }, | ||
{ id: 12312, name: '음식', isFavorite: false }, | ||
{ id: 12, name: '연애', isFavorite: true }, | ||
{ id: 13, name: '패션', isFavorite: true }, | ||
{ id: 14, name: '금융', isFavorite: false }, | ||
]; | ||
|
||
export const VisibleCategory: Story = { | ||
render: () => ( | ||
<Layout | ||
isSidebarVisible={true} | ||
userInfo={MOCK_USER_INFO} | ||
categoryList={MOCK_FAVORITE_CATEGORIES} | ||
handleFavoriteClick={() => {}} | ||
handleLogoutClick={() => {}} | ||
> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
</Layout> | ||
), | ||
}; | ||
|
||
export const HiddenCategory: Story = { | ||
render: () => ( | ||
<Layout | ||
isSidebarVisible={false} | ||
categoryList={MOCK_FAVORITE_CATEGORIES} | ||
handleFavoriteClick={() => {}} | ||
handleLogoutClick={() => {}} | ||
> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
<Skeleton /> | ||
</Layout> | ||
), | ||
}; |
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,52 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
|
||
import type { Category } from '@type/category'; | ||
import type { User } from '@type/user'; | ||
|
||
import Dashboard from '@components/common/Dashboard'; | ||
import WideHeader from '@components/common/WideHeader'; | ||
|
||
import * as S from './style'; | ||
|
||
interface LayoutProps extends PropsWithChildren { | ||
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. 👍👍 |
||
userInfo?: User; | ||
categoryList: Category[]; | ||
selectedCategory?: string; | ||
isSidebarVisible: boolean; | ||
handleFavoriteClick: (categoryId: number) => void; | ||
handleLogoutClick: () => void; | ||
} | ||
|
||
export default function Layout({ | ||
userInfo, | ||
categoryList, | ||
selectedCategory, | ||
isSidebarVisible, | ||
handleFavoriteClick, | ||
handleLogoutClick, | ||
children, | ||
}: LayoutProps) { | ||
return ( | ||
<S.Container> | ||
<S.WideHeaderWrapper> | ||
<WideHeader /> | ||
</S.WideHeaderWrapper> | ||
<S.ContentContainer> | ||
{isSidebarVisible && ( | ||
<S.DashboardWrapper> | ||
<Dashboard | ||
userInfo={userInfo} | ||
categoryList={categoryList} | ||
selectedCategory={selectedCategory} | ||
handleFavoriteClick={handleFavoriteClick} | ||
handleLogoutClick={handleLogoutClick} | ||
/> | ||
</S.DashboardWrapper> | ||
)} | ||
<S.MainContainer $isSidebarVisible={isSidebarVisible}> | ||
<S.ChildrenWrapper $isSidebarVisible={isSidebarVisible}>{children}</S.ChildrenWrapper> | ||
</S.MainContainer> | ||
</S.ContentContainer> | ||
</S.Container> | ||
); | ||
} |
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,55 @@ | ||
import { styled } from 'styled-components'; | ||
|
||
import { theme } from '@styles/theme'; | ||
|
||
export const Container = styled.div` | ||
height: 100vh; | ||
`; | ||
|
||
export const ContentContainer = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
|
||
@media (min-width: ${theme.breakpoint.sm}) { | ||
padding-top: 70px; | ||
} | ||
`; | ||
|
||
export const WideHeaderWrapper = styled.div` | ||
width: 100%; | ||
|
||
position: fixed; | ||
top: 0; | ||
|
||
@media (max-width: ${theme.breakpoint.sm}) { | ||
display: none; | ||
visibility: hidden; | ||
} | ||
`; | ||
|
||
export const DashboardWrapper = styled.aside` | ||
height: 90vh; | ||
|
||
position: fixed; | ||
left: 0; | ||
|
||
@media (max-width: ${theme.breakpoint.sm}) { | ||
display: none; | ||
visibility: hidden; | ||
} | ||
`; | ||
|
||
export const MainContainer = styled.main<{ $isSidebarVisible: boolean }>` | ||
display: flex; | ||
justify-content: center; | ||
|
||
width: 100%; | ||
@media (min-width: ${theme.breakpoint.sm}) { | ||
padding-left: ${({ $isSidebarVisible }) => $isSidebarVisible && '225px'}; | ||
} | ||
`; | ||
|
||
export const ChildrenWrapper = styled.div<{ $isSidebarVisible: boolean }>` | ||
width: 100%; | ||
max-width: ${({ $isSidebarVisible }) => $isSidebarVisible && '500px'}; | ||
`; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
예전에 스켈레톤 UI 구현 pr 에서 코멘트로 남겼던 사항인데, 지속시간이 짧은 맥박 효과 애니메이션을 사용하신 이유가 궁금해요~~~
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.
블로그 참고한 곳이 웨이브 효과인줄 알았으나 맥박이였네요! 이슈를 생성해서 따로 수정해보겠습니다~ 맥박 효과를 사용한 이유는 없어요! 😱
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.
이슈 생성했습니다~
#91
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.
좋아요~~~