-
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.
Browse files
Browse the repository at this point in the history
Feature/#71 글쓰기 페이지
- Loading branch information
Showing
17 changed files
with
364 additions
and
213 deletions.
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.