Skip to content

Commit

Permalink
Team feedback round 4
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas committed Oct 9, 2024
1 parent 24cdd37 commit a52f802
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export function ConnectWalletButton({
<Wallet>
<ConnectWallet
withWalletAggregator
className="rounded-none bg-transparent p-2 hover:bg-gray-40/20"
className="rounded-xl bg-transparent p-2 hover:bg-gray-40/20"
>
<UserAvatar />
<Name chain={basenameChain} className={userAddressClasses} />
</ConnectWallet>
<WalletDropdown className="rounded bg-white font-sans shadow-md">
<WalletDropdown className="rounded-xl bg-white font-sans shadow-md">
<Identity className={classNames('px-4 pb-2 pt-3 font-display')}>
<UserAvatar />
<Name
Expand Down
53 changes: 50 additions & 3 deletions apps/web/src/components/ThreeHero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use client';

import * as THREE from 'three';
import { useRef, useMemo, Suspense, useCallback } from 'react';
import { useRef, useMemo, Suspense, useCallback, useState, useEffect } from 'react';
import { Canvas, Euler, useFrame, useThree, Vector3 } from '@react-three/fiber';
import { Lightformer, Environment, Html, Center } from '@react-three/drei';
import {
Expand Down Expand Up @@ -59,10 +59,57 @@ const sceneSphereArguments: [radius: number, widthSegments: number, heightSegmen
7, 64, 64,
];
export default function Scene(): JSX.Element {
const isActive = true;
const [isActive, setIsActive] = useState(true);
const [isIntoView, setIsIntoView] = useState(true);

useEffect(() => {
const handleVisibilityChange = () => {
updateIsActive();
};

const handleFocus = () => {
updateIsActive();
};

const handleBlur = () => {
updateIsActive();
};

const handleScroll = () => {
updateIsActive();
};

const updateIsActive = () => {
const isFocused = !document.hidden && document.hasFocus();
const isScrolledInView = window.pageYOffset < window.innerHeight;
setIsActive(isFocused);
setIsIntoView(isScrolledInView);
};

document.addEventListener('visibilitychange', handleVisibilityChange);
window.addEventListener('focus', handleFocus);
window.addEventListener('blur', handleBlur);
window.addEventListener('scroll', handleScroll);

// Initial check
updateIsActive();

return () => {
document.removeEventListener('visibilitychange', handleVisibilityChange);
window.removeEventListener('focus', handleFocus);
window.removeEventListener('blur', handleBlur);
window.removeEventListener('scroll', handleScroll);
};
}, []);

return (
<Canvas shadows frameloop={isActive ? 'always' : 'never'} camera={sceneCamera}>
<Canvas
shadows
frameloop={isActive && isIntoView ? 'always' : 'never'}
camera={sceneCamera}
className={isIntoView ? 'opacity-100' : 'opacity-0'}
style={{ background: 'transparent' }}
>
<fog attach="fog" args={sceneFogArguments} />

<mesh>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export default function BuildAndRewardSection() {

<div>
<Link href="https://retrofunding.optimism.io/" target="_blank">
<Button
variant={ButtonVariants.Primary}
iconName="baseOrgDiagonalUpArrow"
className="md:ml-auto"
>
<Button variant={ButtonVariants.Primary} iconName="baseOrgDiagonalUpArrow">
Get rewarded
</Button>
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function BuildExploreSection() {
src={docsIllustration as StaticImageData}
alt="Base docs"
title="Base docs illustration"
className="max-h-[4rem]"
/>
<div>
<Text className="mr-2 inline-block">Docs</Text>{' '}
Expand All @@ -38,6 +39,7 @@ export default async function BuildExploreSection() {
src={resourcesIllustration as StaticImageData}
alt="Resources"
title="Resources illustration"
className="max-h-[4rem]"
/>
<div>
<Text className="mr-2 inline-block">Resources</Text>{' '}
Expand All @@ -58,6 +60,7 @@ export default async function BuildExploreSection() {
src={appsIllustration as StaticImageData}
alt="Resources"
title="Resources illustration"
className="max-h-[4rem]"
/>
<div>
<Text className="mr-2 inline-block">Apps</Text>{' '}
Expand All @@ -73,6 +76,7 @@ export default async function BuildExploreSection() {
src={bridgeIllustration as StaticImageData}
alt="Bridge"
title="Bridge illustration"
className="max-h-[4rem]"
/>
<div>
<Text className="mr-2 inline-block">Bridge</Text>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,36 @@ const AnimatedIcon = ({
scale: 1,
opacity: 1,
transition: {
duration: duration / 1000,
delay: delay / 1000,
ease: scaleEasing,
scale: {
duration: duration / 1000,
delay: delay / 1000,
ease: scaleEasing,
},
opacity: {
duration: duration / 2 / 1000, // Faster opacity animation
delay: delay / 1000,
ease: 'easeOut',
},
},
},
};

const pathVariants = {
hidden: { pathLength: 0, opacity: 0 },
hidden: { pathLength: 0.1, opacity: 0 },
visible: (custom: number) => ({
pathLength: 1,
opacity: 1,
transition: {
duration: (duration + custom) / 1000,
delay: delay / 1000,
ease: easing,
pathLength: {
duration: (duration + custom) / 1000,
delay: 0,
ease: easing,
},
opacity: {
duration: (duration + custom) / 3 / 1000, // Faster opacity animation
delay: 0,
ease: 'easeOut',
},
},
}),
};
Expand Down Expand Up @@ -271,52 +285,6 @@ const AnimatedIcon = ({
/>
</motion.svg>
);
case 'about':
return (
<motion.svg
variants={svgVariants}
initial="hidden"
animate="visible"
width="87"
height="87"
viewBox="0 0 87 87"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<motion.path
variants={pathVariants}
custom={0}
d="M43.1858 0V32.5663"
stroke={color}
strokeWidth="2.47787"
strokeMiterlimit="10"
/>
<motion.path
variants={pathVariants}
custom={0}
d="M0 43.1855H32.5663"
stroke={color}
strokeWidth="2.47787"
strokeMiterlimit="10"
/>
<motion.path
variants={pathVariants}
custom={0}
d="M43.1858 86.3709V53.8047"
stroke={color}
strokeWidth="2.47787"
strokeMiterlimit="10"
/>
<motion.path
variants={pathVariants}
custom={0}
d="M86.3714 43.1855H53.8052"
stroke={color}
strokeWidth="2.47787"
strokeMiterlimit="10"
/>
</motion.svg>
);
case 'socials':
return (
<motion.svg
Expand Down Expand Up @@ -395,7 +363,7 @@ const AnimatedIcon = ({
/>
</motion.svg>
);
case 'about2':
case 'about':
return (
<motion.svg
variants={svgVariants}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function MenuDesktop({ links }: MenuDesktopProps) {
}}
>
<Card radius={8} innerClassName="bg-[#191919]">
<div className="flex w-full items-stretch gap-1 p-1">
<div className="flex w-full items-stretch gap-2 rounded-lg bg-[#191919] p-2">
{links[hoverIndex]?.subItems && (
<AnalyticsProvider context={links[hoverIndex].analyticContext}>
<div className="flex flex-1 flex-col">
Expand All @@ -124,7 +124,7 @@ export default function MenuDesktop({ links }: MenuDesktopProps) {
</AnalyticsProvider>
)}
{links[hoverIndex]?.subItems && (
<div className="min-h-[200px] flex-1 basis-0 overflow-hidden p-2">
<div className="min-h-[200px] flex-1 basis-0 overflow-hidden ">
{links[hoverIndex]?.name && (
<div className="flex h-full w-full flex-col items-center justify-center gap-2 rounded-lg bg-black">
{subActive && (
Expand Down

0 comments on commit a52f802

Please sign in to comment.