diff --git a/src/components/newpost/ImageUpload/ImageUpload.tsx b/src/components/newpost/ImageUpload/ImageUpload.tsx deleted file mode 100644 index 73769e5..0000000 --- a/src/components/newpost/ImageUpload/ImageUpload.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { useState } from "react"; -import { MdUploadFile } from "react-icons/md"; -import { IoClose } from "react-icons/io5"; -import Image from "next/image"; -import * as Style from "./styles"; - -export default function UploadBox() { - const [isActive, setActive] = useState(false); - const [imgSrc, setImgSrc] = useState([]); - - const [showModal, setShowModal] = useState(false); - const [selectedImage, setSelectedImage] = useState(null); - - const handleDragStart = () => setActive(true); - const handleDragEnd = (event: React.DragEvent) => { - // 드래그가 완전히 벗어난 경우에만 setActive(false)를 호출 - if (!event.currentTarget.contains(event.relatedTarget as Node)) { - setActive(false); - } - }; - const handleDragOver = (event: React.DragEvent) => { - event.preventDefault(); - }; - - const setFileInfo = (file: File) => { - if (imgSrc.length >= 3) { - alert("이미지는 최대 3개까지 등록 가능합니다"); - return; - } - const fileReader = new FileReader(); - fileReader.readAsDataURL(file); - // 로딩이 완료되면 실행할 콜백 함수 등록 - fileReader.onload = (e) => { - if (typeof e.target?.result === "string") { - setImgSrc((prevState) => [...prevState, e.target?.result as string]); - } - }; - }; - - const handleDrop = (event: React.DragEvent) => { - event.preventDefault(); - setActive(false); - - const file = event.dataTransfer.files[0]; - if (file) { - if (file.type.startsWith("image/")) { - setFileInfo(file); - } else { - alert("이미지 파일만 업로드할 수 있습니다."); - } - } - }; - - const handleUpload = (event: React.ChangeEvent) => { - const file = event.target.files?.[0]; - if (file) { - if (file.type.startsWith("image/")) { - setFileInfo(file); - } else { - alert("이미지 파일만 업로드할 수 있습니다."); - } - } - }; - - const closeImage = (idx: number) => { - setImgSrc((prevImgSrc) => prevImgSrc.filter((_, i) => i !== idx)); - }; - - const ImageWide = ({ - src, - onClose, - }: { - src: string; - onClose: () => void; - }) => ( - - - - ); - - const openImagePreview = (src: string) => { - setSelectedImage(src); - setShowModal(true); - }; - - const closeImagePreview = () => { - setSelectedImage(null); - setShowModal(false); - }; - - return ( - - {imgSrc.map((img, index) => ( - - { - openImagePreview(img); - }} - alt="" - width={196} - height={196} - /> - closeImage(index)} - > - - - {showModal && selectedImage && ( - - )} - - ))} - - - <> - -

클릭 또는 드롭

- -
-
- ); -} diff --git a/src/components/newpost/ImageUpload/styles.ts b/src/components/newpost/ImageUpload/styles.ts deleted file mode 100644 index eec65a3..0000000 --- a/src/components/newpost/ImageUpload/styles.ts +++ /dev/null @@ -1,86 +0,0 @@ -import styled from "@emotion/styled"; - -const lightgrey = "#d7e2eb"; -const grey = "#b2c0cc"; - -export const ImageUploadContainer = styled.div` - display: flex; - white-space: nowrap; - gap: 20px; - justify-content: start; - align-items: center; - overflow-x: auto; -`; - -interface DragProps { - isActive: boolean; -} - -export const ImageUpload = styled.label` - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - min-width: 200px; - min-height: 200px; - align-items: center; - border: ${({ isActive }) => - isActive ? `dashed 2px black` : `dashed 2px ${grey}`}; - border-radius: 5px; - background-color: ${({ isActive }) => (isActive ? lightgrey : "white")}; - cursor: pointer; - &:hover { - border-color: black; - } -`; - -export const ImagePreview = styled.div` - width: 200px; - height: 200px; - position: relative; - display: inline-block; - - border-radius: 5px; - - img { - object-fit: contain; - } - - &:hover .close-button { - display: flex; - } -`; - -export const CloseButton = styled.button` - position: absolute; - width: 20px; - height: 20px; - display: none; - justify-content: center; - align-items: center; - top: 3px; - right: 3px; - font-size: 30px; - background: transparent; - border: none; - color: black; - cursor: pointer; -`; - -export const ModalOverlay = styled.div` - position: fixed; - top: 0; - left: 0; - width: 100vw; - height: 100vh; - background: rgba(0, 0, 0, 0.5); - display: flex; - align-items: center; - justify-content: center; - z-index: 1000; -`; - -export const ModalImage = styled.img` - max-width: 90%; - max-height: 90%; -`; diff --git a/src/components/newpost/Mdeditor.tsx b/src/components/newpost/Mdeditor.tsx deleted file mode 100644 index de5167c..0000000 --- a/src/components/newpost/Mdeditor.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import "@uiw/react-md-editor/markdown-editor.css"; -import "@uiw/react-markdown-preview/markdown.css"; -import dynamic from "next/dynamic"; -import { useState } from "react"; - -const MDEditor = dynamic(() => import("@uiw/react-md-editor"), { ssr: false }); - -function MdEditor() { - const [value, setValue] = useState("**프로젝트 소개를 입력하세요**"); - - const handleChange = (val?: string) => { - setValue(val ?? ""); - }; - - return ( -
- -
- ); -} - -export default MdEditor; diff --git a/src/components/newpost/newpost.tsx b/src/components/newpost/newpost.tsx deleted file mode 100644 index 8a35983..0000000 --- a/src/components/newpost/newpost.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import * as Style from "./styles"; -import SelectStackType from "../SelectStackType/SelectStackType"; -import NewpostEditor from "./Mdeditor"; -import { useEffect, useRef, useState } from "react"; -import NewpostImages from "./ImageUpload/ImageUpload"; -import { useAppDispatch } from "@/stores"; -import { setVisibilityStackToggle } from "@/stores/selectStackType/selectStacksReducer"; -import { setVisibilityTypeToggle } from "@/stores/selectStackType/selectTypesReducer"; -import { FaPlus, FaMinus } from "react-icons/fa"; - -// 프로젝트 이름 -export function NewpostName() { - return ( - - - - ); -} - -// 한 줄 소개글 -export function NewpostOneline() { - return ( - - 한 줄 소개글 - - - ); -} - -// 참고 링크 -export function NewpostLink() { - const [links, setLinks] = useState([""]); - - const addLink = () => { - if (links.length >= 3) { - alert("링크는 최대 3개까지 등록 가능합니다"); - return; - } - setLinks((previous) => [...previous, ""]); - }; - const minusLink = (trg: number) => { - setLinks((previous) => previous.filter((_, idx) => idx !== trg)); - }; - - return ( - - 참고 링크 -
- {links.map((link, index) => ( -
- { - const newLinks = [...links]; - newLinks[index] = e.target.value; - setLinks(newLinks); - }} - > - {index === 0 ? ( - { - addLink(); - }} - > - - - ) : ( - { - minusLink(index); - }} - > - - - )} -
- ))} -
-
- ); -} - -export function NewpostRepresentativeImg() { - return ( - - 대표 이미지 - - - ); -} - -export default function NewpostComponents() { - const ref = useRef(null); - const dispatch = useAppDispatch(); - - // 화면 바깥 클릭 시 상태 업데이트 - const handleClickOutside = (event: MouseEvent) => { - if (ref.current && !ref.current.contains(event.target as Node)) { - dispatch(setVisibilityStackToggle(false)); - dispatch(setVisibilityTypeToggle(false)); - } - }; - - useEffect(() => { - document.addEventListener("mousedown", handleClickOutside); - return () => { - document.removeEventListener("mousedown", handleClickOutside); - }; - }); - return ( - - - 기술 스택 및 프로젝트 구분 - - - - - 프로젝트 소개 - - - - - ); -} diff --git a/src/components/newpost/styles.ts b/src/components/newpost/styles.ts deleted file mode 100644 index 0396013..0000000 --- a/src/components/newpost/styles.ts +++ /dev/null @@ -1,79 +0,0 @@ -import styled from "@emotion/styled"; - -const blue = "#0078ff"; -const lightgrey = "#d7e2eb"; -const grey = "#b2c0cc"; - -export const NewpostContainer = styled.div` - max-width: 800px; - min-height: 100svh; - align-items: center; - padding: 20px 20px 20px 20px; - margin: auto; -`; - -export const NewpostCard = styled.div` - /* display: flex; - flex-direction: column; */ - width: 100%; - margin-bottom: 20px; -`; - -export const NewpostText = styled.p` - margin: 0px 0px 10px; - font-size: 20px; -`; - -export const NewpostNameInput = styled.input` - border: none; - border-bottom: 2px solid ${lightgrey}; - outline: none; - background: white; - height: 70px; - width: 100%; - font-size: 25px; - &:hover { - border-color: ${blue}; - } - &:focus { - border-color: ${blue}; - } -`; - -export const NewpostOnelineInput = styled.input` - border: 2px solid ${grey}; - border-radius: 5px; - background: white; - height: 50px; - width: 100%; - font-size: 20px; - padding-inline-start: 10px; - padding-inline-end: 10px; - outline-color: ${blue}; - &:hover { - border-color: ${blue}; - } -`; - -// 참고 링크 -export const NewpostLinkContainer = styled.div``; - -export const NewpostLinkBtn = styled.button` - border: 2px solid ${grey}; - border-radius: 5px; - background-color: ${grey}; - color: white; - min-height: 50px; - min-width: 50px; - font-size: 25px; - cursor: pointer; - - display: flex; - justify-content: center; - align-items: center; - - &:hover { - border: 2px solid ${blue}; - background: ${blue}; - } -`;