From f04a5e484cea1ffa9a0bb0e39c93934c215e7d92 Mon Sep 17 00:00:00 2001 From: Doh Date: Sat, 4 Jan 2025 12:32:51 -0500 Subject: [PATCH] fix navigation (#20) --- CHANGELOG.md | 6 +++ components/Layout.tsx | 4 +- components/Navigation.tsx | 85 ++++++++++++++++++++++++--------------- package.json | 2 +- 4 files changed, 62 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2476f2c..76d8d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Version 0.1.10 + +### Fixed + +- fix navigation + ## Version 0.1.9 ### Fixed diff --git a/components/Layout.tsx b/components/Layout.tsx index bcf52b2..8f0eaa7 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -7,12 +7,12 @@ export default function Layout({ children }: { children: React.ReactNode }) {
- +
{children}
- +
diff --git a/components/Navigation.tsx b/components/Navigation.tsx index f68f623..b20c7e9 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -2,9 +2,11 @@ import Link from 'next/link' import { Home, Calendar, List, Gift, Coins, Settings, Info } from 'lucide-react' -import { useState } from 'react' +import { useEffect, useState } from 'react' import AboutModal from './AboutModal' +type ViewPort = 'main' | 'mobile' + const navItems = [ { icon: Home, label: 'Dashboard', href: '/', position: 'main' }, { icon: List, label: 'Habits', href: '/habits', position: 'main' }, @@ -16,18 +18,35 @@ const navItems = [ interface NavigationProps { className?: string - isMobile?: boolean + viewPort: ViewPort } -export default function Navigation({ className, isMobile = false }: NavigationProps) { +export default function Navigation({ className, viewPort }: NavigationProps) { const [showAbout, setShowAbout] = useState(false) - if (isMobile) { + const [isMobileView, setIsMobileView] = useState(false) + + useEffect(() => { + const handleResize = () => { + setIsMobileView(window.innerWidth < 1024) + } + + // Set initial value + handleResize() + + // Add event listener + window.addEventListener('resize', handleResize) + + // Cleanup + return () => window.removeEventListener('resize', handleResize) + }, []) + + if (viewPort === 'mobile' && isMobileView) { return ( <>
{/* Add padding at the bottom to prevent content from being hidden */} -
- +
+ setShowAbout(false)} /> - setShowAbout(false)} /> - - ) + ) + } } diff --git a/package.json b/package.json index 6baed27..6d6f156 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "habittrove", - "version": "0.1.8", + "version": "0.1.10", "private": true, "scripts": { "dev": "next dev --turbopack",