-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[theme-market] 검색/ 베스트 리스트 뷰 추가 (#199)
- Loading branch information
Showing
33 changed files
with
436 additions
and
74 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
2 changes: 1 addition & 1 deletion
2
apps/theme-market/src/app/(routes)/(main)/(bottomsheet)/index.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
5 changes: 5 additions & 0 deletions
5
apps/theme-market/src/app/(routes)/(main)/download/best/page.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,5 @@ | ||
import { BestPage } from "@/app/_pages/Main/ThemeDownload/Best"; | ||
|
||
export default async function DownloadBestPageRoute() { | ||
return <BestPage />; | ||
} |
10 changes: 10 additions & 0 deletions
10
apps/theme-market/src/app/(routes)/(main)/search/[query]/page.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,10 @@ | ||
import { SearchPage } from "@/app/_pages/Search"; | ||
|
||
interface Props { | ||
params: Promise<{ query: string }>; | ||
} | ||
|
||
export default async function SearchPageRoute({ params }: Props) { | ||
const query = decodeURIComponent((await params).query); | ||
return <SearchPage query={query} />; | ||
} |
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,11 +1,30 @@ | ||
import { InputHTMLAttributes } from "react"; | ||
"use client"; | ||
|
||
import { InputHTMLAttributes, useState } from "react"; | ||
import styles from "./index.module.css"; | ||
import classNames from "classnames"; | ||
|
||
interface Props extends InputHTMLAttributes<HTMLInputElement> {} | ||
interface Props extends InputHTMLAttributes<HTMLInputElement> { | ||
onComplete?: (value: string) => void; | ||
} | ||
|
||
export const Input = ({ | ||
onComplete, | ||
className, | ||
defaultValue, | ||
...props | ||
}: Props) => { | ||
const [value, setValue] = useState<string>((defaultValue || "").toString()); | ||
|
||
export const Input = (props: Props) => { | ||
return ( | ||
<input {...props} className={classNames(props.className, styles.input)} /> | ||
<input | ||
{...props} | ||
className={classNames(className, styles.input)} | ||
value={value} | ||
onKeyDown={(e) => { | ||
if (e.key === "Enter") onComplete?.(value); | ||
}} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
apps/theme-market/src/app/_components/Theme/List/ThemeInfoList.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,19 @@ | ||
"use client"; | ||
|
||
import { ThemeInfo } from "@/app/_components/Theme/Info"; | ||
import { Theme } from "@/entities/Theme"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
interface Props { | ||
themes: Theme[]; | ||
} | ||
export const ThemeInfoList = ({ themes }: Props) => { | ||
return ( | ||
<div className={styles.wrapper}> | ||
{themes.map((theme) => { | ||
return <ThemeInfo key={theme.id} theme={theme} />; | ||
})} | ||
</div> | ||
); | ||
}; |
51 changes: 51 additions & 0 deletions
51
apps/theme-market/src/app/_components/Theme/List/ThemeListWithInfiniteScroll.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,51 @@ | ||
"use client"; | ||
|
||
import { useCallback, useEffect, useState } from "react"; | ||
import { useInView } from "react-intersection-observer"; | ||
|
||
import { ThemeInfo } from "@/app/_components/Theme/Info"; | ||
import { useUserStore } from "@/app/_providers/UserProvider"; | ||
import { themeService } from "@/services/ThemeService"; | ||
import { Theme } from "@/entities/Theme"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
interface Props { | ||
defaultThemes: Theme[]; | ||
} | ||
|
||
const DEFAULT_PAGE = 2; | ||
|
||
export const ThemeListWithInifiniteScorll = ({ defaultThemes }: Props) => { | ||
const [themes, setThemes] = useState<Theme[]>(defaultThemes); | ||
const [page, setPage] = useState<number>(DEFAULT_PAGE); | ||
|
||
const { ref, inView } = useInView(); | ||
|
||
const { accessToken } = useUserStore((state) => state); | ||
|
||
const loadThemes = useCallback(async () => { | ||
const { content: themes } = await themeService.getBestThemes( | ||
page, | ||
accessToken | ||
); | ||
|
||
setThemes((prev) => [...prev, ...themes]); | ||
setPage((prev) => prev + 1); | ||
}, [accessToken, page]); | ||
|
||
useEffect(() => { | ||
if (inView) loadThemes(); | ||
}, [inView, loadThemes]); | ||
|
||
return ( | ||
<> | ||
<div className={styles.wrapper}> | ||
{themes.map((theme) => { | ||
return <ThemeInfo key={theme.id} theme={theme} />; | ||
})} | ||
</div> | ||
<div ref={ref} /> | ||
</> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
apps/theme-market/src/app/_components/Theme/List/index.module.css
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,5 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...es/Main/BottomSheet/ThemeDetail/index.tsx → .../_pages/BottomSheet/ThemeDetail/index.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
45 changes: 45 additions & 0 deletions
45
apps/theme-market/src/app/_pages/Main/Header/MainHeader.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,45 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import { MENU } from "@/entities/Menu"; | ||
|
||
import { TabContent } from "@/app/_components/Tab/TabContent"; | ||
import { Tab } from "@/app/_components/Tab"; | ||
import { Input } from "@/app/_components/Input"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
interface Props { | ||
menu: MENU; | ||
} | ||
|
||
export const MainHeader = ({ menu }: Props) => { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<section className={styles.header}> | ||
<div className={styles.inputWrapper}> | ||
<Input | ||
className={styles.input} | ||
placeholder="테마를 검색해보세요" | ||
type="search" | ||
onComplete={(value: String) => router.push(`/search/${value}`)} | ||
/> | ||
</div> | ||
<Tab> | ||
<TabContent selected={menu === "DOWNLOAD"}> | ||
<Link href="/download" replace> | ||
테마 다운로드 | ||
</Link> | ||
</TabContent> | ||
<TabContent selected={menu === "MY_THEME"}> | ||
<Link href="/my" replace> | ||
내 테마 올리기 | ||
</Link> | ||
</TabContent> | ||
</Tab> | ||
</section> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
apps/theme-market/src/app/_pages/Main/Header/index.module.css
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 @@ | ||
.header { | ||
background-color: var(--color-bg-default); | ||
} | ||
|
||
.inputWrapper { | ||
width: 100%; | ||
height: 80px; | ||
|
||
padding: 20px 18.5px; | ||
} | ||
|
||
.input { | ||
width: 100%; | ||
height: 40px; | ||
|
||
padding-left: 40px; | ||
|
||
background-image: url("/static/icons/svgSearch.svg"); | ||
background-position: 7px 7px; | ||
background-repeat: no-repeat; | ||
} |
25 changes: 25 additions & 0 deletions
25
apps/theme-market/src/app/_pages/Main/ThemeDownload/Best/index.module.css
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,25 @@ | ||
.main { | ||
padding: 17px 18px 0; | ||
} | ||
|
||
.prev { | ||
padding-left: 3px; | ||
|
||
display: flex; | ||
flex-direction: row; | ||
|
||
height: 14px; | ||
font-size: 13px; | ||
font-weight: 400; | ||
line-height: 12.6px; | ||
|
||
color: var(--palette-gray-2); | ||
} | ||
|
||
.themes { | ||
margin-top: 12px; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} |
34 changes: 34 additions & 0 deletions
34
apps/theme-market/src/app/_pages/Main/ThemeDownload/Best/index.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,34 @@ | ||
import Image from "next/image"; | ||
|
||
import { cookieService } from "@/services/CookieService"; | ||
import { MainHeader } from "@/app/_pages/Main/Header/MainHeader"; | ||
import { themeService } from "@/services/ThemeService"; | ||
import SvgChevronLeft from "@/assets/icons/svgChevronLeft.svg"; | ||
|
||
import styles from "./index.module.css"; | ||
import { DEFAULT_PAGE } from "@/repositories/ThemeRepository"; | ||
import { ThemeListWithInifiniteScorll } from "@/app/_components/Theme/List/ThemeListWithInfiniteScroll"; | ||
import Link from "next/link"; | ||
|
||
export const BestPage = async () => { | ||
const accessToken = cookieService.getAccessToken(); | ||
const { content: themes } = await themeService.getBestThemes( | ||
DEFAULT_PAGE, | ||
accessToken | ||
); | ||
|
||
return ( | ||
<> | ||
<MainHeader menu="DOWNLOAD" /> | ||
<section className={styles.main}> | ||
<Link className={styles.prev} href="/download"> | ||
<Image src={SvgChevronLeft} alt="<" width="16" height="16.6" /> | ||
<span>돌아가기</span> | ||
</Link> | ||
<div className={styles.themes}> | ||
<ThemeListWithInifiniteScorll defaultThemes={themes} /> | ||
</div> | ||
</section> | ||
</> | ||
); | ||
}; |
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,25 +1,3 @@ | ||
.header { | ||
background-color: var(--color-bg-default); | ||
} | ||
|
||
.inputWrapper { | ||
width: 100%; | ||
height: 80px; | ||
|
||
padding: 20px 18.5px; | ||
} | ||
|
||
.input { | ||
width: 100%; | ||
height: 40px; | ||
|
||
padding-left: 40px; | ||
|
||
background-image: url("/static/icons/svgSearch.svg"); | ||
background-position: 7px 7px; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
.main { | ||
padding: 17px 18px 0; | ||
padding: 21px 18px 0; | ||
} |
Oops, something went wrong.