forked from rajun/ar-test
feat: add customer AR page layout
This commit is contained in:
parent
4934fc3f67
commit
118312d83f
34
app/components/ui/ar-page.tsx
Normal file
34
app/components/ui/ar-page.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { ArLaunchButton } from '~/components/ui/ar-launch-button';
|
||||
import { ArPageHeader } from '~/components/ui/ar-page-header';
|
||||
import { AR_PAGE_DEFAULTS } from '~/data/projects/constants';
|
||||
import { cn } from '~/lib/utils';
|
||||
import type { ArPageLayout, BrandIdentity, ButtonStyle } from '~/types/project';
|
||||
|
||||
// Over the model: placed at an edge, and only the button itself takes touches so the model can still be turned
|
||||
const overlay = (edge: 'top-0' | 'bottom-0') => cn('pointer-events-none absolute inset-x-0 z-10', edge);
|
||||
|
||||
interface ArPageProps {
|
||||
brand?: BrandIdentity;
|
||||
modelName: string;
|
||||
button?: ButtonStyle;
|
||||
layout?: ArPageLayout;
|
||||
launching?: boolean;
|
||||
hint?: string | null;
|
||||
onLaunch?: () => void;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
// The customer-facing AR page layout, shared by the live page and the admin previews.
|
||||
// With the bars off, the model fills the page and the header and button sit over it.
|
||||
export function ArPage({ brand, modelName, button, layout = AR_PAGE_DEFAULTS, launching, hint, onLaunch, className, children }: ArPageProps) {
|
||||
const bars = layout.bars;
|
||||
return (
|
||||
<div className={cn('relative flex flex-col bg-viewer', className)}>
|
||||
<ArPageHeader brand={brand} modelName={modelName} layout={layout} className={bars ? undefined : overlay('top-0')} />
|
||||
<div className={bars ? 'relative min-h-0 flex-1' : 'absolute inset-0'}>{children}</div>
|
||||
<ArLaunchButton style={button} launching={launching} hint={hint} onLaunch={onLaunch} className={bars ? undefined : overlay('bottom-0')} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user