-
Notifications
You must be signed in to change notification settings - Fork 22
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 #50 from jarrisondev/fix-multicursor-bugs
Fix multicursor bugs
- Loading branch information
Showing
11 changed files
with
176 additions
and
251 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,22 @@ | ||
"use client"; | ||
|
||
import React from 'react' | ||
import { Nav } from './Nav' | ||
import { WelcomeHero } from './WelcomeHero' | ||
import { Sponsors } from './Sponsors' | ||
|
||
export default function Hero() { | ||
return ( | ||
<div className="flex mb-32 flex-col gap-[72px]"> | ||
<div className="bg-caBlurBoxes absolute left-[-100px] top-80 h-[200px] w-[200px] blur-[200px] sm:h-[300px] sm:w-[300px]"></div> | ||
<div className="bg-pattern relative flex w-full flex-col gap-[74px] overflow-hidden px-2 pt-4"> | ||
<div className="w-full absolute -bottom-20 h-[200px]"></div> | ||
<div className="bg-caBlurBoxes absolute right-[-100px] top-20 h-[400px] w-[200px] blur-[200px] sm:h-[300px] sm:w-[300px]"></div> | ||
<Nav /> | ||
<WelcomeHero /> | ||
<Sponsors /> | ||
</div> | ||
</div> | ||
|
||
) | ||
} |
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,14 +1,46 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
import { useCursors } from "app/cursors-context"; | ||
import { Button } from "./ui/button"; | ||
import Logo from "app/components/icons/Logo"; | ||
import { cn } from "./utils"; | ||
|
||
export const Nav = () => { | ||
const { cursors, disabled, setDisabled } = useCursors(); | ||
|
||
const slice = 3; | ||
const cursorsSlice = cursors.slice(-slice); | ||
|
||
const imgCircleClass = cn('relative rounded-full h-8 w-8 ring-2 ring-white overflow-hidden group-hover:ring-[3px]') | ||
|
||
return ( | ||
<nav className="relative px-2 w-full max-w-6xl h-16 mx-auto flex items-center justify-between"> | ||
<a href="/" className="flex items-center gap-1 cursor-pointer"> | ||
<Logo /> | ||
<h1 className="text-2xl text-white font-semibold">Aforshow</h1> | ||
</a> | ||
<Button>Inscribirse</Button> | ||
<div className="flex items-center gap-5 h-full"> | ||
<div | ||
className={cn('group flex -space-x-3 hover:cursor-pointer overflow-hidden p-2', {"opacity-70": disabled})} | ||
onClick={() => { | ||
if (setDisabled) setDisabled((prev) => !prev); | ||
}}> | ||
{ | ||
cursorsSlice.map((cursor) => ( | ||
<div key={cursor.id} className={imgCircleClass}> | ||
<img className="scale-[1.7] absolute top-0 left-0" src={cursor.flagUrl} alt="" /> | ||
</div> | ||
)) | ||
} | ||
{ | ||
cursors.length > slice && ( | ||
<div className={cn(imgCircleClass, 'flex items-center justify-center bg-[#121112]')}> | ||
<span className="text-white font-semibold">+{cursors.length - slice}</span> | ||
</div> | ||
) | ||
} | ||
</div> | ||
<Button>Inscribirse</Button> | ||
</div> | ||
</nav> | ||
); | ||
}; |
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,42 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { useCursors } from "./cursors-context"; | ||
import OtherCursor from "./other-cursor"; | ||
|
||
export default function Cursors() { | ||
const { cursors, disabled } = useCursors(); | ||
const [windowDimensions, setWindowDimensions] = useState({ | ||
width: 0, | ||
height: 0, | ||
}); | ||
|
||
useEffect(() => { | ||
const onResize = () => { | ||
setWindowDimensions({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
}; | ||
window.addEventListener("resize", onResize); | ||
onResize(); | ||
return () => { | ||
window.removeEventListener("resize", onResize); | ||
}; | ||
}, []); | ||
|
||
|
||
const cursorsSliced = disabled ? [] : cursors.slice(-15); | ||
|
||
return ( | ||
<div className="absolute h-full w-full pointer-events-none overflow-hidden"> | ||
{cursorsSliced.map((cursor) => ( | ||
<OtherCursor | ||
key={cursor.id} | ||
cursor={cursor} | ||
windowDimensions={windowDimensions} | ||
/> | ||
))} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.