-
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.
Merge pull request #36 from JongMany/feat/project-modal
[Feat] 메인화면 이미지 최적화
- Loading branch information
Showing
43 changed files
with
380 additions
and
102 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { projectOutlineList } from "@/shared/constants"; | ||
import { Modal } from "@/shared/ui"; | ||
|
||
type Props = { | ||
closeModal: () => void; | ||
projectName: string; | ||
}; | ||
|
||
export const ProjectDetailModal = ({ closeModal, projectName }: Props) => { | ||
const project = projectOutlineList.find( | ||
(project) => project.name === projectName | ||
); | ||
|
||
return ( | ||
<Modal> | ||
<div className="w-[700px] h-[600px] backdrop-blur-[60px] text-white rounded-[5px]"> | ||
<div className="flex justify-end px-4 py-2"> | ||
<button onClick={closeModal}>닫기</button> | ||
</div> | ||
<section> | ||
<h1 className="mb-2 text-2xl text-center">{project?.name}</h1> | ||
<article className="overflow-x-scroll scrollbar-hide"></article> | ||
</section> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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,15 +1,44 @@ | ||
import { useDeviceSize } from "@/shared/libs"; | ||
import { ProjectDetailModal } from "@/entities/projects/ui/modal/ProjectDetailModal"; | ||
import { useDeviceSize, useModal } from "@/shared/libs"; | ||
import { Link } from "react-router-dom"; | ||
|
||
type Props = { | ||
projectName: string; | ||
}; | ||
export const DetailLink = ({ projectName }: Props) => { | ||
const device = useDeviceSize(); | ||
const { closeModal, openModal } = useModal( | ||
() => { | ||
return ( | ||
<ProjectDetailModal closeModal={closeModal} projectName={projectName} /> | ||
); | ||
}, | ||
{ | ||
onOpen: () => { | ||
const container = document.querySelector( | ||
'[data-name="project-showcase"]' | ||
); | ||
if (container) { | ||
(container as HTMLElement).style.overflow = "hidden"; | ||
} | ||
}, | ||
onClose: () => { | ||
const container = document.querySelector( | ||
'[data-name="project-showcase"]' | ||
); | ||
if (container) { | ||
// scroll-snap 을 위해 auto로 변경 | ||
(container as HTMLElement).style.overflow = "auto"; | ||
} | ||
}, | ||
} | ||
); | ||
// PC 환경이 아닌 경우는 URL로 이동 | ||
if (device !== "desktop") { | ||
const encodedProjectName = encodeURIComponent(projectName); | ||
return <Link to={`/project/${encodedProjectName}`}>더 자세히 보기</Link>; | ||
} | ||
|
||
return <Link to="/project">더 자세히 보기</Link>; | ||
// PC 환경에서는 모달로 띄움 | ||
return <button onClick={openModal}>더 자세히 보기</button>; | ||
}; |
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,58 +1,28 @@ | ||
import { useDeviceSize } from "@/shared/libs"; | ||
import "./ImageContainer.css"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { Img } from "@/shared/ui/image/Img"; | ||
|
||
// https://blog.webdevsimplified.com/2023-05/lazy-load-images/ | ||
export const ImageContainer = ({ | ||
image, | ||
alt = "project", | ||
smallImageUrl, | ||
imageSet, | ||
}: { | ||
image: string; | ||
alt?: string; | ||
smallImageUrl: string; | ||
imageSet: { | ||
loadImageUrl: string; | ||
smallImageUrl: string; | ||
mediumImageUrl: string; | ||
largeImageUrl: string; | ||
originImageUrl: string; | ||
}; | ||
}) => { | ||
const device = useDeviceSize(); | ||
const imageStyle = device === "desktop" ? "w-full" : "w-[80vw] h-[34vh]"; | ||
const blurredImageDivRef = useRef<HTMLDivElement>(null); | ||
const imageRef = useRef<HTMLImageElement>(null); | ||
const [, setIsLargeImgLoaded] = useState(false); | ||
|
||
useEffect(() => { | ||
function loaded() { | ||
if (blurredImageDivRef.current) { | ||
setIsLargeImgLoaded(true); | ||
blurredImageDivRef.current.classList.add("loaded"); | ||
} | ||
} | ||
|
||
const img = imageRef.current; | ||
if (img?.complete) { | ||
loaded(); | ||
} else { | ||
img?.addEventListener("load", loaded); | ||
} | ||
|
||
return () => { | ||
img?.removeEventListener("load", loaded); | ||
}; | ||
}, []); | ||
|
||
const containerStyle = device === "desktop" ? "w-[100%]" : "w-[70%] h-[80%]"; | ||
return ( | ||
<div className="basis-[50%] flex flex-col items-center justify-center"> | ||
<div | ||
style={{ backgroundImage: `url(${smallImageUrl})` }} | ||
className={`blurred-img`} | ||
ref={blurredImageDivRef} | ||
> | ||
<img | ||
ref={imageRef} | ||
className={`${imageStyle}`} | ||
src={image} | ||
alt={alt} | ||
loading="lazy" | ||
/> | ||
<section className="basis-[50%] flex flex-col items-center justify-center"> | ||
<div className={containerStyle}> | ||
<Img imageStyle={imageStyle} alt={alt} imageSet={imageSet} /> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./typing/useTypingAnimation"; | ||
export * from "./media-query/useDeviceSize"; | ||
export * from "./modal/useModal"; |
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
Oops, something went wrong.