-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/#71 글쓰기 페이지 #81
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6e4fe6b
feat: 변수명 수정
hyejun0228 0a91a74
feat: 글쓰기 페이지
hyejun0228 364b02f
fix: lint 오류 수정
hyejun0228 6fd389d
fix: lint 오류 추가 수정
hyejun0228 fc36b4a
fix: 중복 파일 제거
hyejun0228 fbbb68a
fix: 함수 오류 수정
hyejun0228 51001ca
fix: 사진 삭제 버튼 디자인 변경 및 사진 위치 변경
hyejun0228 3f94d62
feat: 사진 파일 가로 스크롤 추가 및 버튼 위치 변경
hyejun0228 0bc2dcc
fix: 변수명 수정 및 사진 UI수정
hyejun0228 57d292e
fix : 버튼 UI수정
hyejun0228 43c4f05
feat: 글쓰기 페이지 반응형으로 변경
hyejun0228 0bdeec2
fix: 사진 디자인 수정
hyejun0228 3e58329
fix: 클래스네임 컨벤션 통일, 부적절한 태그 변경
ChoiWonBeen bcdd6b3
fix: 모바일 환경에서 불필요한 스크롤이 생기는 문제 수정
ChoiWonBeen 4331b69
fix: 이미지 추가 버튼 하단 고정
ChoiWonBeen b6545bc
Merge pull request #89 from BCSDLab/feature/#81_수정
hyejun0228 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 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
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
87 changes: 87 additions & 0 deletions
87
src/components/editor/TextEditor/AddImage/AddImage.module.scss
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,87 @@ | ||
@use "src/utils/styles/mediaQuery" as media; | ||
|
||
.container { | ||
display: flex; | ||
width: 100%; | ||
white-space: nowrap; | ||
overflow-x: scroll; | ||
margin-left: 25px; | ||
|
||
&__item { | ||
display: flex; | ||
margin: 14px 3px 0; | ||
position: relative; | ||
} | ||
|
||
&__button { | ||
position: absolute; | ||
width: 18px; | ||
height: 18px; | ||
margin-left: 62px; | ||
border: solid 5px; | ||
border-color: #ff7f23; | ||
border-radius: 50%; | ||
background-color: transparent; | ||
z-index: 2; | ||
} | ||
|
||
&__image { | ||
display: flex; | ||
width: 80px; | ||
height: 80px; | ||
object-fit: cover; | ||
border-radius: 10px; | ||
cursor: pointer; | ||
} | ||
|
||
&::-webkit-scrollbar { | ||
display: none; | ||
scrollbar-width: none; | ||
} | ||
} | ||
|
||
.editor { | ||
line-height: 15px; | ||
height: 650px; | ||
width: 100%; | ||
font-size: 16px; | ||
color: #222222; | ||
z-index: 1; | ||
|
||
@include media.media-breakpoint-down(mobile) { | ||
height: 340px; | ||
} | ||
|
||
&--withImage { | ||
line-height: 15px; | ||
height: 600px; | ||
width: 100%; | ||
font-size: 16px; | ||
color: #222222; | ||
z-index: 1; | ||
|
||
@include media.media-breakpoint-down(mobile) { | ||
height: 260px; | ||
} | ||
} | ||
|
||
&__add-image { | ||
display: flex; | ||
justify-content: center; | ||
z-index: 2; | ||
background-color: white; | ||
width: 48px; | ||
height: 48px; | ||
align-items: center; | ||
border-radius: 50px; | ||
box-shadow: 2px 3px 12px 1px rgb(0 0 0 / 10%); | ||
position: fixed; | ||
right: 35px; | ||
bottom: 55px; | ||
cursor: pointer; | ||
|
||
input { | ||
display: none; | ||
} | ||
} | ||
} |
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,39 +1,32 @@ | ||
import { ReactComponent as Trash } from 'assets/svg/post/trash.svg'; | ||
import { ReactComponent as Trash } from 'assets/svg/post/cancel.svg'; | ||
import { useRef } from 'react'; | ||
import useBooleanState from 'utils/hooks/useBooleanState'; | ||
import useOnClickOutside from 'utils/hooks/useOnClickOutside'; | ||
import styles from '../TextEditor.module.scss'; | ||
import styles from './AddImage.module.scss'; | ||
|
||
interface Props { | ||
value: string, | ||
onDelete: (value: string) => void, | ||
} | ||
|
||
export default function ImageItem({ value, onDelete }: Props) { | ||
const [opened, open, close] = useBooleanState(false); | ||
const imageRef = useRef<HTMLInputElement>(null); | ||
useOnClickOutside(imageRef, close); | ||
|
||
return ( | ||
<> | ||
{ opened && ( | ||
<button | ||
type="button" | ||
aria-label="trash" | ||
className={styles['image-container__button']} | ||
onClick={() => onDelete(value)} | ||
> | ||
<Trash /> | ||
</button> | ||
)} | ||
<div> | ||
<button | ||
type="button" | ||
aria-label="trash" | ||
className={styles.container__button} | ||
onClick={() => onDelete(value)} | ||
> | ||
<Trash /> | ||
</button> | ||
<input | ||
type="image" | ||
alt="" | ||
className={styles['image-container__image']} | ||
className={styles.container__image} | ||
src={value} | ||
ref={imageRef} | ||
onClick={open} | ||
/> | ||
</> | ||
</div> | ||
); | ||
} |
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,47 @@ | ||
import React, { useState, ChangeEvent } from 'react'; | ||
import { ReactComponent as Plus } from 'assets/svg/post/picture.svg'; | ||
import styles from './AddImageFile.module.scss'; | ||
|
||
function AddImageFile() { | ||
const [imageSrc, setImageSrc] = useState<string>(); | ||
|
||
const encodeFileToBase64 = (fileBlob: Blob) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(fileBlob); | ||
return new Promise<void>((resolve) => { | ||
reader.onload = () => { | ||
setImageSrc(reader.result as string); | ||
resolve(); | ||
}; | ||
}); | ||
}; | ||
|
||
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
const file = e.target.files && e.target.files[0]; | ||
if (file) { | ||
encodeFileToBase64(file); | ||
} | ||
}; | ||
|
||
return ( | ||
<main> | ||
<label htmlFor="image"> | ||
<div className={styles.getImage}> | ||
<Plus className={styles.getImage__Image} /> | ||
</div> | ||
<input | ||
type="file" | ||
onChange={handleFileChange} | ||
id="image" | ||
className={styles.input} | ||
multiple | ||
/> | ||
</label> | ||
<div> | ||
{imageSrc && <img src={imageSrc} alt="preview-img" width="80" height="80" className={styles.preview} />} | ||
</div> | ||
</main> | ||
); | ||
} | ||
|
||
export default AddImageFile; |
Oops, something went wrong.
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.
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.
얘내들을 모아서 로직을 분리한다면,
useWisiwygImageOpen
같은 훅으로 모아서 useEffect를 넣어두는 쪽으로 작성한다면 컴포넌트에 로직이 뭉치는 것을 방지할 수 있을 것 같아요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.
const [opened, active, inActive] = useBooleanState(false);
에서 반환되는 값들이 useEffect 뿐만아니라AddImage.tsx
에도 쓰이고 있어 컴포넌트를 나눠준다면 더 복잡해지지 않을까요..?!