omnivore/packages/web/components/templates/reader/ReaderHeader.tsx

126 lines
3.4 KiB
TypeScript
Raw Normal View History

import { HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives'
2023-02-27 01:49:49 +00:00
import { Button } from '../../elements/Button'
import { DotsThreeOutline, TextAa } from 'phosphor-react'
2023-02-25 11:31:06 +00:00
import { PrimaryDropdown } from '../PrimaryDropdown'
import { TooltipWrapped } from '../../elements/Tooltip'
import { LogoBox } from '../../elements/LogoBox'
2023-03-02 09:04:31 +00:00
import { ReactNode } from 'react'
import { HEADER_HEIGHT } from '../homeFeed/HeaderSpacer'
import { theme } from '../../tokens/stitches.config'
2023-02-25 11:31:06 +00:00
2023-02-27 07:37:00 +00:00
type ReaderHeaderProps = {
alwaysDisplayToolbar: boolean
hideDisplaySettings: boolean
2023-02-27 07:37:00 +00:00
showDisplaySettingsModal: (show: boolean) => void
2023-03-02 09:04:31 +00:00
children?: ReactNode
2023-02-27 07:37:00 +00:00
}
export function ReaderHeader(props: ReaderHeaderProps): JSX.Element {
2023-02-25 11:31:06 +00:00
return (
<>
<VStack
alignment="center"
distribution="start"
css={{
top: '0',
left: '0',
zIndex: 1,
pt: '0px',
2023-02-25 11:31:06 +00:00
position: 'fixed',
width: '100%',
height: HEADER_HEIGHT,
display: props.alwaysDisplayToolbar ? 'flex' : 'transparent',
2023-05-30 08:18:11 +00:00
pointerEvents: props.alwaysDisplayToolbar ? 'unset' : 'none',
borderBottom: props.alwaysDisplayToolbar
? '1px solid $thBorderColor'
: '1px solid transparent',
'@xlgDown': {
bg: '$readerMargin',
pointerEvents: 'unset',
2023-03-03 04:15:02 +00:00
borderBottom: '1px solid $thBorderColor',
2023-02-25 11:31:06 +00:00
},
'@mdDown': {
bg: '$readerBg',
pointerEvents: 'unset',
},
2023-06-27 10:27:45 +00:00
'@media print': {
display: 'none',
},
2023-02-25 11:31:06 +00:00
}}
>
<HStack
alignment="center"
distribution="start"
css={{
width: '100%',
height: '100%',
}}
>
<LogoBox />
2023-03-03 13:55:04 +00:00
<SpanBox
css={{
width: '100%',
px: '25px',
'@lg': {
display: props.alwaysDisplayToolbar ? 'flex' : 'none',
},
2023-03-03 13:55:04 +00:00
'@mdDown': { px: '15px' },
}}
>
{props.children}
</SpanBox>
{!props.alwaysDisplayToolbar && !props.hideDisplaySettings && (
<SpanBox
css={{
width: '100%',
'@lgDown': {
display: 'none',
},
}}
>
<ControlButtonBox {...props} />
</SpanBox>
)}
2023-02-25 11:31:06 +00:00
</HStack>
</VStack>
</>
)
}
2023-02-27 07:37:00 +00:00
function ControlButtonBox(props: ReaderHeaderProps): JSX.Element {
2023-02-25 11:31:06 +00:00
return (
<>
<HStack
alignment="center"
distribution="end"
css={{
marginLeft: 'auto',
marginRight: '25px',
2023-02-25 11:31:06 +00:00
width: '100px',
height: '100%',
gap: '20px',
minWidth: '121px',
2023-05-25 12:16:55 +00:00
pointerEvents: 'all',
2023-02-25 11:31:06 +00:00
}}
>
<Button
style="articleActionIcon"
2023-02-27 07:37:00 +00:00
onClick={() => {
props.showDisplaySettingsModal(true)
}}
2023-02-25 11:31:06 +00:00
>
<TooltipWrapped tooltipContent="Reader Preferences (d)">
<TextAa size={25} color={theme.colors.thHighContrast.toString()} />
2023-02-25 11:31:06 +00:00
</TooltipWrapped>
</Button>
<PrimaryDropdown showThemeSection={false}>
<DotsThreeOutline
size={25}
color={theme.colors.thHighContrast.toString()}
/>
2023-02-27 07:29:43 +00:00
</PrimaryDropdown>
2023-02-25 11:31:06 +00:00
</HStack>
</>
)
}