Skip to content

Commit

Permalink
feat: picture태그를 사용한 이미지 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisebastian committed Dec 5, 2024
1 parent ab8f892 commit 3d2572e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { WorkSpace } from "@features/workSpace/WorkSpace";
import { useErrorStore } from "@stores/useErrorStore";
import { useUserInfo } from "@stores/useUserStore";
import { useSocketStore } from "./stores/useSocketStore";
import { BackgroundImage } from "./components/backgroundImage/BackgroundImage";

const App = () => {
// TODO 라우터, react query 설정
Expand All @@ -25,6 +26,7 @@ const App = () => {

return (
<>
<BackgroundImage />
{isErrorModalOpen && <ErrorModal errorMessage={errorMessage} />}
<WorkSpace />
</>
Expand Down
28 changes: 28 additions & 0 deletions client/src/components/backgroundImage/BackgroundImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import backgroundPNG from "@assets/images/background.png";
import backgroundWEBP from "@assets/images/background.webp";
import backgroundAVIF from "@assets/images/background.avif";

export const BackgroundImage = () => (
<picture
style={{
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
zIndex: -1,
}}
>
<source srcSet={backgroundAVIF} type="image/avif" />
<source srcSet={backgroundWEBP} type="image/webp" />
<img
src={backgroundPNG}
alt="background"
style={{
width: "100%",
height: "100%",
objectFit: "cover",
}}
/>
</picture>
);

0 comments on commit 3d2572e

Please sign in to comment.