-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
"use client"; | ||
|
||
import { | ||
type Container, | ||
type ISourceOptions, | ||
MoveDirection, | ||
OutMode, | ||
} from "@tsparticles/engine"; | ||
import Particles, { initParticlesEngine } from "@tsparticles/react"; | ||
import { useEffect, useMemo, useState } from "react"; | ||
import { loadFull } from "tsparticles"; | ||
|
||
export const MyParticles = () => { | ||
const [init, setInit] = useState(false); | ||
|
||
// this should be run only once per application lifetime | ||
useEffect(() => { | ||
void initParticlesEngine(async (engine) => { | ||
await loadFull(engine); | ||
}).then(() => { | ||
setInit(true); | ||
}); | ||
}, []); | ||
|
||
const particlesLoaded = async (container?: Container): Promise<void> => { | ||
console.log(container); | ||
}; | ||
|
||
const options: ISourceOptions = useMemo( | ||
() => { | ||
return ({ | ||
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: "#000000", | ||
}, | ||
links: { | ||
color: "#000000", | ||
distance: 150, | ||
enable: true, | ||
opacity: 0.2, | ||
width: 1, | ||
}, | ||
move: { | ||
direction: MoveDirection.none, | ||
enable: true, | ||
outModes: { | ||
default: OutMode.out, | ||
}, | ||
random: false, | ||
speed: 6, | ||
straight: false, | ||
}, | ||
number: { | ||
density: { | ||
enable: true, | ||
}, | ||
value: 30, | ||
}, | ||
opacity: { | ||
value: 0.2, | ||
}, | ||
shape: { | ||
type: "circle", | ||
}, | ||
size: { | ||
value: { min: 1, max: 5 }, | ||
}, | ||
}, | ||
detectRetina: true, | ||
}); | ||
}, | ||
[], | ||
); | ||
|
||
if (init) { | ||
return ( | ||
<Particles | ||
id="tsparticles" | ||
particlesLoaded={particlesLoaded} | ||
options={options} | ||
/> | ||
); | ||
} | ||
|
||
return <></>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { MyParticles } from "../Particles"; | ||
import notes from "./site-notes"; | ||
|
||
export default function Page() { | ||
return ( | ||
<div className="dark:bg-medium dark:text-white"> | ||
<div className='max-w-md divide-y divide-gray-200 text-gray-900 dark:divide-gray-700 dark:text-white min-w-full py-6'> | ||
{ | ||
notes.map((item: { date: string, text: string }) => { | ||
return ( | ||
<div key={item.date} className='flex flex-col pb-3'> | ||
<dt className='mb-1 text-gray-500 md:text-lg dark:text-gray-400'>{item.date}</dt> | ||
<dd className='text-lg font-semibold'>{item.text}</dd> | ||
</div> | ||
) | ||
}) | ||
} | ||
<> | ||
<MyParticles /> | ||
<div className="dark:bg-medium dark:text-white"> | ||
<div className='max-w-md divide-y divide-gray-200 text-gray-900 dark:divide-gray-700 dark:text-white min-w-full py-6'> | ||
{ | ||
notes.map((item: { date: string, text: string }) => { | ||
return ( | ||
<div key={item.date} className='flex flex-col pb-3'> | ||
<dt className='mb-1 text-gray-500 md:text-lg dark:text-gray-400'>{item.date}</dt> | ||
<dd className='text-lg font-semibold'>{item.text}</dd> | ||
</div> | ||
) | ||
}) | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters