-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 헤더 공용컴포넌트 구현 #23
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
The head ref may contain hidden characters: "20250730_#22_\uAE30\uB2A5\uCD94\uAC00_\uACF5\uC6A9\uCEF4\uD3EC\uB10C\uD2B8_\uD5E4\uB354_\uACF5\uC6A9\uCEF4\uD3EC\uB10C\uD2B8"
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { View } from "react-native"; | ||
|
|
||
| export interface HeaderProps { | ||
| left?: React.ReactNode; | ||
| center?: React.ReactNode; | ||
| right?: React.ReactNode; | ||
| } | ||
|
|
||
| export default function CommonHeader({ left, center, right }: HeaderProps) { | ||
| return ( | ||
| <View className="bg-main-color2 rounded-b-[16px] w-full"> | ||
| <View className="flex-row items-center justify-between px-6 h-[56px]"> | ||
| {/* 왼쪽 아이템 */} | ||
| <View className="items-center justify-center">{left ?? <View className="w-6 h-6" />}</View> | ||
|
|
||
| {/* 가운데 아이템 */} | ||
| <View className="flex-1 items-center justify-center mt-2">{center}</View> | ||
|
|
||
| {/* 오른쪽 아이템 */} | ||
| <View className="items-center justify-center">{right ?? <View className="w-6 h-6" />}</View> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export { default as CommonHeader } from "./CommonHeader"; | ||
| export { default as HomeHeader } from "./variants/HomeHeader"; | ||
| export { default as FeedHeader } from "./variants/FeedHeader"; | ||
| export { default as UploadHeader } from "./variants/UploadHeader"; | ||
| export { default as SearchHeader } from "./variants/SearchHeader"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { Pressable, Text } from "react-native"; | ||
| import { Icon } from "@/shared/ui/icon"; | ||
|
|
||
| interface AttendButtonProps { | ||
| onPress?: () => void; | ||
| } | ||
|
|
||
| // Todo: api연결해서 몇 일 연속 출석인지 표시 | ||
| export default function AttendButton({ onPress }: AttendButtonProps) { | ||
| return ( | ||
| <Pressable onPress={onPress} className="mr-4 flex-row items-center"> | ||
| <Icon name="attend" width={24} height={24} /> | ||
| <Text className="text-main-color1 text-sm ml-2">34</Text> | ||
| </Pressable> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Pressable } from "react-native"; | ||
| import { useRouter } from "expo-router"; | ||
| import { Icon } from "@/shared/ui/icon"; | ||
|
|
||
| export default function BackButton() { | ||
| const router = useRouter(); | ||
|
|
||
| return ( | ||
| <Pressable onPress={() => router.back()} hitSlop={8}> | ||
| <Icon name="back" width={24} height={24} /> | ||
| </Pressable> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Icon } from "@/shared/ui/icon"; | ||
|
|
||
| export default function Logo() { | ||
| return <Icon name="logo" width={34} height={34} />; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Pressable } from "react-native"; | ||
| import { Icon } from "@/shared/ui/icon"; | ||
|
|
||
| interface MoreButtonProps { | ||
| onPress?: () => void; | ||
| } | ||
|
|
||
| export default function MoreButton({ onPress }: MoreButtonProps) { | ||
| return ( | ||
| <Pressable onPress={onPress} hitSlop={8}> | ||
| <Icon name="more" width={24} height={24} /> | ||
| </Pressable> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Pressable } from "react-native"; | ||
| import { Icon } from "@/shared/ui/icon"; | ||
|
|
||
| interface SearchButtonProps { | ||
| onPress?: () => void; | ||
| } | ||
|
|
||
| export default function SearchButton({ onPress }: SearchButtonProps) { | ||
| return ( | ||
| <Pressable onPress={onPress} hitSlop={8}> | ||
| <Icon name="search" width={24} height={24} /> | ||
| </Pressable> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { Text, View } from "react-native"; | ||
|
|
||
| interface TodayKeywordProps { | ||
| dateString?: string; | ||
| title: string; | ||
| } | ||
|
|
||
| export default function TodayKeyword({ title, dateString }: TodayKeywordProps) { | ||
| return ( | ||
| <View className="flex-1 items-center"> | ||
| {dateString && <Text className="text-[8px] text-main-color1">{dateString}</Text>} | ||
| <Text className="text-[24px] font-semibold text-main-color1">{title}</Text> | ||
| </View> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||
| import CommonHeader from "../CommonHeader"; | ||||||
| import BackButton from "../items/BackButton"; | ||||||
| import TodayKeyword from "../items/TodayKeyword"; | ||||||
| import MoreButton from "../items/MoreButton"; | ||||||
|
|
||||||
| export default function FeedHeader() { | ||||||
| return ( | ||||||
| <CommonHeader | ||||||
| left={<BackButton />} | ||||||
| center={<TodayKeyword title="피드 테스트" dateString="2025.08.06" />} | ||||||
| right={<MoreButton />} | ||||||
|
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. MoreButton에 onPress 핸들러가 누락되었습니다. MoreButton 컴포넌트는 onPress prop을 필요로 하는데 현재 전달되지 않고 있습니다. - right={<MoreButton />}
+ right={<MoreButton onPress={() => {/* TODO: 더보기 기능 구현 */}} />}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| /> | ||||||
| ); | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import CommonHeader from "../CommonHeader"; | ||
| import Logo from "../items/Logo"; | ||
| import SearchButton from "../items/SearchButton"; | ||
| import AttendButton from "../items/AttendButton"; | ||
| import { View } from "react-native"; | ||
|
|
||
| export default function HomeHeader() { | ||
| return ( | ||
| <CommonHeader | ||
| left={<Logo />} | ||
| center={null} | ||
| right={ | ||
| <View className="flex-row items-center"> | ||
| <AttendButton /> | ||
| <SearchButton /> | ||
| </View> | ||
| } | ||
| /> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||||
| import CommonHeader from "../CommonHeader"; | ||||||||||||||||||||||||
| import BackButton from "../items/BackButton"; | ||||||||||||||||||||||||
| import SearchButton from "../items/SearchButton"; | ||||||||||||||||||||||||
| import TodayKeyword from "../items/TodayKeyword"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export default function SearchHeader() { | ||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||
| <CommonHeader | ||||||||||||||||||||||||
| left={<BackButton />} | ||||||||||||||||||||||||
| //Todo: 검색 페이지 디자인에 따라 UI 수정 + api 연결 | ||||||||||||||||||||||||
| center={<TodayKeyword title="검색 테스트" />} | ||||||||||||||||||||||||
|
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. 🛠️ Refactor suggestion 하드코딩된 테스트 데이터를 개선해주세요. "검색 테스트"가 하드코딩되어 있습니다. props를 통해 동적으로 전달받거나 적절한 기본값을 사용하는 것이 좋겠습니다. -export default function SearchHeader() {
+export default function SearchHeader({ title }: { title?: string }) {
return (
<CommonHeader
left={<BackButton />}
//Todo: 검색 페이지 디자인에 따라 UI 수정 + api 연결
- center={<TodayKeyword title="검색 테스트" />}
+ center={<TodayKeyword title={title || "검색"} />}
right={<SearchButton />}
/>
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| right={<SearchButton />} | ||||||||||||||||||||||||
|
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. SearchButton에 onPress 핸들러가 누락되었습니다. SearchButton 컴포넌트는 onPress prop을 필요로 합니다. - right={<SearchButton />}
+ right={<SearchButton onPress={() => {/* TODO: 검색 기능 구현 */}} />}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||
| import CommonHeader from "../CommonHeader"; | ||||||||||||||||||||||||||||||
| import BackButton from "../items/BackButton"; | ||||||||||||||||||||||||||||||
| import TodayKeyword from "../items/TodayKeyword"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export default function UploadHeader() { | ||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <CommonHeader | ||||||||||||||||||||||||||||||
| left={<BackButton />} | ||||||||||||||||||||||||||||||
| center={<TodayKeyword title="고양이" dateString="2025.08.06" />} | ||||||||||||||||||||||||||||||
|
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. 하드코딩된 값들을 동적으로 변경해야 합니다. TodayKeyword의 title="고양이"와 dateString="2025.08.06"이 하드코딩되어 있습니다. 이는 테스트 값으로 보이며, 실제 업로드 컨텍스트나 현재 날짜를 기반으로 동적으로 설정되어야 합니다. 다음과 같이 수정을 고려해보세요: -export default function UploadHeader() {
+interface UploadHeaderProps {
+ title: string;
+ dateString?: string;
+}
+
+export default function UploadHeader({ title, dateString }: UploadHeaderProps) {
return (
<CommonHeader
left={<BackButton />}
- center={<TodayKeyword title="고양이" dateString="2025.08.06" />}
+ center={<TodayKeyword title={title} dateString={dateString} />}
/>
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
하드코딩된 테스트 데이터를 동적 데이터로 교체해주세요.
현재 "피드 테스트"와 "2025.08.06" 값이 하드코딩되어 있습니다. 실제 데이터나 props를 통해 전달받도록 개선이 필요합니다.
📝 Committable suggestion
🤖 Prompt for AI Agents