Skip to content

Commit 4bd1605

Browse files
committed
minimize header on scroll
1 parent 1b06084 commit 4bd1605

6 files changed

Lines changed: 52 additions & 14 deletions

File tree

devconnect-app/src/app/quests/AppShowcaseDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export default function AppShowcaseDetail({
227227
const questElement = questRefs.current[quest.id];
228228
if (questElement) {
229229
// Calculate offset to account for sticky tabs and menu
230-
const stickyTabsHeight = pwa === true ? 118 : 59; // PWA mode: 118px, regular mode: 59px
230+
const stickyTabsHeight = pwa === true ? 118 : 48; // PWA mode: 118px, regular mode: 59px
231231
const menuHeight = 30; // Additional 30px for menu
232232
const elementTop = questElement.offsetTop;
233233
const offsetPosition =
@@ -584,7 +584,7 @@ export default function AppShowcaseDetail({
584584
<div
585585
className="bg-white border-b border-gray-200 w-full px-4 z-20 sticky"
586586
style={{
587-
top: pwa === true ? '118px' : '59px', // PWA mode: 118px, regular mode: 59px
587+
top: pwa === true ? '118px' : '48px', // PWA mode: 118px, regular mode: 59px
588588
transform: 'translate3d(0, 0, 0)', // Force hardware acceleration for smooth rendering
589589
}}
590590
>

devconnect-app/src/app/schedule/page-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function ProgrammePageContent({
3131
const [favoriteEvents, toggleFavoriteEvent] = useFavorites();
3232

3333
return (
34-
<PageLayout title="Schedule" tabs={homeTabs()}>
34+
<PageLayout title="World's Fair" tabs={homeTabs()}>
3535
<div className={cn('text-left touch-only:px-0 p-4', css['schedule-tab'])}>
3636
<ScheduleLayout
3737
isCommunityCalendar={false}

devconnect-app/src/app/tickets/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default function TicketTab() {
119119
}, [email]);
120120

121121
return (
122-
<PageLayout title="Your Tickets" tabs={homeTabs()}>
122+
<PageLayout title="World's Fair" tabs={homeTabs()}>
123123
<div className="w-full py-6 sm:py-8 px-4 sm:px-6 max-w-4xl mx-auto">
124124
<div className="w-full mb-8">
125125
{ticketError && (

devconnect-app/src/components/PageLayout.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import Link from 'next/link';
88
import cn from 'classnames';
99
import { useRouter } from 'next/navigation';
1010
// import { sessionIdAtom } from '@/store/sessionId';
11-
import { ArrowBigLeft, Blend as AppIcon } from 'lucide-react';
11+
import { ArrowBigLeft, Blend as AppIcon, Undo2 } from 'lucide-react';
1212
import Menu from '@/components/MobileMenu';
1313
import { useIsMobile } from '@/hooks/useIsMobile';
14+
import { useIsScrolled } from 'lib/hooks/useIsScrolled';
1415

1516
interface TabItem {
1617
label: string;
@@ -65,7 +66,7 @@ const BackButton = () => {
6566
return (
6667
<div
6768
className={cn(
68-
'lg:w-[30px] flex w-[20px] justify-start items-center text-xl shrink-0 transition-all duration-300 absolute left-0',
69+
'lg:w-[30px] flex w-[20px] justify-start items-center text-xl shrink-0 absolute left-0',
6970
canBack && 'hover:scale-110'
7071
)}
7172
>
@@ -74,7 +75,7 @@ const BackButton = () => {
7475
onClick={handleBackClick}
7576
className="flex items-center cursor-pointer select-none"
7677
>
77-
<ArrowBigLeft
78+
<Undo2
7879
style={{
7980
fontSize: 16,
8081
// transform: 'rotateY(180deg)', // Apply 180-degree rotation on the X-axis
@@ -93,6 +94,7 @@ const Tabs = ({
9394
activeIndex,
9495
setActiveIndex,
9596
onTabClick,
97+
className,
9698
}: TabsProps) => {
9799
const router = useRouter();
98100
const pathname = usePathname();
@@ -110,7 +112,10 @@ const Tabs = ({
110112

111113
return (
112114
<div
113-
className={`py-4 md:py-2 flex items-center justify-center md:rounded overflow-auto w-full`}
115+
className={cn(
116+
'py-2 md:py-2 flex items-center justify-center md:rounded overflow-auto w-full',
117+
className
118+
)}
114119
>
115120
<div className="flex md:rounded w-[fit-content] shrink-0 flex gap-2">
116121
{tabs.map((tab, idx) => {
@@ -176,6 +181,8 @@ export default function PageLayout({
176181
const activeTab = tabs[activeIndex];
177182
const isMobile = useIsMobile();
178183

184+
const isScrolled = useIsScrolled(20);
185+
179186
return (
180187
<>
181188
{/* Mobile layout */}
@@ -188,18 +195,27 @@ export default function PageLayout({
188195
{title && (
189196
<div
190197
data-page="Header"
191-
className="w-full shrink-0 relative backdrop-blur-xs flex flex-col items-start px-4 gap-5 sticky top-0 z-[999999]"
198+
className={cn(
199+
'w-full shrink-0 relative flex flex-col items-start transition-transform text-white translate-y-[0px] duration-300 px-4 gap-5 sticky top-0 z-[999998]',
200+
isScrolled ? '!translate-y-[-10px] !text-black' : ''
201+
)}
192202
style={{
193-
background: `radial-gradient(196.3% 65.93% at 98.09% -7.2%, rgba(246, 180, 14, 0.30) 0%, rgba(246, 180, 14, 0.00) 100%),
203+
background: isScrolled
204+
? 'white'
205+
: `radial-gradient(196.3% 65.93% at 98.09% -7.2%, rgba(246, 180, 14, 0.30) 0%, rgba(246, 180, 14, 0.00) 100%),
194206
radial-gradient(71.21% 71.21% at 50% 71.21%, rgba(36, 36, 54, 0.20) 0%, rgba(36, 36, 54, 0.00) 100%),
195207
linear-gradient(263deg, rgba(246, 180, 14, 0.30) 2.9%, rgba(45, 45, 66, 0.30) 58.72%, rgba(36, 36, 54, 0.30) 100.39%),
196208
linear-gradient(98deg, rgba(116, 172, 223, 0.80) -7.48%, rgba(73, 129, 180, 0.80) 43.5%, rgba(255, 133, 166, 0.80) 122.37%)`,
197209
backgroundBlendMode: 'normal, normal, overlay, normal',
198-
backdropFilter: 'blur(4px)',
210+
backdropFilter: isScrolled ? 'blur(0px)' : 'blur(4px)',
199211
paddingTop: 'calc(0px + max(0px, env(safe-area-inset-top)))',
200212
}}
201213
>
202-
<div className="relative flex items-center justify-center w-full gap-3 text-white text-lg font-bold h-[59px]">
214+
<div
215+
className={cn(
216+
'relative flex items-center transition-transform duration-300 h-[59px] translate-y-[0px] justify-center w-full gap-3 font-medium'
217+
)}
218+
>
203219
<BackButton />
204220
{title}
205221
</div>
@@ -208,7 +224,10 @@ export default function PageLayout({
208224

209225
{tabs.length > 1 && (
210226
<div
211-
className="px-4 text-lg font-bold border-b border-b-solid border-[#8855CC26] sticky bg-white md:rounded-t-sm z-[999998]"
227+
className={cn(
228+
'px-4 text-lg z-[1] font-bold border-b border-b-solid border-[#8855CC26] transition-transform translate-y-[0px] duration-300 sticky bg-white md:rounded-t-sm z-[999999]',
229+
isScrolled ? '!translate-y-[-25px]' : ''
230+
)}
212231
style={{
213232
top: 'calc(59px + max(0px, env(safe-area-inset-top)))',
214233
}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.layout-app {
22
[data-type="list-day-header"] {
3-
top: calc(59px + max(0px, env(safe-area-inset-top)));
3+
top: calc(81px + max(0px, env(safe-area-inset-top)));
44
}
55
}

lib/hooks/useIsScrolled.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useEffect, useState } from 'react';
2+
3+
export function useIsScrolled(threshold: number = 0) {
4+
const [isScrolled, setIsScrolled] = useState(false);
5+
6+
useEffect(() => {
7+
const handleScroll = () => {
8+
setIsScrolled(window.scrollY > threshold);
9+
};
10+
11+
// Check initial scroll position
12+
handleScroll();
13+
14+
window.addEventListener('scroll', handleScroll);
15+
return () => window.removeEventListener('scroll', handleScroll);
16+
}, [threshold]);
17+
18+
return isScrolled;
19+
}

0 commit comments

Comments
 (0)