-
Notifications
You must be signed in to change notification settings - Fork 3
모달창 구현하기 & util Function vs Custom hooks에 대한 고뇌 #119
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 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a32db91
#110 fix(fe): type 수정
KimKyuHoi 0620960
#110 feat(fe): 모달창 구현
KimKyuHoi 572cd46
#110 feat(fe): formatFileSize 유틸 함수 구현
KimKyuHoi bf6ab7c
#110 feat(fe): type 추가
KimKyuHoi 15c3f10
#110 feat(fe): code 모듈화
KimKyuHoi f715dc1
#110 feat(fe): 모달창 구현하기
KimKyuHoi 26e85b9
#110 fix(fe): 파일명 변경
KimKyuHoi 0565867
#110 refactor(fe): 파일 폴더 이동
KimKyuHoi 7e5e839
#110 refactor(fe): 커스텀 훅 컴포넌트 수정
KimKyuHoi 0249bd0
#110 fix(fe): 파일 경로명 변경
KimKyuHoi 76f4bfc
#110 fix(fe): preview item내 스타일링 수정
KimKyuHoi 954e608
#110 refactor(fe): 함수 useCallback적용해주기
KimKyuHoi e48c216
#110 fix(fe): x icon 변경 및 비디오일 경우 뒷배경 추가
KimKyuHoi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { Button } from '@workspace/ui/components'; | ||
| import { Modal } from '@workspace/ui/components/Modal/modal'; | ||
| import { FileData } from '../model'; | ||
| import { formatFileSize } from '../model'; | ||
| import Image from 'next/image'; | ||
|
|
||
| type FileModalProps = { | ||
| isOpen: boolean; | ||
| setIsOpen: (isOpen: boolean) => void; | ||
| size?: 'default' | 'lg'; | ||
| className?: string; | ||
| fileData: FileData; | ||
| }; | ||
|
|
||
| const FileModal = ({ | ||
| isOpen, | ||
| setIsOpen, | ||
| size, | ||
| className, | ||
| fileData, | ||
| }: FileModalProps) => { | ||
| return ( | ||
| <Modal | ||
| size={size} | ||
| className={className} | ||
| isOpen={isOpen} | ||
| onClose={() => setIsOpen(false)} | ||
| > | ||
| <div className="p-6"> | ||
| {/* 헤더 */} | ||
| <div className="flex justify-between items-center mb-6"> | ||
| <div className="flex items-center gap-3"> | ||
| <span className="p-2 bg-gray-100 rounded-lg"> | ||
| {fileData.type === 'image' ? '🖼️' : '🎥'} | ||
| </span> | ||
| <div> | ||
| <h2 className="text-lg font-bold text-gray-800"> | ||
| {fileData.name} | ||
| </h2> | ||
| <p className="text-sm text-gray-500"> | ||
| {fileData.type === 'image' ? 'Image' : 'Video'} •{' '} | ||
| {formatFileSize(fileData.file.size)} | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* 컨텐츠 영역 */} | ||
| <div className="rounded-xl overflow-hidden bg-gray-50"> | ||
| {fileData.type === 'image' ? ( | ||
| <div className="relative w-full h-[40vh]"> | ||
| <Image | ||
| src={fileData.preview} | ||
| alt={fileData.name} | ||
| fill | ||
| className="object-contain" | ||
| sizes="(max-width: 768px) 100vw, 80vw" | ||
| /> | ||
| </div> | ||
| ) : ( | ||
| <div className="relative w-full h-[40vh] bg-black"> | ||
| <video | ||
| src={fileData.preview} | ||
| className="w-full h-full" | ||
| controls | ||
| autoPlay | ||
| controlsList="nodownload" | ||
| poster={fileData.thumbnailUrl} | ||
| > | ||
| Your browser does not support the video tag. | ||
| </video> | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| {/* 푸터 */} | ||
| <div className="flex justify-end gap-2 mt-6"> | ||
| <Button | ||
| variant="default" | ||
| onClick={() => setIsOpen(false)} | ||
| > | ||
| Close | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </Modal> | ||
| ); | ||
| }; | ||
|
|
||
| export default FileModal; |
19 changes: 19 additions & 0 deletions
19
src/frontend/apps/web/src/features/chat/ui/file-preview-image.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,19 @@ | ||
| import Image from 'next/image'; | ||
|
|
||
| export const ImagePreivew = ({ | ||
| preview, | ||
| onClick, | ||
| }: { | ||
| preview: string; | ||
| onClick: () => void; | ||
| }) => { | ||
| return ( | ||
| <Image | ||
| src={preview} | ||
| alt="Preview" | ||
| fill | ||
| className="object-cover" | ||
| onClick={onClick} | ||
| /> | ||
| ); | ||
| }; |
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
24 changes: 24 additions & 0 deletions
24
src/frontend/apps/web/src/features/chat/ui/file-preview-video.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,24 @@ | ||
| import Image from 'next/image'; | ||
|
|
||
| export const VideoPreview = ({ | ||
| thumbnailUrl, | ||
| onClick, | ||
| }: { | ||
| thumbnailUrl: string; | ||
| onClick: () => void; | ||
| }) => { | ||
| return ( | ||
| <> | ||
| <Image | ||
| src={thumbnailUrl} | ||
| alt="Video thumbnail" | ||
| fill | ||
| className="object-cover" | ||
| onClick={onClick} | ||
| /> | ||
| <div className="absolute bottom-1 right-1 bg-black/60 text-white text-xs px-1 rounded"> | ||
KimKyuHoi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ▶ | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.