Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
kleenpulse committed Jul 24, 2024
1 parent 492852d commit 509d1d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/components/error/Particles404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Particles404 = () => {
<header className="absolute left-0 top-0 w-full bg-white px-10 py-8 font-medium uppercase text-[#f97415] md:text-3xl">
<h1
className=""
// @ts-expect-error Hacking the type
onMouseEnter={handleMouseEnter}
data-value="HNG-BOILERPLATE"
>
Expand All @@ -33,6 +34,7 @@ const Particles404 = () => {
<div className="absolute bottom-10 left-10 font-sans text-2xl uppercase">
<p
className="font-bold text-[#f97415] md:text-6xl lg:text-9xl xl:text-[10rem]"
// @ts-expect-error Hacking the type
onMouseEnter={handleMouseEnter}
data-value="404!!"
>
Expand Down
10 changes: 5 additions & 5 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ export function formatPrice(

const letters = "!ABCDEFGHIJKLMNOPQRSTUVWXYZ#";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const handleMouseEnter = (element: any) => {
if (!element) return;
element = element.target as HTMLElement;
export const handleMouseEnter = (event: MouseEvent) => {
if (!event) return;
const element = event.target as HTMLDivElement;
let iteration: number = 0;
const speed: number = element.dataset.value!.length > 7 ? 30 : 60;

Expand All @@ -46,7 +45,8 @@ export const handleMouseEnter = (element: any) => {
const deltaTime = timestamp - lastTimestamp;

if (deltaTime >= speed) {
element.textContent = [...element.textContent!]
// @ts-expect-error Hacking the type
element!.textContent! = [...element!.textContent!]
.map((_: string, index: number) => {
if (index < iteration) {
return element.dataset.value![index];
Expand Down

0 comments on commit 509d1d7

Please sign in to comment.