Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(billing): Add in-app notification banner for unpaid / past_due subscriptions (#9685)

Michael Fröhlich51e10e464ea2
diff --git a/.cursor/rules/banner-positioning.mdc b/.cursor/rules/banner-positioning.mdc
new file mode 100644
index 0000000000..f4e029cc69
--- /dev/null
+++ b/.cursor/rules/banner-positioning.mdc
@@ -0,0 +1,45 @@
+---
+description: Guidelines for positioning elements with banner awareness
+globs:
+ - "**/*.tsx"
+ - "**/*.jsx"
+alwaysApply: true
+---
+
+## Banner Height System
+
+When positioning elements with `sticky`, `fixed`, or `absolute` that have a global reference point (like `top-0`), **always use `top-banner-offset` instead of `top-0`**.
+
+### Why?
+The application can display system banners (payment issues, maintenance notices, etc.) that push content down. Using `top-banner-offset` ensures your positioned elements appear below the banner rather than being covered by it.
+
+### Usage
+
+**Bad:**
+```tsx
+<div className="fixed top-0 left-0 right-0">...</div>
+<div className="sticky top-0">...</div>
+<div className="absolute top-0">...</div>
+<div className="pt-0">...</div>
+```
+
+**Good:**
+```tsx
+<div className="fixed top-banner-offset left-0 right-0">...</div>
+<div className="sticky top-banner-offset">...</div>
+<div className="absolute top-banner-offset">...</div>
+<div className="pt-banner-offset">...</div>
+```
+
+### Additional Utilities
+
+- `h-screen-with-banner` / `min-h-screen-with-banner` - Use these for full-height containers that should account for banner space
+- `pt-banner-offset` - Use for padding-top to offset content below the banner
+- The system uses CSS variables `--banner-height` and `--banner-offset` defined in `web/src/styles/globals.css`
+- Banner components dynamically update `--banner-height` using ResizeObserver to track their actual rendered height, ensuring accuracy across all screen sizes
+
+### When NOT to use `top-banner-offset`
+
+- Elements positioned relative to their parent container (not globally)
+- Elements that should intentionally appear at the very top of the viewport
+- Elements inside modals/dialogs that are already z-indexed above banners
diff --git a/REVIEW.md b/REVIEW.md
index 69d7f14a56..69d021d796 100644
--- a/REVIEW.md
+++ b/REVIEW.md
@@ -26,3 +26,12 @@
## Langfuse Cloud
- When attempting to confirm if the current environment is Langfuse Cloud in the frontend, use the `useLangfuseCloudRegion` hook and never environment variables directly.
+
+## Banner Height System
+
+- Use `top-banner-offset` instead of `top-0` for any elements that are positioned `sticky`, `fixed`, or `absolute` with a global reference point (e.g., `top-0`). This ensures proper spacing when system banners (payment, maintenance, etc.) are displayed.
+- The banner height is managed through CSS variables (`--banner-height` and `--banner-offset`) defined in `web/src/styles/globals.css`.
+- Banner components (like PaymentBanner) dynamically update `--banner-height` using ResizeObserver to track their actual height, ensuring accurate positioning even when banners resize (e.g., on mobile wrapping).
+- Available Tailwind utilities:
+ - `top-banner-offset` / `pt-banner-offset` - For sticky/fixed/absolute positioning and padding
+ - `h-screen-with-banner` / `min-h-screen-with-banner` - For full-height containers accounting for banners
diff --git a/packages/shared/src/interfaces/cloudConfigSchema.ts b/packages/shared/src/interfaces/cloudConfigSchema.ts
index 673845b093..211de70694 100644
--- a/packages/shared/src/interfaces/cloudConfigSchema.ts
+++ b/packages/shared/src/interfaces/cloudConfigSchema.ts
@@ -14,6 +14,7 @@ export const CloudConfigSchema = z.object({
activeSubscriptionId: z.string().optional(),
activeProductId: z.string().optional(),
activeUsageProductId: z.string().optional(),
+ subscriptionStatus: z.string().optional(), // should be one of ["active","past_due", "unpaid", "canceled", "incomplete", "incomplete_expired", "paused"]; we don't enforce to have a backwards compatibility for this field
})
.transform((data) => ({
...data,
diff --git a/web/src/components/error-page.tsx b/web/src/components/error-page.tsx
index 8228fb1e7e..5a546a0f78 100644
--- a/web/src/components/error-page.tsx
+++ b/web/src/components/error-page.tsx
@@ -28,7 +28,7 @@ export const ErrorPage = ({
const newTargetPath = router.asPath;
return (
- <div className="flex h-screen flex-col items-center justify-center">
+ <div className="flex h-full flex-col items-center justify-center">
<AlertCircle className="mb-4 h-12 w-12 text-dark-red" />
<h1 className="mb-4 text-xl font-bold">{title}</h1>
<p className="mb-6 text-center">{message}</p>
diff --git a/web/src/components/layouts/container-page.tsx b/web/src/components/layouts/container-page.tsx
index db67249eae..670e96b384 100644
--- a/web/src/components/layouts/container-page.tsx
+++ b/web/src/components/layouts/container-page.tsx
@@ -2,6 +2,7 @@ import PageHeader, {
type PageHeaderProps,
} from "@/src/components/layouts/page-header";
import { cn } from "@/src/utils/tailwind";
+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";
type SettingsContainerProps = {
children: React.ReactNode;
@@ -9,12 +10,25 @@ type SettingsContainerProps = {
};
const ContainerPage = ({ children, headerProps }: SettingsContainerProps) => {
+ const { open: supportDrawerIsOpen } = useSupportDrawer();
+
return (
- <div className={cn("relative flex min-h-svh flex-1 flex-col")}>
- <header className="sticky top-0 z-50 w-full">
+ <div
+ className={cn("relative flex min-h-screen-with-banner flex-1 flex-col")}
+ >
+ <header
+ className={cn(
+ "sticky z-50 w-full",
+ supportDrawerIsOpen ? "top-0" : "top-banner-offset", // if the support drawer is open the parent element changes (see layout.tsx) and we need to adjust the top position
+ )}
+ >
<PageHeader {...headerProps} container />
</header>
- <main className="relative flex min-h-svh flex-1 flex-col p-3 lg:container">
+ <main
+ className={cn(
+ "relative flex min-h-screen-with-banner flex-1 flex-col p-3 lg:container",
+ )}
+ >
{children}
</main>
</div>
diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsx
index 09e455a5e6..ffe4ddb7a8 100644
--- a/web/src/components/layouts/layout.tsx
+++ b/web/src/components/layouts/layout.tsx
@@ -23,6 +23,10 @@ import {
ResizablePanel,
ResizablePanelGroup,
} from "@/src/components/ui/resizable";
+import {
+ PaymentBanner,
+ PaymentBannerProvider,
+} from "@/src/features/payment-banner";
import {
Drawer,
DrawerContent,
@@ -332,27 +336,32 @@ export default function Layout(props: PropsWithChildren) {
href={`${env.NEXT_PUBLIC_BASE_PATH ?? ""}/favicon-16x16${region === "DEV" ? "-dev" : ""}.png`}
/>
</Head>
- <div>
+ <PaymentBannerProvider>
<SidebarProvider>
- <AppSidebar
- navItems={mainNavigation}
- secondaryNavItems={secondaryNavigation}
- userNavProps={{
- items: getUserNavigation(),
- user: {
- name: session.data?.user?.name ?? "",
- email: session.data?.user?.email ?? "",
- avatar: session.data?.user?.image ?? "",
- },
- }}
- />
- <SidebarInset className="h-dvh max-w-full md:peer-data-[state=collapsed]:w-[calc(100vw-var(--sidebar-width-icon))] md:peer-data-[state=expanded]:w-[calc(100vw-var(--sidebar-width))]">
- <ResizableContent>{props.children}</ResizableContent>
- <Toaster visibleToasts={1} />
- <CommandMenu mainNavigation={navigation} />
- </SidebarInset>
+ <div className="flex h-dvh w-full flex-col">
+ <PaymentBanner />
+ <div className="flex min-h-0 flex-1 pt-banner-offset">
+ <AppSidebar
+ navItems={mainNavigation}
+ secondaryNavItems={secondaryNavigation}
+ userNavProps={{
+ items: getUserNavigation(),
+ user: {
+ name: session.data?.user?.name ?? "",
+ email: session.data?.user?.email ?? "",
+ avatar: session.data?.user?.image ?? "",
+ },
+ }}
+ />
+ <SidebarInset className="h-screen-with-banner max-w-full md:peer-data-[state=collapsed]:w-[calc(100vw-var(--sidebar-width-icon))] md:peer-data-[state=expanded]:w-[calc(100vw-var(--sidebar-width))]">
+ <ResizableContent>{props.children}</ResizableContent>
+ <Toaster visibleToasts={1} />
+ <CommandMenu mainNavigation={navigation} />
+ </SidebarInset>
+ </div>
+ </div>
</SidebarProvider>
- </div>
+ </PaymentBannerProvider>
</>
);
}
@@ -415,7 +424,7 @@ export function ResizableContent({ children }: PropsWithChildren) {
<Drawer open={open} onOpenChange={setOpen} forceDirection="bottom">
<DrawerContent
id="support-drawer"
- className="inset-x-0 bottom-0 top-10 min-h-full"
+ className="inset-x-0 bottom-0 top-[calc(var(--banner-offset)+10px)] min-h-screen-with-banner"
size="full"
>
<DrawerHeader className="absolute inset-x-0 top-0 p-0 text-left">
@@ -456,7 +465,9 @@ export function ResizableContent({ children }: PropsWithChildren) {
onLayout={onLayout}
>
<ResizablePanel defaultSize={mainDefault} minSize={30}>
- <main className="h-full w-full">{children}</main>
+ <main className="relative h-full w-full overflow-scroll">
+ {children}
+ </main>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={drawerDefault} minSize={20} maxSize={60}>
diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsx
index 773078f3c5..01c0f74f8e 100644
--- a/web/src/components/layouts/page-header.tsx
+++ b/web/src/components/layouts/page-header.tsx
@@ -35,6 +35,7 @@ export type PageHeaderProps = {
itemType?: LangfuseItemType;
container?: boolean;
tabsProps?: PageTabsProps;
+ className?: string;
};
const PageHeader = ({
@@ -46,10 +47,17 @@ const PageHeader = ({
help,
tabsProps,
container = false,
+ className,
}: PageHeaderProps) => {
const router = useRouter();
return (
- <div className="sticky top-0 z-30 w-full border-b bg-background shadow-sm">
+ <div
+ className={cn([
+ "sticky top-banner-offset z-30 w-full border-b bg-background shadow-sm",
+ className,
+ ])}
+ id="page-header"
+ >
<div className="flex flex-col justify-center">
{/* Top Row */}
<div className="border-b">
diff --git a/web/src/components/layouts/page.tsx b/web/src/components/layouts/page.tsx
index e940b8abba..fa5008991e 100644
--- a/web/src/components/layouts/page.tsx
+++ b/web/src/components/layouts/page.tsx
@@ -2,6 +2,7 @@ import PageHeader, {
type PageHeaderProps,
} from "@/src/components/layouts/page-header";
import { cn } from "@/src/utils/tailwind";
+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";
type PageContainerProps = {
children: React.ReactNode;
@@ -16,20 +17,30 @@ const Page = ({
scrollable = false,
withPadding = false,
}: PageContainerProps) => {
+ const { open: supportDrawerIsOpen } = useSupportDrawer();
+
return (
<div
className={cn(
"flex flex-col",
- scrollable ? "relative flex min-h-svh flex-1" : "h-full",
+ scrollable ? "relative flex min-h-screen-with-banner flex-1" : "h-full",
)}
+ id="page"
>
- <header className="sticky top-0 z-50 w-full">
- <PageHeader {...headerProps} container={false} />
+ <header
+ className={cn(
+ "sticky z-50 w-full",
+ supportDrawerIsOpen ? "top-0" : "top-banner-offset", // if the support drawer is open the parent element changes (see layout.tsx) and we need to adjust the top position
+ )}
+ >
+ <PageHeader {...headerProps} container={false} className={"top-0"} />
</header>
<main
className={cn(
"flex flex-1 flex-col",
- scrollable ? "relative flex min-h-svh" : "h-full overflow-hidden",
+ scrollable
+ ? "relative flex min-h-screen-with-banner"
+ : "h-full overflow-hidden",
withPadding && "p-3",
)}
>
diff --git a/web/src/components/ui/drawer.tsx b/web/src/components/ui/drawer.tsx
index f43e472820..b24a149595 100644
--- a/web/src/components/ui/drawer.tsx
+++ b/web/src/components/ui/drawer.tsx
@@ -24,7 +24,7 @@ type DrawerContentProps = React.ComponentPropsWithoutRef<
const TAILWIND_MD_MEDIA_QUERY = 768;
const drawerVariants = cva(
- "fixed inset-x-0 z-50 flex h-auto flex-col rounded-t-lg border bg-background md:inset-x-auto md:right-0 md:mt-0 md:rounded-l-lg md:rounded-r-none",
+ "fixed inset-x-0 z-50 flex h-auto flex-col rounded-t-lg border bg-background md:inset-x-auto md:right-0 md:mt-0 md:rounded-l-lg md:rounded-r-none ",
{
variants: {
size: {
@@ -34,7 +34,7 @@ const drawerVariants = cva(
full: "w-full",
},
position: {
- top: "md:inset-y-0",
+ top: "md:bottom-0 md:top-banner-offset md:max-h-screen-with-banner",
},
height: {
default: "h-1/3 md:h-full",
diff --git a/web/src/components/ui/sheet.tsx b/web/src/components/ui/sheet.tsx
index 97507ae38c..0643d11794 100644
--- a/web/src/components/ui/sheet.tsx
+++ b/web/src/components/ui/sheet.tsx
@@ -35,12 +35,12 @@ const sheetVariants = cva(
{
variants: {
side: {
- top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
+ top: "inset-x-0 top-banner-offset border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
bottom:
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
- left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
+ left: "top-banner-offset bottom-0 left-0 h-screen-with-banner w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
right:
- "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
+ "top-banner-offset bottom-0 right-0 h-screen-with-banner w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
},
},
defaultVariants: {
diff --git a/web/src/components/ui/sidebar.tsx b/web/src/components/ui/sidebar.tsx
index 9ada63d383..c894e54e92 100644
--- a/web/src/components/ui/sidebar.tsx
+++ b/web/src/components/ui/sidebar.tsx
@@ -152,7 +152,7 @@ const SidebarProvider = React.forwardRef<
} as React.CSSProperties
}
className={cn(
- "group/sidebar-wrapper flex min-h-svh w-full text-sidebar-foreground has-[[data-variant=inset]]:bg-sidebar",
+ "group/sidebar-wrapper flex min-h-screen-with-banner w-full text-sidebar-foreground has-[[data-variant=inset]]:bg-sidebar",
className,
)}
ref={ref}
@@ -235,7 +235,7 @@ const Sidebar = React.forwardRef<
{/* This is what handles the sidebar gap on desktop */}
<div
className={cn(
- "relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
+ "relative h-screen-with-banner w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
"group-data-[collapsible=offcanvas]:w-0",
"group-data-[side=right]:rotate-180",
variant === "floating" || variant === "inset"
@@ -245,7 +245,7 @@ const Sidebar = React.forwardRef<
/>
<div
className={cn(
- "fixed inset-y-0 z-20 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
+ "fixed bottom-0 top-banner-offset z-20 hidden h-screen-with-banner w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
side === "left"
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
@@ -259,7 +259,10 @@ const Sidebar = React.forwardRef<
>
<div
data-sidebar="sidebar"
- className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
+ className={cn([
+ "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",
+ "h-screen-with-banner", // offset if the notification banner is visible
+ ])}
>
{children}
</div>
@@ -333,7 +336,7 @@ const SidebarInset = React.forwardRef<
<main
ref={ref}
className={cn(
- "relative flex min-h-svh flex-1 flex-col bg-background",
+ "relative flex min-h-screen-with-banner flex-1 flex-col bg-background",
"peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
className,
)}
diff --git a/web/src/ee/features/billing/server/stripeWebhookHandler.ts b/web/src/ee/features/billing/server/stripeWebhookHandler.ts
index b5deb93323..afcdcb38aa 100644
--- a/web/src/ee/features/billing/server/stripeWebhookHandler.ts
+++ b/web/src/ee/features/billing/server/stripeWebhookHandler.ts
@@ -523,6 +523,7 @@ async function handleSubscriptionChanged(
activeUsageProductId: usageProductId,
activeSubscriptionId: subscriptionId,
customerId: stripeCustomerId,
+ subscriptionStatus: subscription.status,
}),
},
};
@@ -568,6 +569,7 @@ async function handleSubscriptionChanged(
activeProductId: undefined,
activeSubscriptionId: undefined,
activeUsageProductId: undefined,
+ subscriptionStatus: undefined,
}),
},
};
diff --git a/web/src/features/payment-banner/PaymentBanner.tsx b/web/src/features/payment-banner/PaymentBanner.tsx
new file mode 100644
index 0000000000..91f67f852e
--- /dev/null
+++ b/web/src/features/payment-banner/PaymentBanner.tsx
@@ -0,0 +1,145 @@
+import { useEffect, useRef, useMemo } from "react";
+import { useSession } from "next-auth/react";
+import { AlertCircle, CreditCard } from "lucide-react";
+import Link from "next/link";
+import { Button } from "@/src/components/ui/button";
+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
+import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";
+import { usePaymentBannerHeight } from "./PaymentBannerContext";
+import { cn } from "@/src/utils/tailwind";
+import { env } from "@/src/env.mjs";
+import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
+import { cva } from "class-variance-authority";
+
+export function PaymentBanner() {
+ const session = useSession();
+ const { organization } = useQueryProjectOrOrganization();
+ const isCloudBilling = useIsCloudBillingAvailable();
+ const { setBannerHeight } = usePaymentBannerHeight();
+ const bannerRef = useRef<HTMLDivElement>(null);
+
+ const subscriptionStatus = useMemo(() => {
+ // Don't show banner if:
+ // - Not cloud billing environment
+ // - Not authenticated
+ // - No organization context
+ if (
+ !isCloudBilling ||
+ session.status !== "authenticated" ||
+ !organization
+ ) {
+ return null;
+ }
+
+ return organization?.cloudConfig?.stripe?.subscriptionStatus;
+ }, [isCloudBilling, session.status, organization]);
+
+ // Update banner height when component mounts/unmounts or when visibility changes
+ useEffect(() => {
+ if (!bannerRef.current) {
+ setBannerHeight(0);
+ return;
+ }
+
+ const updateHeight = () => {
+ if (bannerRef.current) {
+ setBannerHeight(bannerRef.current.offsetHeight);
+ } else {
+ setBannerHeight(0);
+ }
+ };
+
+ // Update height initially
+ updateHeight();
+
+ // Use ResizeObserver to track height changes
+ const resizeObserver = new ResizeObserver(updateHeight);
+ resizeObserver.observe(bannerRef.current);
+
+ return () => {
+ resizeObserver.disconnect();
+ setBannerHeight(0);
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [setBannerHeight, subscriptionStatus]);
+
+ if (!organization) {
+ return null;
+ }
+
+ if (!subscriptionStatus) {
+ return null;
+ }
+
+ // Only show for past_due or unpaid
+ if (subscriptionStatus !== "past_due" && subscriptionStatus !== "unpaid") {
+ return null;
+ }
+
+ // Check if user has billing access (OWNER only)
+ const canManageBilling = hasOrganizationAccess({
+ session: session.data,
+ organizationId: organization.id,
+ scope: "langfuseCloudBilling:CRUD",
+ });
+
+ // Determine severity styling
+ const isCritical = subscriptionStatus === "unpaid";
+ const basePath = env.NEXT_PUBLIC_BASE_PATH ?? "";
+
+ const drawerVariants = cva(
+ "fixed top-0 z-[51] flex w-full items-center justify-between gap-4 px-4 py-1 sm:px-4 lg:px-4",
+ {
+ variants: {
+ type: {
+ info: "bg-foreground text-background",
+ warning:
+ "bg-amber-500 text-amber-950 dark:bg-amber-600 dark:text-amber-50",
+ critical: "bg-destructive text-destructive-foreground",
+ },
+
+ defaultVariants: {
+ type: "info",
+ },
+ },
+ },
+ );
+
+ if (!canManageBilling) {
+ return null;
+ }
+
+ return (
+ <div
+ ref={bannerRef}
+ className={cn(drawerVariants({ type: isCritical ? "critical" : "info" }))}
+ role="alert"
+ aria-live="polite"
+ >
+ <div className="flex items-center gap-3">
+ <AlertCircle className="h-4 w-4 flex-shrink-0" />
+ <div className="flex flex-col gap-0.5 sm:flex-row sm:items-center sm:gap-2">
+ <span className="text-sm font-semibold">Billing Issue:</span>
+ <span className="text-sm">
+ {canManageBilling
+ ? `We have problems collecting subscription payment for your organization '${organization.name}'. Please update your payment information to continue using Langfuse.`
+ : `We have problems collecting subscription payment for your organization '${organization.name}'. Please notify your organization administrator to avoid service interruption.`}
+ </span>
+ </div>
+ </div>
+
+ <div className="flex items-center gap-2">
+ {canManageBilling && (
+ <Button size="sm" variant="ghost" asChild>
+ <Link
+ href={`${basePath}/organization/${organization.id}/settings/billing`}
+ >
+ <CreditCard className="mr-2 h-4 w-4" />
+ Update Payment
+ </Link>
+ </Button>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/features/payment-banner/PaymentBannerContext.tsx b/web/src/features/payment-banner/PaymentBannerContext.tsx
new file mode 100644
index 0000000000..a53d3d8595
--- /dev/null
+++ b/web/src/features/payment-banner/PaymentBannerContext.tsx
@@ -0,0 +1,47 @@
+import {
+ createContext,
+ useContext,
+ useEffect,
+ useState,
+ type ReactNode,
+} from "react";
+
+interface PaymentBannerContextValue {
+ bannerHeight: number;
+ setBannerHeight: (height: number) => void;
+}
+
+const PaymentBannerContext = createContext<PaymentBannerContextValue | null>(
+ null,
+);
+
+export function PaymentBannerProvider({ children }: { children: ReactNode }) {
+ const [bannerHeight, setBannerHeight] = useState(0);
+
+ useEffect(() => {
+ // Note: CSS vars allow us to reduce re-renders of child-components and correct
+ // CSS animations. Prefer using the CSS var over consuming the hook below to adjust layouts.
+ // Example:
+ // - <div className="h-[calc(100svh-var(--banner-height,0px))]"> --> correct height calculation
+ document.documentElement.style.setProperty(
+ "--banner-height",
+ `${bannerHeight}px`,
+ );
+ }, [bannerHeight]);
+
+ return (
+ <PaymentBannerContext.Provider value={{ bannerHeight, setBannerHeight }}>
+ {children}
+ </PaymentBannerContext.Provider>
+ );
+}
+
+export function usePaymentBannerHeight() {
+ const context = useContext(PaymentBannerContext);
+ if (!context) {
+ throw new Error(
+ "usePaymentBannerHeight must be used within PaymentBannerProvider",
+ );
+ }
+ return context;
+}
diff --git a/web/src/features/payment-banner/index.ts b/web/src/features/payment-banner/index.ts
new file mode 100644
index 0000000000..cc7d7a3edb
--- /dev/null
+++ b/web/src/features/payment-banner/index.ts
@@ -0,0 +1,5 @@
+export { PaymentBanner } from "./PaymentBanner";
+export {
+ PaymentBannerProvider,
+ usePaymentBannerHeight,
+} from "./PaymentBannerContext";
diff --git a/web/src/features/support-chat/SupportDrawer.tsx b/web/src/features/support-chat/SupportDrawer.tsx
index addd1755ac..53d72897ea 100644
--- a/web/src/features/support-chat/SupportDrawer.tsx
+++ b/web/src/features/support-chat/SupportDrawer.tsx
@@ -33,7 +33,7 @@ export const SupportDrawer = ({
return (
<div
className={cn([
- "flex h-dvh w-full min-w-0 flex-col bg-background",
+ "flex h-full w-full min-w-0 flex-col bg-background",
className,
])}
>
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index 537b6991f2..320e06590b 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -84,6 +84,13 @@
--color-3: oklch(69.6% 0.165 251);
--color-4: oklch(80.2% 0.134 225);
--color-5: oklch(90.7% 0.231 133);
+
+ /* Banner height system for fixed/sticky positioning
+ Banner components dynamically update --banner-height via JS */
+ --banner-height: 0px;
+ --banner-offset: calc(
+ env(safe-area-inset-top, 0px) + var(--banner-height, 0px)
+ );
}
.dark {
diff --git a/web/tailwind.config.ts b/web/tailwind.config.ts
index 059c59b756..aaff9926d8 100644
--- a/web/tailwind.config.ts
+++ b/web/tailwind.config.ts
@@ -21,6 +21,18 @@ module.exports = {
transparent: "transparent",
current: "currentColor",
extend: {
+ spacing: {
+ "banner-offset": "var(--banner-offset)",
+ },
+ minHeight: {
+ "screen-with-banner": "calc(100svh - var(--banner-offset))",
+ },
+ maxHeight: {
+ "screen-with-banner": "calc(100svh - var(--banner-offset))",
+ },
+ height: {
+ "screen-with-banner": "calc(100svh - var(--banner-offset))",
+ },
colors: {
"primary-accent": "hsl(var(--primary-accent))",
"hover-primary-accent": "hsl(var(--hover-primary-accent))",