-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from DDD-Community/feature/134
[FEATURE] 보드 테마 선택, 투명 헤더
- Loading branch information
Showing
12 changed files
with
182 additions
and
23 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
'use client' | ||
|
||
import Button from '@/components/Button' | ||
import { BOARDTHEMAS } from '@/lib/constants/boardConfig' | ||
import { BoardThemaKeyType } from '@/types' | ||
import Image from 'next/image' | ||
import CheckIcon from 'public/icons/check.svg' | ||
import { useState } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
interface ThemaSelectItemProps { | ||
themaType: BoardThemaKeyType | ||
isCurrentThema: boolean | ||
setCurrentThema: (thema: BoardThemaKeyType) => void | ||
} | ||
|
||
const ThemaSelectItem = ({ | ||
themaType, | ||
isCurrentThema, | ||
setCurrentThema, | ||
}: ThemaSelectItemProps) => ( | ||
<div | ||
className={twMerge( | ||
'relative flex flex-col items-center justify-center gap-2.5', | ||
)} | ||
> | ||
{isCurrentThema && ( | ||
<CheckIcon className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[calc(50%+15px)] scale-[3] text-gray-950" /> | ||
)} | ||
|
||
<div | ||
className={twMerge( | ||
'h-[178px] w-[140px] max-w-full overflow-hidden rounded-lg border-2', | ||
isCurrentThema ? 'border-gray-950' : 'border-gray-300', | ||
)} | ||
> | ||
<Image | ||
src={`/images/boardThemas/${themaType}.png`} | ||
alt="polabo" | ||
width={140} | ||
height={178} | ||
onClick={() => setCurrentThema(themaType)} | ||
objectFit="contain" | ||
/> | ||
</div> | ||
<span | ||
className={twMerge( | ||
'text-md font-semiBold', | ||
isCurrentThema ? 'text-gray-950' : 'text-gray-400', | ||
)} | ||
> | ||
{BOARDTHEMAS[themaType].title} | ||
</span> | ||
</div> | ||
) | ||
|
||
interface ThemaSelectProps { | ||
boardName: string | ||
createBoard: (boardName: string, boardThema: BoardThemaKeyType) => void | ||
} | ||
|
||
const ThemaSelect = ({ createBoard, boardName }: ThemaSelectProps) => { | ||
const [currentThema, setCurrentThema] = useState<BoardThemaKeyType>('B-0') | ||
|
||
return ( | ||
<div className="flex h-[calc(100%-64px)] flex-col"> | ||
<div className="grid h-full auto-rows-min grid-cols-2 gap-2.5 overflow-y-scroll px-4 pt-3"> | ||
{Object.entries(BOARDTHEMAS).map(([key]) => ( | ||
<ThemaSelectItem | ||
key={key} | ||
themaType={key as BoardThemaKeyType} | ||
isCurrentThema={currentThema === key} | ||
setCurrentThema={setCurrentThema} | ||
/> | ||
))} | ||
</div> | ||
<Button | ||
size="lg" | ||
className="mx-auto mb-12" | ||
onClick={() => createBoard(boardName, currentThema)} | ||
> | ||
완료 | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
export default ThemaSelect |
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,48 @@ | ||
import Header from '@/components/Header' | ||
import { postBoard } from '@/lib' | ||
import { revalidateTag } from 'next/cache' | ||
import { redirect } from 'next/navigation' | ||
import { BoardThemaKeyType } from '@/types' | ||
import ThemaSelect from './_components/ThemaSelect' | ||
|
||
interface PageProps { | ||
searchParams: { | ||
title: string | ||
} | ||
} | ||
|
||
const CreateBoardThemePage = ({ searchParams }: PageProps) => { | ||
const { title } = searchParams | ||
|
||
const createBoard = async ( | ||
boardName: string, | ||
boardThema: BoardThemaKeyType, | ||
) => { | ||
'use server' | ||
|
||
const boardId = await postBoard({ | ||
title: boardName, | ||
userId: null, | ||
options: { | ||
THEMA: boardThema, | ||
}, | ||
}) | ||
|
||
revalidateTag('myBoard') | ||
|
||
redirect(`/board/${boardId}`) | ||
} | ||
|
||
return ( | ||
<div className="h-dvh"> | ||
<Header | ||
title="보드 테마를 선택해주세요!" | ||
leftButton={<Header.BackButton />} | ||
shadow={false} | ||
/> | ||
<ThemaSelect createBoard={createBoard} boardName={title} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default CreateBoardThemePage |
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,14 @@ | ||
export const BOARDTHEMAS = { | ||
'B-0': { | ||
title: '기본 테마', | ||
}, | ||
'B-1': { | ||
title: '밝은 테마', | ||
}, | ||
'B-2': { | ||
title: '수능 테마', | ||
}, | ||
'B-3': { | ||
title: '코르크판 테마', | ||
}, | ||
} |
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