-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into basic-sections
- Loading branch information
Showing
9 changed files
with
171 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"use client"; | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import Image from 'next/image'; | ||
import LugeReact from "./luge"; | ||
|
||
/** | ||
* | ||
* Documentation: https://luge.cool/docs/custom-cursor/ | ||
* Compatibility with Next.js Discussion: https://github.com/AntoineW/luge/discussions/9 | ||
* | ||
* The day that Luge becomes deprecated or starts to break, cause problems, etc., it must be removed. | ||
* | ||
* 1. pnpm uninstall @waaark/luge | ||
* 2. Delete the TrailEffect component | ||
* 3. Delete all instances of data-lg-[...] in global.css | ||
*/ | ||
const TrailEffect = () => { | ||
return ( | ||
<> | ||
<LugeReact /> | ||
<div data-lg-cursor data-lg-cursor-hide> | ||
<div data-lg-cursor-trail data-lg-cursor-trail-length="20" data-lg-cursor-inertia="0.4"></div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
const Cursor = () => { | ||
const [position, setPosition] = useState({ x: 0, y: 0 }); | ||
|
||
const [isPointer, setIsPointer] = useState(false); | ||
|
||
const handleMouseMove = (e: any) => { | ||
setPosition({ x: e.clientX, y: e.clientY }); | ||
|
||
const target = e.target; | ||
|
||
setIsPointer( | ||
window.getComputedStyle(target).getPropertyValue("cursor") === "pointer" | ||
); | ||
// target.style.cursor = "none"; | ||
|
||
e.stopPropagation(); | ||
}; | ||
|
||
useEffect(() => { | ||
window.addEventListener("mousemove", handleMouseMove); | ||
|
||
return () => window.removeEventListener("mousemove", handleMouseMove); | ||
}, []); | ||
|
||
const YSize = isPointer ? -100 : 100; | ||
const XSize = isPointer ? -100 : 20; | ||
const rotationAngle = isPointer ? 0 : 315; | ||
const topPos = (position.y - YSize / 4) + 10; | ||
const leftPos = (position.x - XSize / 4) + 30; | ||
|
||
const hasNotMoved = position.x === 0 && position.y === 0; | ||
|
||
return ( | ||
<> | ||
<TrailEffect /> | ||
<Image | ||
src={"/landing/wand.png"} | ||
alt="Custom Cursor" | ||
width={XSize} | ||
height={YSize} | ||
className="select-none z-50" | ||
style={{ | ||
display: hasNotMoved ? "none" : "block", | ||
transform: `rotate(${rotationAngle}deg)`, | ||
position: "fixed", | ||
left: `${leftPos}px`, | ||
top: `${topPos}px`, | ||
pointerEvents: "none", | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default Cursor; |
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,27 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
|
||
import '@/node_modules/@waaark/luge/dist/css/luge.css'; | ||
|
||
/** | ||
* This is for the trailing effect for the wand in the Cursor component. | ||
* | ||
* Delete this when necessary. This adds a whole another library to this project | ||
* and we don't need the clutter later on if we don't need it. | ||
* | ||
* But magic wand trail effect is very cool. So we keep for Spring '24. | ||
*/ | ||
|
||
const LugeReact = () => { | ||
useEffect(() => { | ||
import('@waaark/luge/dist/js/luge') | ||
.then((luge) => { | ||
luge.lifecycle.refresh(); | ||
}) | ||
.catch((error) => console.error(error)); | ||
}); | ||
|
||
return null; | ||
}; | ||
|
||
export default LugeReact; |
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.
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
Oops, something went wrong.