({
user,
onOpenSettings,
currentLocale,
}: MobileHeaderProps)
| 20 | } |
| 21 | |
| 22 | export const MobileHeader = ({ |
| 23 | user, |
| 24 | onOpenSettings, |
| 25 | currentLocale, |
| 26 | }: MobileHeaderProps) => { |
| 27 | const { isRwMarkable } = useAppMode(); |
| 28 | const [isScrolled, setIsScrolled] = useState(true); |
| 29 | const [scrollPos, setScrollPos] = useState(0); |
| 30 | const lastScrollY = useRef(0); |
| 31 | const router = useRouter(); |
| 32 | const t = useTranslations(); |
| 33 | |
| 34 | useEffect(() => { |
| 35 | const handleGlobalScroll = (e: Event) => { |
| 36 | handleScroll(e, "jotty-scrollable-content", setIsScrolled, lastScrollY); |
| 37 | setScrollPos(lastScrollY.current); |
| 38 | }; |
| 39 | |
| 40 | window.addEventListener("scroll", handleGlobalScroll, true); |
| 41 | |
| 42 | return () => { |
| 43 | window.removeEventListener("scroll", handleGlobalScroll, true); |
| 44 | }; |
| 45 | }, []); |
| 46 | |
| 47 | const handleLogout = async () => { |
| 48 | await logout(); |
| 49 | router.push("/auth/login"); |
| 50 | }; |
| 51 | |
| 52 | const mobileHeaderClasses = cn( |
| 53 | "w-full z-30 border-transparent border-b border-border -mt-20", |
| 54 | `lg:hidden flex items-center justify-between w-full py-3 px-4 transition-all duration-300 ease-in-out`, |
| 55 | scrollPos < 150 |
| 56 | ? "relative bg-background !mt-0 !max-w-[100%] !left-0" |
| 57 | : "fixed max-w-[80%] mt-5 left-[10%] border rounded-jotty bg-muted", |
| 58 | isScrolled && scrollPos > 500 ? "mt-5" : scrollPos > 500 && "-mt-20", |
| 59 | ); |
| 60 | |
| 61 | return ( |
| 62 | <div className={mobileHeaderClasses}> |
| 63 | <a href="/" className="flex items-center gap-3"> |
| 64 | <div className="relative"> |
| 65 | <DynamicLogo className="h-10 w-10" /> |
| 66 | <ConnectionIndicator |
| 67 | borderColor={scrollPos < 150 ? "border-background" : "border-muted"} |
| 68 | /> |
| 69 | </div> |
| 70 | <div className="flex items-center gap-2"> |
| 71 | <AppName |
| 72 | className="text-2xl font-bold text-foreground jotty-app-name" |
| 73 | fallback={isRwMarkable ? "rwMarkable" : "jotty·page"} |
| 74 | /> |
| 75 | </div> |
| 76 | </a> |
| 77 | |
| 78 | {user ? ( |
| 79 | <div className="flex items-center gap-2"> |
nothing calls this directly
no test coverage detected