-
Notifications
You must be signed in to change notification settings - Fork 7
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
17 changed files
with
155 additions
and
68 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
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
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
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,40 @@ | ||
import useMouseMove from "@/hooks/useMouseMove"; | ||
import type { ReactNode } from "react"; | ||
|
||
export default function Background({ children }: { children: ReactNode }) { | ||
useMouseMove(); | ||
return ( | ||
<> | ||
<div className="-z-50 fixed top-0 left-0"> | ||
<div className="sticky top-0 left-0 h-screen w-screen overflow-hidden"> | ||
<div className="absolute inset-0 z-[-1] bg-muted-foreground/15" /> | ||
<div className="-translate-x-1/2 -translate-y-1/2 absolute top-[--y] left-[--x] z-[-1] h-56 w-56 rounded-full bg-gradient-radial from-0% from-muted-foreground/40 to-90% to-transparent blur-md" /> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"> | ||
<defs> | ||
<pattern | ||
id="dotted-pattern" | ||
width="16" | ||
height="16" | ||
patternUnits="userSpaceOnUse" | ||
> | ||
<circle cx="2" cy="2" r="1" fill="black" /> | ||
</pattern> | ||
<mask id="dots-mask"> | ||
<rect width="100%" height="100%" fill="white" /> | ||
<rect width="100%" height="100%" fill="url(#dotted-pattern)" /> | ||
</mask> | ||
</defs> | ||
<rect | ||
width="100%" | ||
height="100%" | ||
fill="hsl(var(--background))" | ||
mask="url(#dots-mask)" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
|
||
{children} | ||
</> | ||
); | ||
} |
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,26 @@ | ||
import React from "react"; | ||
|
||
export default function useMouseMove() { | ||
React.useEffect(() => { | ||
function mouseMoveEvent(e: MouseEvent) { | ||
const scale = window.visualViewport?.scale; | ||
// disable mouse movement on viewport zoom - causes page to slow down | ||
if (scale === 1) { | ||
const body = document.body; | ||
|
||
const targetX = e.clientX; | ||
const targetY = e.clientY; | ||
|
||
// TODO: make it move around cursor so you feal like its floating around it | ||
// the animation requires tranformX and transformY on the HTML Element | ||
body.style.setProperty("--x", `${targetX}px`); | ||
body.style.setProperty("--y", `${targetY}px`); | ||
} | ||
} | ||
|
||
document.addEventListener("mousemove", mouseMoveEvent); | ||
return () => { | ||
document.removeEventListener("mousemove", mouseMoveEvent); | ||
}; | ||
}, []); | ||
} |
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.