-
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 #121 from DDD-Community/feature/polaroid-design
폴라로이드 꾸미기 기능 추가
- Loading branch information
Showing
30 changed files
with
498 additions
and
59 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
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.
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
107 changes: 107 additions & 0 deletions
107
src/app/board/[boardId]/_components/CreatePolaroidModal/CreatePolaroid.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,107 @@ | ||
import ArrowBack from '@/app/board/[boardId]/_components/CreatePolaroidModal/ArrowBack' | ||
import PolaroidMaker from '@/components/Polaroid/PolaroidMaker' | ||
import TagButton from '@/components/TagButton' | ||
import { twMerge } from 'tailwind-merge' | ||
import FontSelect from '@/app/board/[boardId]/_components/CreatePolaroidModal/FontSelect' | ||
import UploadBtn from '@/app/board/[boardId]/_components/CreatePolaroidModal/UploadBtn' | ||
import { Dispatch, SetStateAction, useEffect, useRef } from 'react' | ||
import { FontKeyType, ThemaKeyType } from '@/types' | ||
import PolaroidIcon from 'public/icons/polaroid.svg' | ||
|
||
interface CreatePolaroidProps { | ||
image: File | null | ||
selectedFontKey: FontKeyType | ||
selectedThemaKey: ThemaKeyType | ||
message: string | ||
nickname: string | ||
showFontSelect: boolean | ||
isValid: boolean | ||
submit: () => Promise<void> | ||
setImage: Dispatch<SetStateAction<File | null>> | ||
setMessage: Dispatch<SetStateAction<string>> | ||
setNickname: Dispatch<SetStateAction<string>> | ||
setShowFontSelect: Dispatch<SetStateAction<boolean>> | ||
setSelectedFontKey: Dispatch<SetStateAction<FontKeyType>> | ||
setShowThemaSelect: Dispatch<SetStateAction<boolean>> | ||
setIsValid: Dispatch<SetStateAction<boolean>> | ||
} | ||
|
||
const CreatePolaroid = ({ | ||
image, | ||
selectedFontKey, | ||
selectedThemaKey, | ||
message, | ||
nickname, | ||
setImage, | ||
setMessage, | ||
setNickname, | ||
showFontSelect, | ||
setShowFontSelect, | ||
setSelectedFontKey, | ||
setShowThemaSelect, | ||
submit, | ||
isValid, | ||
setIsValid, | ||
}: CreatePolaroidProps) => { | ||
const fontSelectRef = useRef<HTMLDivElement>(null) | ||
|
||
useEffect(() => { | ||
setIsValid(!!image) | ||
}, [image]) | ||
|
||
useEffect(() => { | ||
if (fontSelectRef.current) { | ||
fontSelectRef.current.scrollIntoView() | ||
} | ||
}, [fontSelectRef, showFontSelect]) | ||
|
||
return ( | ||
<div className="relative flex h-dvh w-full max-w-md touch-pan-y flex-col items-center justify-between"> | ||
<ArrowBack /> | ||
<div className="w-full overflow-y-scroll pb-5 pt-16 scrollbar-hide"> | ||
<div className="mx-auto w-[272px]"> | ||
<PolaroidMaker | ||
image={image} | ||
fontKey={selectedFontKey} | ||
themaKey={selectedThemaKey} | ||
message={message} | ||
nickname={nickname} | ||
setImage={setImage} | ||
setMessage={setMessage} | ||
setNickname={setNickname} | ||
/> | ||
<div className="flex gap-5 py-5"> | ||
<TagButton | ||
className={twMerge( | ||
'font-hesom text-md leading-5', | ||
showFontSelect ? 'border-gray-0 bg-gray-800 text-gray-0' : '', | ||
)} | ||
onClick={() => setShowFontSelect((prev) => !prev)} | ||
> | ||
폰트 고르기 | ||
</TagButton> | ||
<TagButton | ||
className="flex gap-2 p-2.5 text-sm leading-4" | ||
onClick={() => setShowThemaSelect((prev) => !prev)} | ||
> | ||
<PolaroidIcon /> | ||
프레임 고르기 | ||
</TagButton> | ||
</div> | ||
</div> | ||
{showFontSelect && ( | ||
<FontSelect | ||
ref={fontSelectRef} | ||
selectedFont={selectedFontKey} | ||
onSelect={setSelectedFontKey} | ||
/> | ||
)} | ||
</div> | ||
<div className="flex w-full justify-center pb-10"> | ||
<UploadBtn submitForm={submit} btnDisabled={!isValid} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default CreatePolaroid |
42 changes: 42 additions & 0 deletions
42
src/app/board/[boardId]/_components/CreatePolaroidModal/FontSelect.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,42 @@ | ||
import { FontKeyType } from '@/types' | ||
import { FONTS } from '@/lib' | ||
import { twMerge } from 'tailwind-merge' | ||
import TagButton from '@/components/TagButton' | ||
import { forwardRef } from 'react' | ||
|
||
interface FontSelectProps { | ||
selectedFont: FontKeyType | ||
onSelect: (fontKey: FontKeyType) => void | ||
} | ||
|
||
const FontSelect = forwardRef<HTMLDivElement, FontSelectProps>( | ||
({ selectedFont, onSelect }, ref) => { | ||
const selectedFontClass = 'bg-gray-0 text-gray-1000 border border-gray-900' | ||
const fontClass = 'text-neutral-500 bg-gray-300 border border-gray-500 ' | ||
return ( | ||
<div className="overflow-x-scroll scrollbar-hide" ref={ref}> | ||
<div className="mx-[calc((100%-272px)/2)] inline-flex items-center gap-2"> | ||
{Object.entries(FONTS).map(([key, font]) => ( | ||
<TagButton | ||
className={twMerge( | ||
'shrink-0', | ||
FONTS[selectedFont].title === font.title | ||
? selectedFontClass | ||
: fontClass, | ||
font.className, | ||
)} | ||
key={key} | ||
onClick={() => onSelect(key as FontKeyType)} | ||
> | ||
{font.title} | ||
</TagButton> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
}, | ||
) | ||
|
||
FontSelect.displayName = 'FontSelect' | ||
|
||
export default FontSelect |
89 changes: 89 additions & 0 deletions
89
src/app/board/[boardId]/_components/CreatePolaroidModal/ThemaSelect.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,89 @@ | ||
import Image from 'next/image' | ||
import { twMerge } from 'tailwind-merge' | ||
import { ThemaKeyType } from '@/types' | ||
import { THEMAS } from '@/lib' | ||
import { useEffect, useState } from 'react' | ||
import Button from '@/components/Button' | ||
import ArrowBackIcon from 'public/icons/arrow_back_ios.svg' | ||
|
||
interface ThemaSelectItemProps { | ||
themaType: ThemaKeyType | ||
isCurrentThema: boolean | ||
setCurrentThema: (thema: ThemaKeyType) => void | ||
} | ||
|
||
const ThemaSelectItem = ({ | ||
themaType, | ||
isCurrentThema, | ||
setCurrentThema, | ||
}: ThemaSelectItemProps) => { | ||
return ( | ||
<div | ||
className={twMerge( | ||
'flex items-center justify-center rounded-lg border-2 bg-gray-700 px-7 py-[22px]', | ||
isCurrentThema ? 'border-gray-100' : 'border-gray-700', | ||
)} | ||
> | ||
<Image | ||
src={`/images/polaroidThemas/${themaType}.png`} | ||
alt="polabo" | ||
width={100} | ||
height={100} | ||
onClick={() => setCurrentThema(themaType)} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
interface ThemaSelectProps { | ||
selectedThema: ThemaKeyType | ||
setSelectedThema: (thema: ThemaKeyType) => void | ||
setShowThemaSelect: (showThemaSelect: boolean) => void | ||
} | ||
|
||
const ThemaSelect = ({ | ||
selectedThema, | ||
setSelectedThema, | ||
setShowThemaSelect, | ||
}: ThemaSelectProps) => { | ||
const [currentThema, setCurrentThema] = useState<ThemaKeyType>(selectedThema) | ||
|
||
useEffect(() => { | ||
setCurrentThema(selectedThema) | ||
}, [selectedThema]) | ||
|
||
const onSelectThema = () => { | ||
setSelectedThema(currentThema) | ||
setShowThemaSelect(false) | ||
} | ||
|
||
return ( | ||
<div className="relative flex h-dvh w-full max-w-md touch-pan-y flex-col items-center justify-between"> | ||
<div className="absolute left-5 top-10"> | ||
<ArrowBackIcon | ||
className="h-6 w-6 text-gray-0" | ||
onClick={() => setShowThemaSelect(false)} | ||
/> | ||
</div> | ||
<div className="mx-12 overflow-y-scroll pb-5 pt-10 scrollbar-hide"> | ||
<div className="grid grid-cols-2 gap-3"> | ||
{Object.entries(THEMAS).map(([key]) => ( | ||
<ThemaSelectItem | ||
key={key} | ||
themaType={key as ThemaKeyType} | ||
isCurrentThema={currentThema === key} | ||
setCurrentThema={setCurrentThema} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
<div className="flex w-full justify-center pb-10"> | ||
<Button size="lg" onClick={onSelectThema}> | ||
선택 완료 | ||
</Button> | ||
</div> | ||
</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
Oops, something went wrong.