Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: error cat #591

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@ladle/react": "^2.13.0",
"@react-spring/web": "^9.7.3",
"@sentry/react": "^7.53.0",
"@sentry/tracing": "^7.53.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down
Binary file added public/paw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/asset/css/NotFound.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,23 @@
background-color: #2d2d2d;
padding: 25rem 0 10rem 0;
}

#error_cat {
width: 100vw;
height: 100vh;
position: absolute;
z-index: 1;
object-fit: cover;
object-position: center;
}

#error_cat__paw {
width: 12vw;
height: 12vw;
position: absolute;
z-index: 2;
object-fit: cover;
object-position: center;
background: url("paw.png") no-repeat;
background-size: 100% 100%;
}
47 changes: 44 additions & 3 deletions src/component/utils/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
import { useSpring, animated } from '@react-spring/web';
import "../../asset/css/NotFound.css";

const NotFound = () => {
const [springs, api] = useSpring(() => ({
from: { opacity: 0, transform: 'translate3d(0px, 0px, 0px)' },
config: { duration: 500 } // 애니메이션 지속 시간 설정
}));

const froms = [
{ x: 0, y: 0 },
{ x: window.innerWidth, y: 0 },
{ x: 0, y: window.innerHeight },
{ x: window.innerWidth, y: window.innerHeight },
];

const getRandomFromIndex = (from, to) => {
const min = Math.ceil(from);
const max = Math.floor(to);
return Math.floor(Math.random() * (max - min)) + min;
}

const handleClick = (event) => {
api.start({
to: {
opacity: 1, // 불투명도를 1로 설정
transform: `translate3d(${event.clientX}px, ${event.clientY}px, 0px)` // 위치 업데이트
},
// 애니메이션 시작시 불투명도를 0으로 설정 및 위치 설정 froms 배열에서 랜덤으로 from 선택되도록 수정
from: {
opacity: 0,
transform: `translate3d(${froms[getRandomFromIndex(0, froms.length)].x}px, ${froms[getRandomFromIndex(0, froms.length)].y}px, 0px)`
},
reset: true // 매 클릭마다 애니메이션 리셋
});
};

return (
<div>
<>
<div onClick={handleClick} id="error_cat">
<animated.div id="error_cat__paw"
style={{
...springs,
}
}
/>
</div>
<div className="not-found__text color-ff">
<div className="font-48-bold">404</div>
<div className="font-40-bold">Not Found</div>
</div>
</div>
</>
);
};

Expand Down
Loading