diff --git a/src/app/components/ParticleBackground.tsx b/src/app/components/ParticleBackground.tsx new file mode 100644 index 0000000..bbec95c --- /dev/null +++ b/src/app/components/ParticleBackground.tsx @@ -0,0 +1,104 @@ +'use client' +import React, { useEffect, useMemo, useState } from 'react'; +import Particles, { initParticlesEngine } from '@tsparticles/react'; +import { loadSlim } from '@tsparticles/slim'; +import { type ISourceOptions, MoveDirection, OutMode } from '@tsparticles/engine'; + +interface ParticleBackgroundProps { + speed: number; +} + +const ParticleBackground: React.FC = ({ speed }) => { + const [init, setInit] = useState(false); + + useEffect(() => { + initParticlesEngine(async (engine) => { + await loadSlim(engine); + }).then(() => { + setInit(true); + }); + }, []); + + const particlesLoaded = async (container?: any): Promise => { + console.log(container); + }; + + const options: ISourceOptions = useMemo( + () => ({ + background: { + color: { + value: '#1a202c', + }, + }, + fpsLimit: 120, + interactivity: { + events: { + onClick: { + enable: true, + mode: 'push', + }, + onHover: { + enable: true, + mode: 'repulse', + }, + }, + modes: { + push: { + quantity: 4, + }, + repulse: { + distance: 200, + duration: 0.4, + }, + }, + }, + particles: { + color: { + value: '#ffffff', + }, + links: { + color: '#ffffff', + distance: 150, + enable: true, + opacity: 0.5, + width: 1, + }, + move: { + direction: MoveDirection.none, + enable: true, + outModes: { + default: OutMode.out, + }, + random: true, + speed: speed, // speed prop + straight: false, + }, + number: { + density: { + enable: true, + }, + value: 80, + }, + opacity: { + value: 0.5, + }, + shape: { + type: 'star', + }, + size: { + value: { min: 1, max: 5 }, + }, + }, + detectRetina: true, + }), + [speed] + ); + + return ( + <> + {init && } + + ); +}; + +export default ParticleBackground; \ No newline at end of file diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx index c44d69d..50a01db 100644 --- a/src/app/home/page.tsx +++ b/src/app/home/page.tsx @@ -1,102 +1,15 @@ 'use client' -import React, { useEffect, useMemo, useState } from 'react'; -import Particles, { initParticlesEngine } from '@tsparticles/react'; -import { loadSlim } from '@tsparticles/slim'; -import { type ISourceOptions, MoveDirection, OutMode } from '@tsparticles/engine'; +import React, { useState } from 'react'; +import ParticleBackground from '../components/ParticleBackground'; import Card from '../components/Card'; import Avatar from '../components/Avatar'; const Home: React.FC = () => { - const [init, setInit] = useState(false); - - useEffect(() => { - initParticlesEngine(async (engine) => { - await loadSlim(engine); - }).then(() => { - setInit(true); - }); - }, []); - - const particlesLoaded = async (container?: any): Promise => { - console.log(container); - }; - - const options: ISourceOptions = useMemo( - () => ({ - background: { - color: { - value: '#1a202c', - }, - }, - fpsLimit: 120, - interactivity: { - events: { - onClick: { - enable: true, - mode: 'push', - }, - onHover: { - enable: true, - mode: 'repulse', - }, - }, - modes: { - push: { - quantity: 4, - }, - repulse: { - distance: 200, - duration: 0.4, - }, - }, - }, - particles: { - color: { - value: '#ffffff', - }, - links: { - color: '#ffffff', - distance: 150, - enable: true, - opacity: 0.5, - width: 1, - }, - move: { - direction: MoveDirection.none, - enable: true, - outModes: { - default: OutMode.out, - }, - random: true, - speed: 1, - straight: false, - }, - number: { - density: { - enable: true, - }, - value: 80, - }, - opacity: { - value: 0.5, - }, - shape: { - type: 'star', - }, - size: { - value: { min: 1, max: 5 }, - }, - }, - detectRetina: true, - }), - [] - ); + const [starRating, setStarRating] = useState(1); // State for star rating return (
- {init && ( - - )} +
@@ -142,8 +55,47 @@ const Home: React.FC = () => { btnLink="https://st4rdelic.com/" />
+
+
+ setStarRating(1)} + /> + setStarRating(2)} + /> + setStarRating(3)} + /> + setStarRating(4)} + /> + setStarRating(5)} + /> +
+
); }; -export default Home; \ No newline at end of file +export default Home; diff --git a/src/app/page.tsx b/src/app/page.tsx index 7f653d4..affa15f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,108 +1,19 @@ 'use client' -import React, { useEffect, useMemo, useState } from 'react'; -import Particles, { initParticlesEngine } from '@tsparticles/react'; -import { loadSlim } from '@tsparticles/slim'; -import { type ISourceOptions, MoveDirection, OutMode } from '@tsparticles/engine'; +import React from 'react'; +import ParticleBackground from '../app/components/ParticleBackground'; import CodeBlock from '../app/components/CodeBlock'; const HomePage: React.FC = () => { - const [init, setInit] = useState(false); + const starRating = 1; - useEffect(() => { - initParticlesEngine(async (engine) => { - await loadSlim(engine); - }).then(() => { - setInit(true); - }); - }, []); - - const particlesLoaded = async (container?: any): Promise => { - console.log(container); - }; - - const options: ISourceOptions = useMemo( - () => ({ - background: { - color: { - value: '#1a202c', - }, - }, - fpsLimit: 120, - interactivity: { - events: { - onClick: { - enable: true, - mode: 'push', - }, - onHover: { - enable: true, - mode: 'repulse', - }, - }, - modes: { - push: { - quantity: 4, - }, - repulse: { - distance: 200, - duration: 0.4, - }, - }, - }, - particles: { - color: { - value: '#ffffff', - }, - links: { - color: '#ffffff', - distance: 150, - enable: true, - opacity: 0.5, - width: 1, - }, - move: { - direction: MoveDirection.none, - enable: true, - outModes: { - default: OutMode.out, - }, - random: true, - speed: 1, - straight: false, - }, - number: { - density: { - enable: true, - }, - value: 80, - }, - opacity: { - value: 0.5, - }, - shape: { - type: 'star', - }, - size: { - value: { min: 1, max: 5 }, - }, - }, - detectRetina: true, - }), - [] - ); - - if (init) { - return ( -
- -
- -
+ return ( +
+ +
+
- ); - } - - return <>; +
+ ); }; export default HomePage;