-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: 메인페이지 레이아웃을 구현합니다 #114
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e821f11
feat: add ghost style to button component
hyjoong f22e68c
feat: postcss.config 파일 추가
hyjoong 3c9114a
feat: basic layout for navbar component
hyjoong 7b23ac3
chore: install next-themes
hyjoong 513cdef
feat: badge component 구현
hyjoong 885d1c8
refactor: button component export 방식 수정
hyjoong 2a84be9
style: add icon size variant to button.styles.ts
hyjoong b957a07
feat: tagList component 구현
hyjoong 6a0ce22
feat: dropdown component 구현
hyjoong 9617654
feat: dark mode provider
hyjoong f6c94f1
feat: toggle enable control dark mode switching
hyjoong 4fc91a2
feat: add theme toggle button to the navbar
hyjoong bdfda4a
feat: navbar storybook
hyjoong fe9351a
feat: add temporary variables to constants
hyjoong a8fc9e9
feat: postcard component 구현
hyjoong ccb198f
chore: install @radix-ui/react-dropdown-menu
hyjoong bc46c18
feat: themeProvider for darkmode in the layout
hyjoong 20a3a5e
style: globals.css 에 css 속성 추가
hyjoong 2ce1247
feat: postCardList component layout 구현
hyjoong e88cfbc
feat: root page imported postCardList, TagList
hyjoong 3f148f9
feat: TEMP_TAGS 변수 constants 폴더로 이동 및 적용
hyjoong 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
Large diffs are not rendered by default.
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,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import React from 'react'; | ||
import { PostCardList } from '@/components/home/PostCardList'; | ||
import { TagList } from '@/components/home/TagList'; | ||
import { TEMP_TAGS } from '@/constants'; | ||
|
||
const RootPage = () => { | ||
return <div>RootPage</div>; | ||
return ( | ||
<div> | ||
<div className="flex"> | ||
<PostCardList /> | ||
<TagList tags={TEMP_TAGS} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RootPage; |
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,21 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { PostCard } from '.'; | ||
import { PostCardList } from '../PostCardList'; | ||
|
||
const sotryMeta: Meta = { | ||
title: 'components/home/Postcard', | ||
component: PostCard, | ||
parameters: { | ||
nextjs: { | ||
appDirectory: true, | ||
}, | ||
}, | ||
}; | ||
|
||
export default sotryMeta; | ||
|
||
type Story = StoryObj<typeof PostCardList>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; |
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,29 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
import { Badge } from '@/components/ui/Badge/Badge'; | ||
// import Image from 'next/image'; | ||
import { PostCardProps } from './PostCard.type'; | ||
import { TEMP_CONTENT } from '@/constants'; | ||
|
||
export const PostCard = ({ post }: PostCardProps) => { | ||
const { title, content } = post; | ||
return ( | ||
<div className="flex items-center h-[200px] gap-[50px]"> | ||
{/* <Image /> */} | ||
<div className="min-w-[200px] min-h-[200px] bg-slate-500"></div> | ||
<div className="flex-col"> | ||
<div className="flex items-center"> | ||
<span className="text-sm text-gray-400 mr-2">January 20th</span> | ||
<Badge variant="outline">tag</Badge> | ||
</div> | ||
<Link href="/post/1"> | ||
<p className="text-2xl mb-2">{title}</p> | ||
<span className="text-gray-300"> | ||
{content} | ||
{TEMP_CONTENT} | ||
</span> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,6 @@ | ||
export interface PostCardProps { | ||
post: { | ||
title: string; | ||
content: string; | ||
}; | ||
} |
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 @@ | ||
export * from './PostCard'; |
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,15 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { TEMP_POSTS } from '@/constants'; | ||
import { PostCard } from '../PostCard'; | ||
|
||
export const PostCardList = () => { | ||
return ( | ||
<div className="space-y-20"> | ||
{TEMP_POSTS.map((post, index) => ( | ||
<PostCard key={index} post={post} /> | ||
))} | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export * from './PostCardList'; |
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,17 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { TagList } from '.'; | ||
import { TEMP_TAGS } from '@/constants'; | ||
|
||
const sotryMeta: Meta = { | ||
title: 'components/home/TagList', | ||
component: TagList, | ||
}; | ||
export default sotryMeta; | ||
|
||
type Story = StoryObj<typeof TagList>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
tags: TEMP_TAGS, | ||
}, | ||
}; |
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,18 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { Badge } from '@/components/ui/Badge/Badge'; | ||
import { TagListProps } from './TagList.type'; | ||
|
||
export const TagList = ({ tags }: TagListProps) => { | ||
return ( | ||
<div className="w-[400px] py-2"> | ||
<p className="text-xl font-bold mb-3">Popular Tags</p> | ||
{tags?.map((tag, index) => ( | ||
<Badge key={index} variant="outline" className="mr-1"> | ||
{tag} | ||
</Badge> | ||
))} | ||
</div> | ||
); | ||
}; |
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,3 @@ | ||
export interface TagListProps { | ||
tags: string[]; // TODO: tag값 union type으로 변경 | ||
} | ||
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 @@ | ||
export * from './TagList'; |
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,20 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Navbar } from '.'; | ||
|
||
const sotryMeta: Meta = { | ||
title: 'components/layout/Navbar', | ||
component: Navbar, | ||
parameters: { | ||
nextjs: { | ||
appDirectory: true, | ||
}, | ||
}, | ||
}; | ||
|
||
export default sotryMeta; | ||
|
||
type Story = StoryObj<typeof Navbar>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; |
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,32 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import { useRouter } from 'next/navigation'; | ||
import { Button } from '@/components/ui/Button/Button'; | ||
import { ModeToggle } from '@/components/theme/ThemeToggle'; | ||
|
||
export const Navbar = () => { | ||
const router = useRouter(); | ||
const [isLogin, setIsLogin] = useState(false); | ||
|
||
const handleButtonClick = () => { | ||
if (isLogin) { | ||
setIsLogin(false); | ||
} else { | ||
router.push('/sign-in'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="flex justify-between items-center h-[100px] py-4"> | ||
<p>Logo</p> | ||
<p className="text-4xl font-bold">Henlog</p> | ||
<div className="flex"> | ||
<Button variant="ghost" onClick={handleButtonClick}> | ||
{isLogin ? 'Logout' : 'Sign in'} | ||
</Button> | ||
<ModeToggle /> | ||
</div> | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export * from './Navbar'; |
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,9 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { ThemeProvider as NextThemesProvider } from 'next-themes'; | ||
import { type ThemeProviderProps } from 'next-themes/dist/types'; | ||
|
||
export const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => { | ||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>; | ||
}; |
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,40 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { Moon, Sun } from 'lucide-react'; | ||
import { useTheme } from 'next-themes'; | ||
Comment on lines
+4
to
+5
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. 오.. 라이브러리를 잘 쓰지 않는편이다 보니 처음 보는 라이브러리들인데 좋은것들 알아갑니다~! |
||
|
||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from '../ui/Dropdown/DropdownMenu'; | ||
import { Button } from '../ui/Button'; | ||
|
||
export function ModeToggle() { | ||
const { setTheme } = useTheme(); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="outline" size="icon"> | ||
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> | ||
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> | ||
<span className="sr-only">Toggle theme</span> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuItem onClick={() => setTheme('light')}> | ||
Light | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => setTheme('dark')}> | ||
Dark | ||
</DropdownMenuItem> | ||
<DropdownMenuItem onClick={() => setTheme('system')}> | ||
System | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
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,47 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Badge } from './Badge'; | ||
|
||
const sotryMeta: Meta = { | ||
title: 'components/ui/Badge', | ||
component: Badge, | ||
argTypes: { | ||
variant: { | ||
control: { | ||
type: 'select', | ||
options: ['default', 'secondary', 'destructive', 'outline'], | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default sotryMeta; | ||
|
||
type Story = StoryObj<typeof Badge>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: 'Badge', | ||
variant: 'default', | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
children: 'Badge', | ||
variant: 'secondary', | ||
}, | ||
}; | ||
|
||
export const Destructive: Story = { | ||
args: { | ||
children: 'Badge', | ||
variant: 'destructive', | ||
}, | ||
}; | ||
|
||
export const Outline: Story = { | ||
args: { | ||
children: 'Badge', | ||
variant: 'outline', | ||
}, | ||
}; |
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,21 @@ | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
||
export const badgeVariants = cva( | ||
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80', | ||
secondary: | ||
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', | ||
destructive: | ||
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80', | ||
outline: 'text-foreground', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
}, | ||
}, | ||
); |
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,13 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
import { badgeVariants } from './Badge.styles'; | ||
import { BadgeProps } from './Badge.type'; | ||
|
||
function Badge({ className, variant, ...props }: BadgeProps) { | ||
return ( | ||
<div className={cn(badgeVariants({ variant }), className)} {...props} /> | ||
); | ||
} | ||
|
||
export { Badge, badgeVariants }; |
Oops, something went wrong.
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.
props 타입을 밖으로 빼시는군요!
뭔가 재사용 되지 않을 타입이라 view에 들어있는걸 선호하는데 다른 분들 생각이 궁금하네요.
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.
네, 기존에 스타일 및 타입 파일은 항상 별도로 분리하는 컨벤션으로 작업했었는데, 헌진님이 말씀하신 것 처럼 재사용되지 않는 타입 파일들은 따로 분리하지 않고, 재사용되는 타입일 경우에만 분리하는 방식도 좋아보이네요. 이 부분은 리펙토링할 때 참고해보겠습니다! 감사합니다