feat(mobile): move journal date picker into page header (#8968)

This commit is contained in:
CatsJuice 2024-12-02 02:05:04 +00:00
parent 1c9bd204cd
commit 372dbf5ec8
No known key found for this signature in database
GPG Key ID: 1C1E76924FAFDDE4
3 changed files with 25 additions and 22 deletions

View File

@ -44,6 +44,15 @@ export interface PageHeaderProps
prefixStyle?: React.CSSProperties; prefixStyle?: React.CSSProperties;
suffixClassName?: string; suffixClassName?: string;
suffixStyle?: React.CSSProperties; suffixStyle?: React.CSSProperties;
/**
* Custom bottom content
*/
bottom?: ReactNode;
/**
* Bottom Spacer height
*/
bottomSpacer?: number;
} }
export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>( export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
function PageHeader( function PageHeader(
@ -59,6 +68,8 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
prefixStyle, prefixStyle,
suffixClassName, suffixClassName,
suffixStyle, suffixStyle,
bottom,
bottomSpacer,
...attrs ...attrs
}, },
ref ref
@ -120,11 +131,13 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
{suffix} {suffix}
</section> </section>
</header> </header>
{bottom}
</SafeArea> </SafeArea>
{/* Spacer */} {/* Spacer */}
<SafeArea top> <SafeArea top>
<div className={styles.headerSpacer} /> <div className={styles.headerSpacer} />
{bottom ? <div style={{ height: bottomSpacer ?? 0 }} /> : null}
</SafeArea> </SafeArea>
</> </>
); );

View File

@ -94,14 +94,6 @@ export const journalIconButton = style({
display: 'flex', display: 'flex',
}); });
export const journalDatePickerSticky = style({ export const journalDatePicker = style({
background: cssVarV2('layer/background/primary'), background: cssVarV2('layer/background/primary'),
position: 'sticky',
zIndex: 1,
top: 56,
selectors: {
'&[data-standalone]': {
top: 'calc(44px + env(safe-area-inset-top, 12px))',
},
},
}); });

View File

@ -253,6 +253,17 @@ const MobileDetailPage = ({
<PageHeaderMenuButton /> <PageHeaderMenuButton />
</> </>
} }
bottom={
date ? (
<JournalDatePicker
date={date}
onChange={handleDateChange}
withDotDates={allJournalDates}
className={styles.journalDatePicker}
/>
) : null
}
bottomSpacer={94}
> >
{date ? ( {date ? (
<span className={bodyEmphasized}> <span className={bodyEmphasized}>
@ -260,19 +271,6 @@ const MobileDetailPage = ({
</span> </span>
) : null} ) : null}
</PageHeader> </PageHeader>
{date ? (
<JournalDatePicker
date={date}
onChange={handleDateChange}
withDotDates={allJournalDates}
className={styles.journalDatePickerSticky}
data-standalone={
environment.isPwa || BUILD_CONFIG.isAndroid || BUILD_CONFIG.isIOS
? ''
: undefined
}
/>
) : null}
<DetailPageImpl /> <DetailPageImpl />
{date ? ( {date ? (
<AppTabs background={cssVarV2('layer/background/primary')} /> <AppTabs background={cssVarV2('layer/background/primary')} />