-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add qr code & use mouse & improve cursor performances (#35)
* ✨ ⚡️ Add useMouse & refacto components * 🎨 Force component type to have releaseDate * ⚡️ Improve cursor effects performance & move home page to sever side * ✨ add QR Code generator component * 🎨 refacto the other section * 🔧 Fix Vite CJS Node API deprecated by renaming mts
- Loading branch information
1 parent
104095e
commit 2556584
Showing
43 changed files
with
1,093 additions
and
888 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,123 +1,43 @@ | ||
"use client"; | ||
import { ArrowUpRightIcon } from "lucide-react"; | ||
import Image from "next/image"; | ||
import React, { useRef, useEffect, useState } from "react"; | ||
|
||
import { cn } from "#/src/utils/cn"; | ||
import type { CategoryType } from "../lib/types/component"; | ||
|
||
export const MainMenuCard = ({ | ||
className, | ||
category, | ||
target, | ||
nameIfNotCategory: name, | ||
descriptionIfNotCategory: description, | ||
}: { | ||
className?: string; | ||
category?: CategoryType; | ||
target?: "_blank" | "_self"; | ||
nameIfNotCategory?: string; | ||
descriptionIfNotCategory?: string; | ||
}) => { | ||
const { x, y, parentRef } = useMousePosition(); | ||
|
||
return ( | ||
<div | ||
ref={parentRef} | ||
style={{ | ||
//@ts-ignore : This is a valid css variable | ||
"--x": `${x}px`, | ||
"--y": `${y}px`, | ||
}} | ||
className={cn( | ||
"relative overflow-hidden rounded-[20px] p-2 h-full group ", | ||
className, | ||
)} | ||
> | ||
{target === "_blank" && ( | ||
<ArrowUpRightIcon className="absolute top-2 right-2 text-neutral-700 dark:text-neutral-300 size-5 group-hover:opacity-100 group-hover:translate-y-0 opacity-0 translate-y-4 transition-all z-10 transform-gpu" /> | ||
)} | ||
if (category?.comingSoonCategory) { | ||
return ( | ||
<p className="text-2xl top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 font-semibold text-neutral-800 dark:text-neutral-300 absolute"> | ||
Coming Soon | ||
</p> | ||
); | ||
} | ||
if (category?.previewCategory?.previewImage) { | ||
return ( | ||
<Image | ||
className="object-cover w-full h-48" | ||
width={600} | ||
height={400} | ||
alt={`${category.name} preview`} | ||
src={category.previewCategory.previewImage} | ||
/> | ||
); | ||
} | ||
if (category?.previewCategory?.component) { | ||
return ( | ||
<div | ||
className={cn( | ||
"size-40 rounded-full blur-3xl absolute top-[var(--y)] left-[var(--x)] -translate-x-1/2 -translate-y-1/2 group-hover:scale-[5] scale transition-transform duration-300 transform-gpu", | ||
(x === null || y === null) && "hidden", | ||
"pointer-events-none select-none flex justify-center items-center w-full h-full", | ||
)} | ||
style={{ | ||
background: | ||
"linear-gradient(135deg, #3BC4F2, #7A69F9,#F26378,#F5833F)", | ||
transform: `scale(${category.previewCategory?.previewScale ?? 0.75})`, | ||
}} | ||
/> | ||
<div className="absolute inset-px rounded-[19px] dark:bg-neutral-900/70 bg-neutral-100/90" /> | ||
|
||
{category?.previewCategory?.component || category?.comingSoonCategory ? ( | ||
<div className="relative flex items-center justify-center w-full object-cover rounded-2xl bg-white/50 dark:bg-neutral-950/50 h-48 overflow-hidden"> | ||
{category.comingSoonCategory ? ( | ||
<div className="absolute inset-0 flex items-center justify-center"> | ||
<div className="text-2xl font-semibold text-neutral-800 dark:text-neutral-300"> | ||
Coming Soon | ||
</div> | ||
</div> | ||
) : category.previewCategory?.previewImage ? ( | ||
<Image | ||
className="object-cover w-full h-full" | ||
width={600} | ||
height={400} | ||
alt={`${category.name} preview`} | ||
src={category.previewCategory.previewImage} | ||
/> | ||
) : ( | ||
<div | ||
className={cn( | ||
"pointer-events-none select-none flex justify-center items-center w-full h-full", | ||
)} | ||
style={{ | ||
transform: `scale(${ | ||
category.previewCategory?.previewScale ?? 0.75 | ||
})`, | ||
}} | ||
> | ||
{category.previewCategory?.component} | ||
</div> | ||
)} | ||
</div> | ||
) : null} | ||
<div className="relative px-4 pb-2 pt-4"> | ||
<h3 className="text-lg font-semibold text-neutral-800 dark:text-neutral-300"> | ||
{category?.name ?? name} | ||
</h3> | ||
<p className="mt-2 text-neutral-600 dark:text-neutral-400"> | ||
{category?.description ?? description} | ||
</p> | ||
> | ||
{category.previewCategory?.component} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
type MousePosition = { | ||
x: number | null; | ||
y: number | null; | ||
}; | ||
|
||
const useMousePosition = () => { | ||
const [mousePosition, setMousePosition] = useState<MousePosition>({ | ||
x: null, | ||
y: null, | ||
}); | ||
const parentRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const updateMousePosition = (event: MouseEvent) => { | ||
if (parentRef.current) { | ||
const bounds = parentRef.current.getBoundingClientRect(); | ||
const x = event.clientX - bounds.left; | ||
const y = event.clientY - bounds.top; | ||
setMousePosition({ x, y }); | ||
} | ||
}; | ||
window.addEventListener("mousemove", updateMousePosition); | ||
return () => { | ||
window.removeEventListener("mousemove", updateMousePosition); | ||
}; | ||
}, []); | ||
|
||
return { ...mousePosition, parentRef }; | ||
); | ||
} | ||
}; |
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
Oops, something went wrong.