-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #399 from Itheum/d-robert-feature-givebitz
givebitz bounty feature UI
- Loading branch information
Showing
28 changed files
with
2,110 additions
and
74 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,64 @@ | ||
export class Highlighter { | ||
container: Element; | ||
boxes: unknown[]; | ||
mouse: { x: number; y: number }; | ||
containerSize: { w: number; h: number }; | ||
constructor(containerElement: Element) { | ||
this.container = containerElement; | ||
this.boxes = Array.from(this.container.children); | ||
this.mouse = { | ||
x: 0, | ||
y: 0, | ||
}; | ||
this.containerSize = { | ||
w: 0, | ||
h: 0, | ||
}; | ||
this.initContainer = this.initContainer.bind(this); | ||
this.onMouseMove = this.onMouseMove.bind(this); | ||
this.init(); | ||
} | ||
|
||
initContainer() { | ||
const containerElement = this.container as HTMLElement; | ||
this.containerSize.w = containerElement.offsetWidth; | ||
this.containerSize.h = containerElement.offsetHeight; | ||
} | ||
|
||
onMouseMove(event: { clientX: any; clientY: any }) { | ||
const { clientX, clientY } = event; | ||
const rect = this.container.getBoundingClientRect(); | ||
const { w, h } = this.containerSize; | ||
const x = clientX - rect.left; | ||
const y = clientY - rect.top; | ||
const inside = x < w && x > 0 && y < h && y > 0; | ||
if (inside) { | ||
this.mouse.x = x; | ||
this.mouse.y = y; | ||
this.boxes.forEach((box: unknown) => { | ||
if (typeof box === "object" && box !== null) { | ||
const typedBox = box as { | ||
getBoundingClientRect: () => { (): any; new (): any; left: number; top: number }; | ||
style: { setProperty: (arg0: string, arg1: string) => void }; | ||
}; | ||
const boxX = -(typedBox.getBoundingClientRect().left - rect.left) + this.mouse.x; | ||
const boxY = -(typedBox.getBoundingClientRect().top - rect.top) + this.mouse.y; | ||
typedBox.style.setProperty("--mouse-x", `${boxX}px`); | ||
typedBox.style.setProperty("--mouse-y", `${boxY}px`); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
init() { | ||
this.initContainer(); | ||
window.addEventListener("resize", this.initContainer); | ||
window.addEventListener("mousemove", this.onMouseMove); | ||
} | ||
} | ||
|
||
// Init Highlighter | ||
const highlighters = document.querySelectorAll("[data-highlighter]"); | ||
highlighters.forEach((highlighter) => { | ||
new Highlighter(highlighter); | ||
}); |
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,98 @@ | ||
"use client"; | ||
import React, { useEffect, useRef, useState } from "react"; | ||
import { motion, useTransform, useScroll, useSpring } from "framer-motion"; | ||
import { cn } from "libs/utils"; | ||
|
||
export const TracingBeam = ({ children, className }: { children: React.ReactNode; className?: string }) => { | ||
const ref = useRef<HTMLDivElement>(null); | ||
const { scrollYProgress } = useScroll({ | ||
target: ref, | ||
offset: ["start start", "end start"], | ||
}); | ||
|
||
const contentRef = useRef<HTMLDivElement>(null); | ||
const [svgHeight, setSvgHeight] = useState(0); | ||
|
||
useEffect(() => { | ||
if (contentRef.current) { | ||
setSvgHeight(contentRef.current.offsetHeight); | ||
} | ||
}, []); | ||
|
||
const y1 = useSpring(useTransform(scrollYProgress, [0, 0.8], [50, svgHeight]), { | ||
stiffness: 500, | ||
damping: 90, | ||
}); | ||
const y2 = useSpring(useTransform(scrollYProgress, [0, 1], [50, svgHeight - 200]), { | ||
stiffness: 500, | ||
damping: 90, | ||
}); | ||
|
||
return ( | ||
<motion.div ref={ref} className={cn("relative w-full max-w-4xl mx-auto h-full", className)}> | ||
<div className="absolute -left-8 md:-left-8 top-3"> | ||
<motion.div | ||
transition={{ | ||
duration: 0.2, | ||
delay: 0.5, | ||
}} | ||
animate={{ | ||
boxShadow: scrollYProgress.get() > 0 ? "none" : "rgba(0, 0, 0, 0.24) 0px 3px 8px", | ||
}} | ||
className="ml-[27px] h-4 w-4 rounded-full border border-netural-200 shadow-sm flex items-center justify-center"> | ||
<motion.div | ||
transition={{ | ||
duration: 0.2, | ||
delay: 0.25, | ||
}} | ||
animate={{ | ||
backgroundColor: scrollYProgress.get() > 0 ? "white" : "var(--emerald-500)", | ||
borderColor: scrollYProgress.get() > 0 ? "white" : "var(--emerald-600)", | ||
}} | ||
className="h-2 w-2 rounded-full border border-neutral-300 bg-white" | ||
/> | ||
</motion.div> | ||
<svg | ||
viewBox={`0 0 20 ${svgHeight}`} | ||
width="20" | ||
height={svgHeight} // Set the SVG height | ||
className=" ml-4 block" | ||
aria-hidden="true"> | ||
<motion.path | ||
d={`M 1 0V -36 l 18 24 V ${svgHeight * 0.8} l -18 24V ${svgHeight}`} | ||
fill="none" | ||
stroke="#9091A0" | ||
strokeOpacity="0.16" | ||
transition={{ | ||
duration: 10, | ||
}}></motion.path> | ||
<motion.path | ||
d={`M 1 0V -36 l 18 24 V ${svgHeight * 0.8} l -18 24V ${svgHeight}`} | ||
fill="none" | ||
stroke="url(#gradient)" | ||
strokeWidth="1.25" | ||
className="motion-reduce:hidden" | ||
transition={{ | ||
duration: 10, | ||
}}></motion.path> | ||
<defs> | ||
<motion.linearGradient | ||
id="gradient" | ||
gradientUnits="userSpaceOnUse" | ||
x1="0" | ||
x2="0" | ||
y1={y1} // set y1 for gradient | ||
y2={y2} // set y2 for gradient | ||
> | ||
<stop stopColor="#35d9fa" stopOpacity="0"></stop> | ||
<stop stopColor="#35d9fa"></stop> | ||
<stop offset="0.325" stopColor="#18f495"></stop> | ||
<stop offset="1" stopColor="#022629" stopOpacity="0"></stop> | ||
</motion.linearGradient> | ||
</defs> | ||
</svg> | ||
</div> | ||
<div ref={contentRef}>{children}</div> | ||
</motion.div> | ||
); | ||
}; |
Oops, something went wrong.