Edge-to-edge mobile layout with safe-area insets
The public menu (and editor) left a non-matching rectangular gap around the iPhone notch / dynamic island. Make the glassmorphism background go edge-to-edge while keeping interactive content clear of the unsafe regions. - viewport-fit=cover so the layout uses the full screen incl. behind the island - Safe-area utility classes (globals.css) built on env(safe-area-inset-*); they resolve to 0 on devices without insets, preserving previous spacing - Public menu: header padding-top, sticky section tabs offset, and floating action buttons (Ask AI / +) respect top/bottom insets - Editor: header padding-top and bottom tab bar respect top/bottom insets Verified: build passes; all safe-area classes survive Tailwind purge; rendered meta tag emits viewport-fit=cover.
This commit is contained in:
1 parent
9fad1d43aa
commit
d71ede3d00
4 files changed
+35
-5
No files matched your search
@@ -92,3 +92,30 @@ body {
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
/* Safe-area helpers for edge-to-edge layout (viewport-fit=cover).
|
||||
The background covers behind the notch / dynamic island and gesture bar, while
|
||||
interactive content is padded so it isn't covered. On devices without insets
|
||||
env() resolves to 0, so spacing matches the previous values. */
|
||||
@layer utilities {
|
||||
/* public menu header */
|
||||
.safe-pt-header {
|
||||
padding-top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
|
||||
}
|
||||
/* editor header */
|
||||
.safe-pt-editor {
|
||||
padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
|
||||
}
|
||||
/* sticky section tabs keep clear of the island when scrolled */
|
||||
.safe-top-sticky {
|
||||
top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
|
||||
}
|
||||
/* public floating action buttons clear the gesture bar */
|
||||
.safe-bottom-fab {
|
||||
bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
|
||||
}
|
||||
/* editor bottom tab bar clears the gesture bar */
|
||||
.safe-pb-tabbar {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ export const viewport: Viewport = {
|
||||
initialScale: 1,
|
||||
maximumScale: 1,
|
||||
themeColor: '#f4f1ec',
|
||||
// Use the full screen incl. the area behind the notch / dynamic island so the
|
||||
// glassmorphism background goes edge-to-edge; content respects safe areas via CSS.
|
||||
viewportFit: 'cover',
|
||||
};
|
||||
|
||||
export default async function RootLayout({
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function Editor({ data, baseUrl }: { data: EditorData; baseUrl: s
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="mx-auto min-h-screen max-w-2xl px-4 pb-28 pt-4">
|
||||
<div className="safe-pt-editor mx-auto min-h-screen max-w-2xl px-4 pb-28">
|
||||
<header className="mb-3 flex items-center justify-between gap-2">
|
||||
<div>
|
||||
<h1 className="display text-xl font-semibold leading-tight">{data.name}</h1>
|
||||
@@ -67,7 +67,7 @@ export default function Editor({ data, baseUrl }: { data: EditorData; baseUrl: s
|
||||
)}
|
||||
|
||||
{/* Bottom tab bar */}
|
||||
<nav className="glass fixed bottom-0 left-1/2 z-30 flex w-full max-w-2xl -translate-x-1/2 items-stretch justify-around rounded-t-3xl px-2 py-2">
|
||||
<nav className="glass safe-pb-tabbar fixed bottom-0 left-1/2 z-30 flex w-full max-w-2xl -translate-x-1/2 items-stretch justify-around rounded-t-3xl px-2 pt-2">
|
||||
{tabs.map((x) => (
|
||||
<button
|
||||
key={x.id}
|
||||
|
||||
@@ -61,7 +61,7 @@ export default function PublicMenu({ menu, slug }: { menu: MenuSnapshot; slug: s
|
||||
const cartCount = cart.reduce((n, l) => n + l.qty, 0);
|
||||
|
||||
return (
|
||||
<div className="mx-auto min-h-screen max-w-2xl px-4 pb-32 pt-5">
|
||||
<div className="safe-pt-header mx-auto min-h-screen max-w-2xl px-4 pb-32">
|
||||
{/* Header */}
|
||||
<header className="mb-4 flex items-center justify-between gap-3">
|
||||
<h1 className="display text-2xl font-semibold leading-tight">{menu.restaurant.name}</h1>
|
||||
@@ -70,7 +70,7 @@ export default function PublicMenu({ menu, slug }: { menu: MenuSnapshot; slug: s
|
||||
|
||||
{/* Section tabs */}
|
||||
{sections.length > 0 && (
|
||||
<nav className="sticky top-2 z-20 -mx-1 mb-4 flex gap-2 overflow-x-auto px-1 py-1 no-scrollbar">
|
||||
<nav className="safe-top-sticky sticky z-20 -mx-1 mb-4 flex gap-2 overflow-x-auto px-1 py-1 no-scrollbar">
|
||||
{sections.map((s) => (
|
||||
<button
|
||||
key={s.id}
|
||||
@@ -119,7 +119,7 @@ export default function PublicMenu({ menu, slug }: { menu: MenuSnapshot; slug: s
|
||||
))}
|
||||
|
||||
{/* Floating actions */}
|
||||
<div className="fixed bottom-5 left-1/2 z-30 flex -translate-x-1/2 flex-col items-center gap-3">
|
||||
<div className="safe-bottom-fab fixed left-1/2 z-30 flex -translate-x-1/2 flex-col items-center gap-3">
|
||||
{actionsOpen && (
|
||||
<div className="animate-spawn flex flex-col items-stretch gap-2">
|
||||
{ordersEnabled && (
|
||||
|
||||
Reference in new issue
Block a user