import { HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives'
import { Button } from '../../elements/Button'
import { PrimaryDropdown } from '../PrimaryDropdown'
import { LogoBox } from '../../elements/LogoBox'
import { ReactNode, useEffect, useState } from 'react'
import { DEFAULT_HEADER_HEIGHT } from '../homeFeed/HeaderSpacer'
import { theme } from '../../tokens/stitches.config'
import { ReaderSettingsIcon } from '../../elements/icons/ReaderSettingsIcon'
import { CircleUtilityMenuIcon } from '../../elements/icons/CircleUtilityMenuIcon'
function useScrollDirection() {
const [scrollDirection, setScrollDirection] = useState('up')
useEffect(() => {
let lastScrollY = window.pageYOffset
const updateScrollDirection = () => {
const scrollY = window.pageYOffset
const direction = scrollY > lastScrollY ? 'down' : 'up'
if (
direction !== scrollDirection &&
(scrollY - lastScrollY > 10 || scrollY - lastScrollY < -10)
) {
setScrollDirection(direction)
}
lastScrollY = scrollY > 0 ? scrollY : 0
}
window.addEventListener('scroll', updateScrollDirection) // add event listener
return () => {
window.removeEventListener('scroll', updateScrollDirection) // clean up
}
}, [scrollDirection])
return scrollDirection
}
type ReaderHeaderProps = {
alwaysDisplayToolbar: boolean
hideDisplaySettings: boolean
showDisplaySettingsModal: (show: boolean) => void
children?: ReactNode
}
export function ReaderHeader(props: ReaderHeaderProps): JSX.Element {
const scrollDirection = useScrollDirection()
return (
<>
{props.children}
{!props.alwaysDisplayToolbar && !props.hideDisplaySettings && (
)}
>
)
}
function ControlButtonBox(props: ReaderHeaderProps): JSX.Element {
return (
<>
>
)
}