Skip to content

Commit

Permalink
feat: 수정 중 썸네일 이미지 출력
Browse files Browse the repository at this point in the history
  • Loading branch information
ymj07168 committed Oct 29, 2024
1 parent fe519d8 commit 0068c50
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/components/EditorPage/MdEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ function MdEditor() {
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onSave={handleModalSave}
thumbnailImage={postData?.thumbnail}
isEdit={isEdit}
/>
</div>
);
Expand Down
22 changes: 19 additions & 3 deletions src/components/EditorPage/ThumbnailModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faX } from "@fortawesome/free-solid-svg-icons";
import { useMediaQuery } from "@mui/material";

const ThumbnailModal = ({ isOpen, onClose, onSave }) => {
const ThumbnailModal = ({
isOpen,
onClose,
onSave,
thumbnailImage,
isEdit,
}) => {
const [thumbnail, setThumbnail] = React.useState(null);
const isMobile = useMediaQuery("(max-width:550px)");

Expand Down Expand Up @@ -52,13 +58,23 @@ const ThumbnailModal = ({ isOpen, onClose, onSave }) => {
onChange={handleFileChange}
className="hidden"
/>
{thumbnail && (
{/* 수정 중이고 썸네일 null인 경우 기존 썸네일 출력 */}
{isEdit && !thumbnail ? (
<img
src={URL.createObjectURL(thumbnail)}
src={thumbnailImage}
alt="Thumbnail Preview"
className="my-3"
style={{ height: "200px", objectFit: "cover" }}
/>
) : (
thumbnail && (
<img
src={URL.createObjectURL(thumbnail)}
alt="Thumbnail Preview"
className="my-3"
style={{ height: "200px", objectFit: "cover" }}
/>
)
)}
<Button
variant="contained"
Expand Down

0 comments on commit 0068c50

Please sign in to comment.