diff --git a/examples/avatar-generator/package.json b/examples/avatar-generator/package.json
index 630679f..1dd9517 100644
--- a/examples/avatar-generator/package.json
+++ b/examples/avatar-generator/package.json
@@ -9,6 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
+ "party-js": "^2.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
diff --git a/examples/avatar-generator/src/App.jsx b/examples/avatar-generator/src/App.jsx
index a336d1f..c7fb5ef 100644
--- a/examples/avatar-generator/src/App.jsx
+++ b/examples/avatar-generator/src/App.jsx
@@ -1,12 +1,16 @@
-import { useState } from "react";
+import { useState, useRef } from "react";
import "./App.css";
import UserCard from "./components/UserCard";
import Button from "./components/Button";
+import Header from "./components/Header";
+import party from "party-js";
function App() {
const [name, setName] = useState("");
const [avatar, setAvatar] = useState("");
const [isLoading, setIsLoading] = useState(false);
+ const [headerValue, setHeaderValue] = useState("Avatar Generator");
+ const ref = useRef(null);
async function getAvatar(name, gender) {
const url = `https://avatars.dicebear.com/api/${gender}/${name}.svg`;
@@ -26,11 +30,30 @@ function App() {
getAvatar(fullName, gender);
}
+ function startParty() {
+ party.confetti(ref.current, {
+ count: party.variation.range(20, 40),
+ spread: party.variation.range(10, 20),
+ size: party.variation.range(1, 3),
+ });
+ setHeaderValue(name);
+ }
+
return (
-
Avatar Generator
-
+
+
+ {avatar !== "" && (
+
+ )}
);
}
diff --git a/examples/avatar-generator/src/components/Button.jsx b/examples/avatar-generator/src/components/Button.jsx
index 79a48be..440daf1 100644
--- a/examples/avatar-generator/src/components/Button.jsx
+++ b/examples/avatar-generator/src/components/Button.jsx
@@ -1,9 +1,12 @@
+import { forwardRef } from "react";
import styles from "./Button.module.css";
-export default function Button(props) {
+const Button = forwardRef((props, ref) => {
return (
-