-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update home page * chore: update styles * chore: update home page * chore: update homepage * chore: update code * chore: update color * chore: update page * chore: finish docs * chore: finish docs
- Loading branch information
Showing
18 changed files
with
1,104 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/css/custom.scss", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils", | ||
"ui": "@/components/ui", | ||
"examples": "@/components/examples", | ||
"blocks": "@/components/blocks" | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"$schema": "https://nyxbui.design/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/css/custom.scss", | ||
"baseColor": "rose", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "~/components", | ||
"utils": "~/lib/utils" | ||
} | ||
} |
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
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,188 @@ | ||
"use client"; | ||
|
||
import { RefObject, useEffect, useId, useState } from "react"; | ||
import { motion } from "framer-motion"; | ||
|
||
import { cn } from "../../lib/utils"; | ||
|
||
export interface AnimatedBeamProps { | ||
className?: string; | ||
containerRef: RefObject<HTMLElement>; // Container ref | ||
fromRef: RefObject<HTMLElement>; | ||
toRef: RefObject<HTMLElement>; | ||
curvature?: number; | ||
reverse?: boolean; | ||
pathColor?: string; | ||
pathWidth?: number; | ||
pathOpacity?: number; | ||
gradientStartColor?: string; | ||
gradientStopColor?: string; | ||
delay?: number; | ||
duration?: number; | ||
startXOffset?: number; | ||
startYOffset?: number; | ||
endXOffset?: number; | ||
endYOffset?: number; | ||
} | ||
|
||
export const AnimatedBeam: React.FC<AnimatedBeamProps> = ({ | ||
className, | ||
containerRef, | ||
fromRef, | ||
toRef, | ||
curvature = 0, | ||
reverse = false, // Include the reverse prop | ||
duration = Math.random() * 3 + 4, | ||
delay = 0, | ||
pathColor = "gray", | ||
pathWidth = 2, | ||
pathOpacity = 0.2, | ||
gradientStartColor = "#ffaa40", | ||
gradientStopColor = "#9c40ff", | ||
startXOffset = 0, | ||
startYOffset = 0, | ||
endXOffset = 0, | ||
endYOffset = 0, | ||
}) => { | ||
const id = useId(); | ||
const [pathD, setPathD] = useState(""); | ||
const [svgDimensions, setSvgDimensions] = useState({ width: 0, height: 0 }); | ||
|
||
// Calculate the gradient coordinates based on the reverse prop | ||
const gradientCoordinates = reverse | ||
? { | ||
x1: ["90%", "-10%"], | ||
x2: ["100%", "0%"], | ||
y1: ["0%", "0%"], | ||
y2: ["0%", "0%"], | ||
} | ||
: { | ||
x1: ["10%", "110%"], | ||
x2: ["0%", "100%"], | ||
y1: ["0%", "0%"], | ||
y2: ["0%", "0%"], | ||
}; | ||
|
||
useEffect(() => { | ||
const updatePath = () => { | ||
if (containerRef.current && fromRef.current && toRef.current) { | ||
const containerRect = containerRef.current.getBoundingClientRect(); | ||
const rectA = fromRef.current.getBoundingClientRect(); | ||
const rectB = toRef.current.getBoundingClientRect(); | ||
|
||
const svgWidth = containerRect.width; | ||
const svgHeight = containerRect.height; | ||
setSvgDimensions({ width: svgWidth, height: svgHeight }); | ||
|
||
const startX = | ||
rectA.left - containerRect.left + rectA.width / 2 + startXOffset; | ||
const startY = | ||
rectA.top - containerRect.top + rectA.height / 2 + startYOffset; | ||
const endX = | ||
rectB.left - containerRect.left + rectB.width / 2 + endXOffset; | ||
const endY = | ||
rectB.top - containerRect.top + rectB.height / 2 + endYOffset; | ||
|
||
const controlY = startY - curvature; | ||
const d = `M ${startX},${startY} Q ${ | ||
(startX + endX) / 2 | ||
},${controlY} ${endX},${endY}`; | ||
setPathD(d); | ||
} | ||
}; | ||
|
||
// Initialize ResizeObserver | ||
const resizeObserver = new ResizeObserver((entries) => { | ||
// For all entries, recalculate the path | ||
for (let entry of entries) { | ||
updatePath(); | ||
} | ||
}); | ||
|
||
// Observe the container element | ||
if (containerRef.current) { | ||
resizeObserver.observe(containerRef.current); | ||
} | ||
|
||
// Call the updatePath initially to set the initial path | ||
updatePath(); | ||
|
||
// Clean up the observer on component unmount | ||
return () => { | ||
resizeObserver.disconnect(); | ||
}; | ||
}, [ | ||
containerRef, | ||
fromRef, | ||
toRef, | ||
curvature, | ||
startXOffset, | ||
startYOffset, | ||
endXOffset, | ||
endYOffset, | ||
]); | ||
|
||
return ( | ||
<svg | ||
fill="none" | ||
width={svgDimensions.width} | ||
height={svgDimensions.height} | ||
xmlns="http://www.w3.org/2000/svg" | ||
className={cn( | ||
"pointer-events-none absolute left-0 top-0 transform-gpu stroke-2", | ||
className, | ||
)} | ||
viewBox={`0 0 ${svgDimensions.width} ${svgDimensions.height}`} | ||
> | ||
<path | ||
d={pathD} | ||
stroke={pathColor} | ||
strokeWidth={pathWidth} | ||
strokeOpacity={pathOpacity} | ||
strokeLinecap="round" | ||
/> | ||
<path | ||
d={pathD} | ||
strokeWidth={pathWidth} | ||
stroke={`url(#${id})`} | ||
strokeOpacity="1" | ||
strokeLinecap="round" | ||
/> | ||
<defs> | ||
<motion.linearGradient | ||
className="transform-gpu" | ||
id={id} | ||
gradientUnits={"userSpaceOnUse"} | ||
initial={{ | ||
x1: "0%", | ||
x2: "0%", | ||
y1: "0%", | ||
y2: "0%", | ||
}} | ||
animate={{ | ||
x1: gradientCoordinates.x1, | ||
x2: gradientCoordinates.x2, | ||
y1: gradientCoordinates.y1, | ||
y2: gradientCoordinates.y2, | ||
}} | ||
transition={{ | ||
delay, | ||
duration, | ||
ease: [0.16, 1, 0.3, 1], // https://easings.net/#easeOutExpo | ||
repeat: Infinity, | ||
repeatDelay: 0, | ||
}} | ||
> | ||
<stop stopColor={gradientStartColor} stopOpacity="0"></stop> | ||
<stop stopColor={gradientStartColor}></stop> | ||
<stop offset="32.5%" stopColor={gradientStopColor}></stop> | ||
<stop | ||
offset="100%" | ||
stopColor={gradientStopColor} | ||
stopOpacity="0" | ||
></stop> | ||
</motion.linearGradient> | ||
</defs> | ||
</svg> | ||
); | ||
}; |
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.