-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 프로필 수정 모달 UI 제작 #112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1bcd081
fix: modal padding 수정
Chiman2937 d05285d
feat: 프로필 수정 모달 UI 작업 완료
Chiman2937 0eb3281
fix: 모임 모달 스타일 수정(padding 등)
Chiman2937 021aa38
Merge branch 'main' of https://github.com/WeGo-Together/WeGo_FrontEnd…
Chiman2937 09827d1
fix: 프로필 수정 모달 max-w 지정
Chiman2937 1e9f810
Merge branch 'main' of https://github.com/WeGo-Together/WeGo_FrontEnd…
Chiman2937 506cdb7
Merge branch 'main' of https://github.com/WeGo-Together/WeGo_FrontEnd…
Chiman2937 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 hidden or 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 hidden or 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,6 +1,7 @@ | ||
| export { ProfileCard } from './profile-card'; | ||
| export { ProfileDescription } from './profile-description'; | ||
| export { ProfileDescriptionBadge } from './profile-description-badge'; | ||
| export { ProfileEditModal } from './profile-edit-modal'; | ||
| export { ProfileFollowsBadge } from './profile-follows-badge'; | ||
| export { ProfileInfo } from './profile-info'; | ||
| export { ProfileSetting } from './profile-setting'; |
56 changes: 56 additions & 0 deletions
56
src/components/pages/profile/profile-edit-fields/image-field/index.tsx
This file contains hidden or 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,56 @@ | ||
| import Image from 'next/image'; | ||
|
|
||
| import { AnyFieldApi } from '@tanstack/react-form'; | ||
|
|
||
| import { Icon } from '@/components/icon'; | ||
| import { ImageInput, ImageInputProps } from '@/components/ui'; | ||
| import { cn } from '@/lib/utils'; | ||
|
|
||
| type ImageUploadPropsWithoutChildren = Omit<ImageInputProps, 'children'>; | ||
|
|
||
| interface Props extends ImageUploadPropsWithoutChildren { | ||
| field: AnyFieldApi; | ||
| } | ||
| const ImageField = ({ field, initialImages }: Props) => { | ||
| return ( | ||
| <div className='flex-center py-6'> | ||
| <ImageInput | ||
| accept='image/*' | ||
| initialImages={initialImages} | ||
| maxFiles={1} | ||
| mode='replace' | ||
| multiple={false} | ||
| value={field.state.value} | ||
| onChange={field.handleChange} | ||
| > | ||
| {(images, _onRemoveImageClick, onFileSelectClick) => ( | ||
| <> | ||
| {Object.entries(images).map(([url, _file]) => ( | ||
| <div key={url} className='relative aspect-square size-24'> | ||
| <Image | ||
| className='rounded-full border-1 border-[rgba(0,0,0,0.04)]' | ||
| alt='프로필 이미지' | ||
| fill | ||
| src={url} | ||
| /> | ||
| <button | ||
| className={cn( | ||
| 'flex-center absolute -right-1.75 bottom-0 size-8 cursor-pointer rounded-full border-1 border-gray-300 bg-gray-100', | ||
| 'hover:scale-110 hover:bg-gray-200', | ||
| 'transition-all duration-300', | ||
| )} | ||
| type='button' | ||
| onClick={onFileSelectClick} | ||
| > | ||
| <Icon id='edit' className='size-5 text-gray-600' /> | ||
| </button> | ||
| </div> | ||
| ))} | ||
| </> | ||
| )} | ||
| </ImageInput> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ImageField; | ||
26 changes: 26 additions & 0 deletions
26
src/components/pages/profile/profile-edit-fields/mbti-field/index.tsx
This file contains hidden or 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,26 @@ | ||
| import { AnyFieldApi } from '@tanstack/react-form'; | ||
|
|
||
| import { Input, Label } from '@/components/ui'; | ||
|
|
||
| interface Props { | ||
| field: AnyFieldApi; | ||
| } | ||
|
|
||
| export const MBTIField = ({ field }: Props) => { | ||
| return ( | ||
| <div className='mt-3 flex w-full flex-col gap-1'> | ||
| <Label htmlFor='post-meetup-title' required> | ||
| MBTI | ||
| </Label> | ||
|
|
||
| <Input | ||
| className='bg-mono-white focus:border-mint-500 rounded-2xl border border-gray-300' | ||
| placeholder='MBTI를 입력해주세요' | ||
| required | ||
| type='text' | ||
| value={field.state.value} | ||
| onChange={(e) => field.handleChange(e.target.value)} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
26 changes: 26 additions & 0 deletions
26
src/components/pages/profile/profile-edit-fields/message-field/index.tsx
This file contains hidden or 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,26 @@ | ||
| import { AnyFieldApi } from '@tanstack/react-form'; | ||
|
|
||
| import { Input, Label } from '@/components/ui'; | ||
|
|
||
| interface Props { | ||
| field: AnyFieldApi; | ||
| } | ||
|
|
||
| export const MessageField = ({ field }: Props) => { | ||
| return ( | ||
| <div className='mt-3 flex w-full flex-col gap-1'> | ||
| <Label htmlFor='post-meetup-title' required> | ||
| 한 줄 소개 | ||
| </Label> | ||
|
|
||
| <Input | ||
| className='bg-mono-white focus:border-mint-500 rounded-2xl border border-gray-300' | ||
| placeholder='한 줄 소개를 입력해주세요' | ||
| required | ||
| type='text' | ||
| value={field.state.value} | ||
| onChange={(e) => field.handleChange(e.target.value)} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
26 changes: 26 additions & 0 deletions
26
src/components/pages/profile/profile-edit-fields/nickname-field/index.tsx
This file contains hidden or 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,26 @@ | ||
| import { AnyFieldApi } from '@tanstack/react-form'; | ||
|
|
||
| import { Input, Label } from '@/components/ui'; | ||
|
|
||
| interface Props { | ||
| field: AnyFieldApi; | ||
| } | ||
|
|
||
| export const NickNameField = ({ field }: Props) => { | ||
| return ( | ||
| <div className='flex w-full flex-col gap-1'> | ||
| <Label htmlFor='post-meetup-title' required> | ||
| 닉네임 | ||
| </Label> | ||
|
|
||
| <Input | ||
| className='bg-mono-white focus:border-mint-500 rounded-2xl border border-gray-300' | ||
| placeholder='닉네임을 입력해주세요' | ||
| required | ||
| type='text' | ||
| value={field.state.value} | ||
| onChange={(e) => field.handleChange(e.target.value)} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or 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,70 @@ | ||
| 'use client'; | ||
| import { useForm } from '@tanstack/react-form'; | ||
|
|
||
| import { | ||
| Button, | ||
| ImageRecord, | ||
| ModalContent, | ||
| ModalDescription, | ||
| ModalTitle, | ||
| useModal, | ||
| } from '@/components/ui'; | ||
| import { User } from '@/types/service/user'; | ||
|
|
||
| import ImageField from '../profile-edit-fields/image-field'; | ||
| import { MBTIField } from '../profile-edit-fields/mbti-field'; | ||
| import { MessageField } from '../profile-edit-fields/message-field'; | ||
| import { NickNameField } from '../profile-edit-fields/nickname-field'; | ||
|
|
||
| interface Props { | ||
| user: User; | ||
| } | ||
|
|
||
| export const ProfileEditModal = ({ user }: Props) => { | ||
| const { profileImage: image, nickName, profileMessage, mbti } = user; | ||
|
|
||
| const { close } = useModal(); | ||
|
|
||
| const form = useForm({ | ||
| defaultValues: { | ||
| profileImage: { | ||
| [image]: null, | ||
| } as ImageRecord, | ||
| nickName, | ||
| profileMessage, | ||
| mbti, | ||
| }, | ||
| onSubmit: async ({ value }) => { | ||
| console.log(value); | ||
| close(); | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <ModalContent> | ||
| <ModalTitle>프로필 수정</ModalTitle> | ||
| <ModalDescription className='sr-only'> | ||
| 이 모달은 자신의 프로필을 수정할 수 있는 모달입니다. | ||
| </ModalDescription> | ||
| <form | ||
| className='w-full max-w-70.5' | ||
| onSubmit={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| form.handleSubmit(); | ||
| }} | ||
| > | ||
| <form.Field children={(field) => <ImageField field={field} />} name='profileImage' /> | ||
| <form.Field children={(field) => <NickNameField field={field} />} name='nickName' /> | ||
| <form.Field children={(field) => <MessageField field={field} />} name='profileMessage' /> | ||
| <form.Field children={(field) => <MBTIField field={field} />} name='mbti' /> | ||
| <div className='mt-6 flex gap-2'> | ||
| <Button variant='tertiary' onClick={close}> | ||
| 취소 | ||
| </Button> | ||
| <Button type='submit'>수정하기</Button> | ||
| </div> | ||
| </form> | ||
| </ModalContent> | ||
| ); | ||
| }; |
This file contains hidden or 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 hidden or 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
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.
저번에 코멘트 남겼던 mode가 이렇게 사용되는군요!
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.
맞아요! 프로필에서는 항상 이미지가 교체되기 때문에 replace를 적용했습니다 :)