Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Overflow fix and banner consistency (#4742)

Marcus Farrell88c41ad75822
diff --git a/apps/web/app/(ee)/partners.dub.co/(apply)/[programSlug]/(default)/header.tsx b/apps/web/app/(ee)/partners.dub.co/(apply)/[programSlug]/(default)/header.tsx
index e9e0a7e0da..2c819b19af 100644
--- a/apps/web/app/(ee)/partners.dub.co/(apply)/[programSlug]/(default)/header.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(apply)/[programSlug]/(default)/header.tsx
@@ -31,7 +31,7 @@ export function ApplyHeader({
<header
className={cn(
"sticky z-10 mx-px flex items-center justify-between bg-white/90 px-6 py-4 backdrop-blur-sm",
- hasBanner ? "top-12" : "top-0",
+ hasBanner ? "top-[52px] sm:top-9" : "top-0",
)}
>
{/* Bottom border when scrolled */}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/layout.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/layout.tsx
index 4bb702d602..0abefe9ffb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/layout.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/messages/layout.tsx
@@ -30,7 +30,7 @@ export default function MessagesLayout({ children }: { children: ReactNode }) {
return (
<MessagesContext.Provider value={{ currentPanel, setCurrentPanel }}>
- <div className="@container/page h-[calc(100dvh-var(--page-top-margin)-var(--page-bottom-margin)-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">
+ <div className="@container/page h-[calc(100dvh-var(--page-banner-height)-var(--page-top-margin)-var(--page-bottom-margin)-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">
<div
className="@[800px]/page:grid-cols-[min-content_minmax(340px,1fr)] @[800px]/page:translate-x-0 grid h-full translate-x-[calc(var(--current-panel)*-100%)] grid-cols-[100%_100%]"
style={
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
index e4144d905f..21d3e0400d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
@@ -51,7 +51,7 @@ function CapableLayout({ children }: { children: ReactNode }) {
return (
<MessagesContext.Provider value={{ currentPanel, setCurrentPanel }}>
- <div className="@container/page h-[calc(100dvh-var(--page-top-margin)-var(--page-bottom-margin)-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">
+ <div className="@container/page h-[calc(100dvh-var(--page-banner-height)-var(--page-top-margin)-var(--page-bottom-margin)-1px)] w-full overflow-hidden rounded-t-[inherit] bg-white">
<div
className="@[800px]/page:grid-cols-[min-content_minmax(340px,1fr)] @[800px]/page:translate-x-0 grid h-full translate-x-[calc(var(--current-panel)*-100%)] grid-cols-[100%_100%]"
style={
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
index dbb6b776ef..e50f8f4687 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
@@ -139,7 +139,7 @@ function LinkBuilder({ link }: { link: ExpandedLinkProps }) {
const [isChangingLink, setIsChangingLink] = useState(false);
return (
- <div className="flex min-h-[calc(100dvh-var(--page-top-margin)-var(--page-bottom-margin)-1px)] flex-col rounded-t-[inherit] bg-white">
+ <div className="flex min-h-[calc(100dvh-var(--page-banner-height)-var(--page-top-margin)-var(--page-bottom-margin)-1px)] flex-col rounded-t-[inherit] bg-white">
<div className="py-2 pl-4 pr-5">
<LinkBuilderHeader
onSelectLink={(selectedLink) => {
@@ -308,7 +308,7 @@ const Controls = memo(({ link }: { link: ExpandedLinkProps }) => {
function LoadingSkeleton() {
return (
- <div className="flex min-h-[calc(100dvh-var(--page-top-margin)-var(--page-bottom-margin)-1px)] flex-col rounded-t-[inherit] bg-white">
+ <div className="flex min-h-[calc(100dvh-var(--page-banner-height)-var(--page-top-margin)-var(--page-bottom-margin)-1px)] flex-col rounded-t-[inherit] bg-white">
<div className="flex items-center justify-between gap-4 py-2.5 pl-4 pr-5">
<div className="h-8 w-64 max-w-full animate-pulse rounded-md bg-neutral-100" />
<div className="h-7 w-32 max-w-full animate-pulse rounded-md bg-neutral-100" />
diff --git a/apps/web/lib/sandbox/components/workspace-environment.tsx b/apps/web/lib/sandbox/components/workspace-environment.tsx
index 9f0944be66..2ef853d263 100644
--- a/apps/web/lib/sandbox/components/workspace-environment.tsx
+++ b/apps/web/lib/sandbox/components/workspace-environment.tsx
@@ -4,7 +4,7 @@ import { useDashboardBannerVisible } from "@/lib/hooks/use-dashboard-banner-visi
import useWorkspace from "@/lib/swr/use-workspace";
import useWorkspaces from "@/lib/swr/use-workspaces";
import { WorkspaceProps } from "@/lib/types";
-import { IsolatedCube } from "@dub/ui";
+import { buttonVariants, IsolatedCube } from "@dub/ui";
import { capitalize, cn } from "@dub/utils";
import { WorkspaceEnvironment } from "@prisma/client";
import { motion } from "motion/react";
@@ -27,19 +27,16 @@ export function ProgramEnvironmentBanner({
return (
<div
className={cn(
- "fixed left-0 right-0 top-0 z-50 flex h-12 items-center justify-between gap-4 overflow-hidden px-6 text-neutral-800",
+ // Below sm the sentence stacks under the label, so the banner is 52px (two 20px lines + padding)
+ "fixed left-0 right-0 top-0 z-50 grid h-[52px] grid-cols-[auto_minmax(0,1fr)] content-center items-center gap-x-2 overflow-hidden px-2 text-sm text-neutral-800 sm:flex sm:h-9 sm:px-4",
isStagingEnvironment(environment) ? "bg-amber-200" : "bg-blue-200",
)}
>
- <div className="flex shrink-0 items-center gap-2">
- <IsolatedCube className="size-4 shrink-0" />
- <span className="truncate text-sm font-semibold">
- {capitalize(environment)}
- </span>
- </div>
-
- <p className="text-sm font-medium">
- No real money or payouts in {environment}
+ {/* Glyph spans 0.9–15.1 around (8, 8), so a 16×16 viewBox centers it */}
+ <IsolatedCube viewBox="0 0 16 16" className="size-4 shrink-0" />
+ <span className="truncate font-semibold">{capitalize(environment)}</span>
+ <p className="col-start-2 truncate font-medium">
+ No real money or payouts in {environment}.
</p>
</div>
);
@@ -72,40 +69,41 @@ export function WorkspaceEnvironmentBanner() {
initial={{ transform: "translateY(-100%)" }}
animate={{ transform: "translateY(0)" }}
className={cn(
- "fixed left-0 right-0 top-0 z-30 flex h-12 items-center justify-between gap-4 overflow-hidden px-6 text-neutral-800",
+ "fixed left-0 right-0 top-0 z-30 flex h-9 items-center justify-between gap-4 overflow-hidden px-2 text-sm text-neutral-800 sm:px-4",
isStagingEnvironment(currentWorkspace.environment)
? "bg-amber-200"
: "bg-blue-200",
)}
>
- <div className="flex min-w-0 shrink-0 items-center gap-2">
- <IsolatedCube className="size-4 shrink-0" />
- <span className="truncate text-sm font-semibold">
+ <div className="flex min-w-0 items-center gap-2">
+ {/* Glyph spans 0.9–15.1 around (8, 8), so a 16×16 viewBox centers it */}
+ <IsolatedCube viewBox="0 0 16 16" className="size-4 shrink-0" />
+ <span className="shrink-0 font-semibold">
{capitalize(currentWorkspace.environment)} workspace
</span>
+ <p className="hidden min-w-0 truncate font-medium sm:block">
+ No real money or payouts in {currentWorkspace.environment}.{" "}
+ <a
+ href="https://dub.co/docs/testing"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="underline"
+ >
+ Learn more
+ </a>
+ </p>
</div>
- <p className="hidden min-w-0 flex-1 text-center text-sm font-medium sm:block">
- No real money or payouts in {currentWorkspace.environment}.{" "}
- <a
- href="https://dub.co/docs/testing"
- target="_blank"
- rel="noopener noreferrer"
- className="underline underline-offset-2"
- >
- Learn more
- </a>
- </p>
-
- {liveWorkspace ? (
+ {liveWorkspace && (
<Link
href={pathname.replace(currentWorkspace.slug, liveWorkspace.slug)}
- className="bg-bg-inverted text-content-inverted shrink-0 rounded-md p-2 text-xs font-medium"
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "border-bg-inverted bg-bg-inverted flex h-6 shrink-0 items-center whitespace-nowrap rounded-md border px-1.5 text-xs font-medium",
+ )}
>
Exit staging
</Link>
- ) : (
- <span className="w-[88px] shrink-0" />
)}
</motion.div>
);
diff --git a/apps/web/ui/layout/main-nav.tsx b/apps/web/ui/layout/main-nav.tsx
index 45d975f2c4..5ff522fc72 100644
--- a/apps/web/ui/layout/main-nav.tsx
+++ b/apps/web/ui/layout/main-nav.tsx
@@ -87,7 +87,7 @@ export function MainNav({
isOpen
? "bg-black/20 backdrop-blur-sm"
: "bg-transparent max-lg:pointer-events-none",
- displayBanner ? "top-12 h-[calc(100dvh-48px)]" : "top-0 h-dvh",
+ displayBanner ? "top-9 h-[calc(100dvh-36px)]" : "top-0 h-dvh",
)}
onClick={(e) => {
if (e.target === e.currentTarget) {
@@ -109,7 +109,9 @@ export function MainNav({
<div
className={cn(
"bg-neutral-200 pb-[var(--page-bottom-margin)] pt-[var(--page-top-margin)] [--page-bottom-margin:0px] [--page-top-margin:0px] lg:pb-2 lg:pr-2 lg:[--page-bottom-margin:0.5rem] lg:[--page-top-margin:0.5rem]",
- displayBanner ? "mt-12 h-[calc(100vh-48px)]" : "h-screen",
+ displayBanner
+ ? "mt-9 h-[calc(100vh-36px)] [--page-banner-height:36px]"
+ : "h-screen [--page-banner-height:0px]",
)}
>
<div
diff --git a/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx b/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx
index c22d70d551..df528edf38 100644
--- a/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx
+++ b/apps/web/ui/layout/page-content/page-content-with-side-panel.tsx
@@ -55,7 +55,7 @@ export function PageContentWithSidePanel({
>
<div
className={cn(
- "@container/page-content relative grid min-h-[var(--page-height)] grid-cols-[minmax(340px,1fr)_minmax(0,min-content)] rounded-t-[inherit] bg-neutral-100 [--page-height:calc(100dvh-var(--page-top-margin)-var(--page-bottom-margin)-1px)] lg:bg-white",
+ "@container/page-content relative grid min-h-[var(--page-height)] grid-cols-[minmax(340px,1fr)_minmax(0,min-content)] rounded-t-[inherit] bg-neutral-100 [--page-height:calc(100dvh-var(--page-banner-height)-var(--page-top-margin)-var(--page-bottom-margin)-1px)] lg:bg-white",
individualScrolling && "h-[var(--page-height)]",
className,
)}
diff --git a/apps/web/ui/layout/upgrade-banner.tsx b/apps/web/ui/layout/upgrade-banner.tsx
index 0cc11e09bf..76bf12a217 100644
--- a/apps/web/ui/layout/upgrade-banner.tsx
+++ b/apps/web/ui/layout/upgrade-banner.tsx
@@ -7,10 +7,10 @@ import { useRetryPaymentModal } from "@/ui/modals/retry-payment-modal";
import { useTrialLimitActivateModal } from "@/ui/modals/trial-limit-activate-modal";
import {
Button,
+ buttonVariants,
Crown,
DynamicTooltipWrapper,
TriangleWarning,
- useMediaQuery,
} from "@dub/ui";
import {
cn,
@@ -19,6 +19,7 @@ import {
} from "@dub/utils";
import { motion } from "motion/react";
import Link from "next/link";
+import { ReactNode } from "react";
export function useUpgradeBannerVisibility() {
const {
@@ -70,9 +71,16 @@ export function UpgradeBanner() {
exceededPayouts: Boolean(exceededPayouts),
});
- const customButtonClassname = "ml-4 h-7 w-fit px-2.5 text-sm font-medium";
+ const customButtonClassname = "h-6 w-fit shrink-0 px-1.5 text-xs font-medium";
- const { isMobile } = useMediaQuery();
+ const paymentMethodLink = (text: string) => (
+ <Link
+ href={`/${slug}/settings/billing#payment-methods`}
+ className="underline"
+ >
+ {text}
+ </Link>
+ );
if (!isUpgradeBannerVisible) return null;
@@ -84,49 +92,62 @@ export function UpgradeBanner() {
initial={{ transform: "translateY(-100%)" }}
animate={{ transform: "translateY(0)" }}
className={cn(
- "fixed left-0 right-0 top-0 z-30 flex items-center justify-center overflow-hidden px-6 py-2 text-white sm:h-12 sm:py-0",
+ "fixed left-0 right-0 top-0 z-30 flex h-9 items-center justify-between gap-4 overflow-hidden px-2 text-white sm:px-4",
needsUpgrade ? "bg-amber-600" : "bg-red-600",
)}
>
- {needsUpgrade ? (
- <Crown className="mr-2 size-4 shrink-0" />
- ) : (
- <TriangleWarning className="mr-2 size-4 shrink-0" variant="fill" />
- )}
- <p className="text-sm">
+ <div className="flex min-w-0 items-center gap-2">
{needsUpgrade ? (
- <>
- You&rsquo;ve hit the{" "}
- <Link href={`/${slug}/settings/billing`} className="underline">
- {exceededEvents
- ? "events"
- : exceededLinks
- ? "links"
- : "payouts"}{" "}
- limit
- </Link>
- <span className="xs:inline hidden">
- &nbsp;on your current plan
- </span>
- <span className="hidden md:inline">
- . Upgrade to avoid service disruption.
- </span>
- </>
- ) : subscriptionCanceled ? (
- "Your subscription has been canceled. To reactivate, please upgrade to a paid plan."
+ <Crown className="size-4 shrink-0" />
) : (
- <>
- Your last payment failed. Please{" "}
- <Link
- href={`/${slug}/settings/billing#payment-methods`}
- className="underline"
- >
- update your payment method
- </Link>{" "}
- to avoid service disruption.
- </>
+ <TriangleWarning className="size-4 shrink-0" variant="fill" />
)}
- </p>
+ <p className="min-w-0 truncate text-sm font-medium">
+ {needsUpgrade ? (
+ <>
+ You&rsquo;ve hit the{" "}
+ <Link href={`/${slug}/settings/billing`} className="underline">
+ {exceededEvents
+ ? "events"
+ : exceededLinks
+ ? "links"
+ : "payouts"}{" "}
+ limit
+ </Link>
+ <span className="hidden sm:inline"> on your current plan</span>
+ </>
+ ) : subscriptionCanceled ? (
+ <BreakpointText
+ short="Your subscription has been canceled."
+ medium="Your subscription has been canceled. Upgrade to a paid plan."
+ long="Your subscription has been canceled. To reactivate, please upgrade to a paid plan."
+ />
+ ) : (
+ <BreakpointText
+ short={
+ <>
+ Payment failed.{" "}
+ {paymentMethodLink("Update payment method.")}
+ </>
+ }
+ medium={
+ <>
+ Payment failed.{" "}
+ {paymentMethodLink("Update your payment method")} to avoid
+ service disruption.
+ </>
+ }
+ long={
+ <>
+ Your last payment failed. Please{" "}
+ {paymentMethodLink("update your payment method")} to avoid
+ service disruption.
+ </>
+ }
+ />
+ )}
+ </p>
+ </div>
{needsUpgrade || subscriptionCanceled ? (
trialActive ? (
<Button
@@ -145,12 +166,15 @@ export function UpgradeBanner() {
className={customButtonClassname}
/>
) : (
- <Link href={`/${slug}/settings/billing/upgrade`}>
- <Button
- text="Upgrade"
- variant="secondary"
- className={customButtonClassname}
- />
+ <Link
+ href={`/${slug}/settings/billing/upgrade`}
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex items-center whitespace-nowrap rounded-lg border",
+ customButtonClassname,
+ )}
+ >
+ Upgrade
</Link>
)
) : (
@@ -160,7 +184,7 @@ export function UpgradeBanner() {
}
>
<Button
- text={isMobile ? "Retry" : "Retry payment"}
+ text="Retry"
variant="secondary"
disabled={Boolean(permissionsError)}
onClick={() => setShowRetryPaymentModal(true)}
@@ -172,3 +196,22 @@ export function UpgradeBanner() {
</>
);
}
+
+// Mobile shows `short`, sm shows `medium`, md and up shows `long`
+function BreakpointText({
+ short,
+ medium,
+ long,
+}: {
+ short: ReactNode;
+ medium: ReactNode;
+ long: ReactNode;
+}) {
+ return (
+ <>
+ <span className="sm:hidden">{short}</span>
+ <span className="hidden sm:inline md:hidden">{medium}</span>
+ <span className="hidden md:inline">{long}</span>
+ </>
+ );
+}