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

🔧 Added react-confetti v6.1.0 (#90) #90

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions components/BodyContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useRecoilState } from "recoil";

import ActionLode from "./ActionLode";
import ButtonActions from "./ButtonActions";
import ConfettiSection from "./ConfettiSection";
import SmallHeader from "./Contents/SmallHeader";
import FeedBackForm from "./FeedBackForm";
import FormContainer from "./FormContainer";
Expand Down Expand Up @@ -197,6 +198,7 @@ function BodyContent({}: Props) {
</>
) : (
<>
<ConfettiSection />
<ButtonActions
setIsShow={setIsShow}
setIsMdPreview={setIsMdPreview}
Expand Down
32 changes: 32 additions & 0 deletions components/ConfettiSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import useWindowSize from "@/lib/useWindowSize";
import { useEffect, useState } from "react";
import Confetti from "react-confetti";

type Props = {};

function ConfettiSection({}: Props) {
const { width, height } = useWindowSize();
const [isFalse, setIsFalse] = useState<boolean>(true);

useEffect(() => {
setTimeout(() => {
setIsFalse(false);
}, 4000);
}, [isFalse]);

return (
<div>
<Confetti
gravity={0.3}
tweenDuration={4000}
width={width - 10}
height={height - 1}
recycle={isFalse}
/>
</div>
);
}

export default ConfettiSection;
2 changes: 2 additions & 0 deletions components/profile/ProfileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { toast } from "react-toastify";
import { useRecoilState } from "recoil";

import ActionLode from "../ActionLode";
import ConfettiSection from "../ConfettiSection";
import DividerLine from "../DividerLine";
import ProfileButtonAction from "./ProfileButtonAction";
import ProfileFeedbackForm from "./ProfileFeedbackForm";
Expand Down Expand Up @@ -110,6 +111,7 @@ function ProfileContent({}: Props) {
</>
) : (
<>
<ConfettiSection />
<ProfileButtonAction
setIsShow={setIsShow}
setIsMdPreview={setIsMdPreview}
Expand Down
26 changes: 26 additions & 0 deletions lib/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useEffect, useState } from "react";

export default function useWindowSize() {
const [windowSize, setWindowSize] = useState({
width: typeof window !== "undefined" ? window.innerWidth : 1200,
height: typeof window !== "undefined" ? window.innerHeight : 800,
});

function changeWindowSize() {
if (typeof window !== "undefined") {
setWindowSize({ width: window.innerWidth, height: window.innerHeight });
}
}

useEffect(() => {
if (typeof window !== "undefined") {
window.addEventListener("resize", changeWindowSize);

return () => {
window.removeEventListener("resize", changeWindowSize);
};
}
}, []);

return windowSize;
}
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"postcss": "8.4.21",
"react": "18.2.0",
"react-colorful": "^5.6.1",
"react-confetti": "^6.1.0",
"react-dom": "18.2.0",
"react-icons": "^4.8.0",
"react-particles": "^2.9.3",
Expand Down