use ui back button for non tma mode
This commit is contained in:
parent
12686f0712
commit
0bc83446b5
@ -1,14 +1,22 @@
|
||||
'use client';
|
||||
|
||||
import { UpdateProfile } from '@/components/auth';
|
||||
import { BottomNav } from '@/components/navigation';
|
||||
import { EmptyProvider } from '@/providers/empty';
|
||||
import { TelegramProvider } from '@/providers/telegram';
|
||||
import { isTMA } from '@telegram-apps/sdk-react';
|
||||
import { type PropsWithChildren } from 'react';
|
||||
|
||||
export default async function Layout({ children }: Readonly<PropsWithChildren>) {
|
||||
export default function Layout({ children }: Readonly<PropsWithChildren>) {
|
||||
const isTG = isTMA('simple');
|
||||
|
||||
const Provider = isTG ? TelegramProvider : EmptyProvider;
|
||||
|
||||
return (
|
||||
<TelegramProvider>
|
||||
<Provider>
|
||||
<UpdateProfile />
|
||||
<main className="grow">{children}</main>
|
||||
<BottomNav />
|
||||
</TelegramProvider>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,11 +1,21 @@
|
||||
'use client';
|
||||
import { BackButton } from './back-button';
|
||||
import { cn } from '@repo/ui/lib/utils';
|
||||
import { isTMA } from '@telegram-apps/sdk-react';
|
||||
|
||||
type Props = { title: string | undefined };
|
||||
|
||||
export function PageHeader(props: Readonly<Props>) {
|
||||
const isTG = isTMA('simple');
|
||||
|
||||
return (
|
||||
<div className="sticky top-0 z-50 flex h-12 items-center rounded-b-lg bg-transparent px-4 font-bold tracking-wide backdrop-blur-md">
|
||||
{/* <BackButton /> */}
|
||||
<div
|
||||
className={cn(
|
||||
'sticky top-0 z-50 flex h-12 items-center rounded-b-lg bg-transparent font-bold tracking-wide backdrop-blur-md',
|
||||
isTG ? 'px-4' : 'px-2',
|
||||
)}
|
||||
>
|
||||
{!isTG && <BackButton />}
|
||||
{props.title}
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -21,10 +21,12 @@ export function useBackButton() {
|
||||
}, [onBackClick]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isRootLevelPage(pathname)) {
|
||||
backButton.hide();
|
||||
} else {
|
||||
backButton.show();
|
||||
if (backButton.isMounted()) {
|
||||
if (isRootLevelPage(pathname)) {
|
||||
backButton.hide();
|
||||
} else {
|
||||
backButton.show();
|
||||
}
|
||||
}
|
||||
}, [pathname]);
|
||||
}
|
||||
|
||||
5
apps/web/providers/empty.tsx
Normal file
5
apps/web/providers/empty.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import { type PropsWithChildren } from 'react';
|
||||
|
||||
export function EmptyProvider({ children }: Readonly<PropsWithChildren>) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user