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.

improve upgrade banner

Steven Teyd7018bf9d7f3
diff --git a/apps/web/ui/integrations/integration-status-badge.tsx b/apps/web/ui/integrations/integration-status-badge.tsx
index 496ec55c92..416eef5e82 100644
--- a/apps/web/ui/integrations/integration-status-badge.tsx
+++ b/apps/web/ui/integrations/integration-status-badge.tsx
@@ -44,7 +44,10 @@ export function IntegrationStatusBadge({
return (
<Tooltip content="Dub hasn't verified this integration. Install it at your own risk.">
<span>
- <CircleWarning className="size-4 shrink-0 text-neutral-500" invert />
+ <CircleWarning
+ className="size-4 shrink-0 text-neutral-500"
+ variant="fill"
+ />
</span>
</Tooltip>
);
diff --git a/apps/web/ui/layout/main-nav.tsx b/apps/web/ui/layout/main-nav.tsx
index 7c315124ca..5bc63d4102 100644
--- a/apps/web/ui/layout/main-nav.tsx
+++ b/apps/web/ui/layout/main-nav.tsx
@@ -18,7 +18,7 @@ import {
useLayoutEffect,
useState,
} from "react";
-import { useUpgradeBannerVisible } from "./upgrade-banner";
+import { useUpgradeBannerVisibility } from "./upgrade-banner";
type SideNavContext = {
isOpen: boolean;
@@ -48,7 +48,7 @@ export function MainNav({
const { isDesktop } = useMediaQuery();
const [isOpen, setIsOpen] = useState(false);
- const isUpgradeBannerVisible = useUpgradeBannerVisible();
+ const { isVisible: isUpgradeBannerVisible } = useUpgradeBannerVisibility();
// Prevent body scroll when side nav is open
useEffect(() => {
diff --git a/apps/web/ui/layout/upgrade-banner.tsx b/apps/web/ui/layout/upgrade-banner.tsx
index 4c1d750ac2..35baa45bd8 100644
--- a/apps/web/ui/layout/upgrade-banner.tsx
+++ b/apps/web/ui/layout/upgrade-banner.tsx
@@ -2,7 +2,7 @@
import useWorkspace from "@/lib/swr/use-workspace";
import { useTrialLimitActivateModal } from "@/ui/modals/trial-limit-activate-modal";
-import { Crown } from "@dub/ui";
+import { Button, Crown, TriangleWarning, useMediaQuery } from "@dub/ui";
import {
cn,
getTrialLimitResourceForOverageBanner,
@@ -12,12 +12,25 @@ import { motion } from "motion/react";
import Link from "next/link";
import ManageSubscriptionButton from "../workspaces/manage-subscription-button";
-export function useUpgradeBannerVisible() {
- const { exceededEvents, exceededLinks, exceededPayouts, paymentFailedAt } =
- useWorkspace();
+export function useUpgradeBannerVisibility() {
+ const {
+ exceededEvents,
+ exceededLinks,
+ exceededPayouts,
+ paymentFailedAt,
+ subscriptionCanceledAt,
+ } = useWorkspace();
const needsUpgrade = exceededEvents || exceededLinks || exceededPayouts;
- return needsUpgrade || !!paymentFailedAt;
+ const subscriptionCanceled =
+ subscriptionCanceledAt && new Date(subscriptionCanceledAt) < new Date();
+
+ return {
+ isVisible: needsUpgrade || !!paymentFailedAt || subscriptionCanceled,
+ needsUpgrade,
+ paymentFailed: !!paymentFailedAt,
+ subscriptionCanceled,
+ };
}
export function UpgradeBanner() {
@@ -27,14 +40,19 @@ export function UpgradeBanner() {
useTrialLimitActivateModal();
const trialActive = isWorkspaceBillingTrialActive(trialEndsAt);
- const needsUpgrade = exceededEvents || exceededLinks || exceededPayouts;
+ const { isVisible, needsUpgrade, paymentFailed, subscriptionCanceled } =
+ useUpgradeBannerVisibility();
+
const overageLimitResource = getTrialLimitResourceForOverageBanner({
exceededEvents: Boolean(exceededEvents),
exceededLinks: Boolean(exceededLinks),
exceededPayouts: Boolean(exceededPayouts),
});
- const isVisible = useUpgradeBannerVisible();
+ const customButtonClassname = "ml-4 h-7 w-fit px-2.5 text-sm font-medium";
+
+ const { isMobile } = useMediaQuery();
+
if (!isVisible) return null;
return (
@@ -43,9 +61,16 @@ export function UpgradeBanner() {
<motion.div
initial={{ transform: "translateY(-100%)" }}
animate={{ transform: "translateY(0)" }}
- className="text-content-inverted bg-bg-inverted fixed left-0 right-0 top-0 z-50 flex h-12 items-center justify-center overflow-hidden px-6"
+ className={cn(
+ "fixed left-0 right-0 top-0 z-50 flex items-center justify-center overflow-hidden px-6 py-2 text-white sm:h-12 sm:py-0",
+ needsUpgrade ? "bg-amber-600" : "bg-red-600",
+ )}
>
- {needsUpgrade && <Crown className="mr-2 size-4 shrink-0" />}
+ {needsUpgrade ? (
+ <Crown className="mr-2 size-4 shrink-0" />
+ ) : (
+ <TriangleWarning className="mr-2 size-4 shrink-0" variant="fill" />
+ )}
<p className="text-sm">
{needsUpgrade ? (
<>
@@ -63,20 +88,20 @@ export function UpgradeBanner() {
&nbsp;on your current plan
</span>
<span className="hidden md:inline">
- . Upgrade to keep using Dub.
+ . Upgrade to avoid service disruption.
</span>
</>
+ ) : subscriptionCanceled ? (
+ "Your subscription has been canceled. To reactivate, please upgrade to a paid plan."
) : (
- <>
- Your last payment failed. Please update your payment method to
- continue using Dub.
- </>
+ "Your last payment failed. Please update your payment method to avoid service disruption."
)}
</p>
- {needsUpgrade ? (
+ {needsUpgrade || subscriptionCanceled ? (
trialActive ? (
- <button
- type="button"
+ <Button
+ text="Upgrade"
+ variant="secondary"
onClick={() =>
openTrialLimitModal(
overageLimitResource ??
@@ -87,29 +112,22 @@ export function UpgradeBanner() {
: "payouts"),
)
}
- className={cn(
- "bg-bg-default text-content-emphasis border-border-subtle ml-4 flex h-7 items-center justify-center rounded-lg border px-2.5 text-sm font-medium",
- "hover:bg-bg-subtle transition-colors duration-150",
- )}
- >
- Upgrade
- </button>
+ className={customButtonClassname}
+ />
) : (
- <Link
- href={`/${slug}/settings/billing/upgrade`}
- className={cn(
- "bg-bg-default text-content-emphasis border-border-subtle ml-4 flex h-7 items-center justify-center rounded-lg border px-2.5 text-sm font-medium",
- "hover:bg-bg-subtle transition-colors duration-150",
- )}
- >
- Upgrade
+ <Link href={`/${slug}/settings/billing/upgrade`}>
+ <Button
+ text="Upgrade"
+ variant="secondary"
+ className={customButtonClassname}
+ />
</Link>
)
) : (
<ManageSubscriptionButton
- text="Update Payment Method"
+ text={isMobile ? "Update" : "Update Payment Method"}
variant="secondary"
- className="ml-4 h-7 w-fit px-2.5 text-sm font-medium"
+ className={customButtonClassname}
/>
)}
</motion.div>
diff --git a/packages/ui/src/icons/nucleo/circle-warning.tsx b/packages/ui/src/icons/nucleo/circle-warning.tsx
index 53c1200f66..8776e0bb64 100644
--- a/packages/ui/src/icons/nucleo/circle-warning.tsx
+++ b/packages/ui/src/icons/nucleo/circle-warning.tsx
@@ -1,8 +1,9 @@
import { SVGProps } from "react";
-export function CircleWarning(
- props: SVGProps<SVGSVGElement> & { invert?: boolean },
-) {
+export function CircleWarning({
+ variant = "outline",
+ ...props
+}: SVGProps<SVGSVGElement> & { variant?: "outline" | "fill" }) {
return (
<svg
height="18"
@@ -12,7 +13,7 @@ export function CircleWarning(
{...props}
>
<g fill="currentColor">
- {props.invert ? (
+ {variant === "fill" ? (
<path
d="M9,1.5C4.86,1.5,1.5,4.86,1.5,9s3.36,7.5,7.5,7.5,7.5-3.36,7.5-7.5S13.14,1.5,9,1.5Zm0,11.917c-.552,0-1-.449-1-1s.448-1,1-1,1,.449,1,1-.448,1-1,1Zm.75-4.348c0,.414-.336,.75-.75,.75s-.75-.336-.75-.75V5.431c0-.414,.336-.75,.75-.75s.75,.336,.75,.75v3.638Z"
fill="currentColor"
diff --git a/packages/ui/src/icons/nucleo/shield-check.tsx b/packages/ui/src/icons/nucleo/shield-check.tsx
index 2f16556431..2b184903a8 100644
--- a/packages/ui/src/icons/nucleo/shield-check.tsx
+++ b/packages/ui/src/icons/nucleo/shield-check.tsx
@@ -1,8 +1,9 @@
import { SVGProps } from "react";
-export function ShieldCheck(
- props: SVGProps<SVGSVGElement> & { invert?: boolean },
-) {
+export function ShieldCheck({
+ variant = "outline",
+ ...props
+}: SVGProps<SVGSVGElement> & { variant?: "outline" | "fill" }) {
return (
<svg
height="18"
@@ -12,7 +13,7 @@ export function ShieldCheck(
{...props}
>
<g fill="currentColor">
- {props.invert ? (
+ {variant === "fill" ? (
<path
d="M14.783,2.813l-5.25-1.68c-.349-.112-.718-.111-1.066,0L3.216,2.813c-.728,.233-1.216,.903-1.216,1.667v6.52c0,3.508,4.946,5.379,6.46,5.869,.177,.057,.358,.086,.54,.086s.362-.028,.538-.085c1.516-.49,6.462-2.361,6.462-5.869V4.48c0-.764-.489-1.434-1.217-1.667Zm-2.681,4.389l-3.397,4.5c-.128,.169-.322,.276-.534,.295-.021,.002-.043,.003-.065,.003-.189,0-.372-.071-.511-.201l-1.609-1.5c-.303-.283-.32-.757-.038-1.06,.284-.303,.758-.319,1.06-.038l1.001,.933,2.896-3.836c.25-.33,.72-.396,1.051-.146,.331,.25,.396,.72,.146,1.051Z"
fill="currentColor"
diff --git a/packages/ui/src/icons/nucleo/triangle-warning.tsx b/packages/ui/src/icons/nucleo/triangle-warning.tsx
index 89c31846c2..f88e837ca7 100644
--- a/packages/ui/src/icons/nucleo/triangle-warning.tsx
+++ b/packages/ui/src/icons/nucleo/triangle-warning.tsx
@@ -1,6 +1,9 @@
import { SVGProps } from "react";
-export function TriangleWarning(props: SVGProps<SVGSVGElement>) {
+export function TriangleWarning({
+ variant = "outline",
+ ...props
+}: SVGProps<SVGSVGElement> & { variant?: "outline" | "fill" }) {
return (
<svg
height="18"
@@ -10,30 +13,39 @@ export function TriangleWarning(props: SVGProps<SVGSVGElement>) {
{...props}
>
<g fill="currentColor">
- <path
- d="M7.638,3.495L2.213,12.891c-.605,1.048,.151,2.359,1.362,2.359H14.425c1.211,0,1.967-1.31,1.362-2.359L10.362,3.495c-.605-1.048-2.119-1.048-2.724,0Z"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- />
- <path
- d="M9,13.569c-.552,0-1-.449-1-1s.448-1,1-1,1,.449,1,1-.448,1-1,1Z"
- fill="currentColor"
- stroke="none"
- />
- <line
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.5"
- x1="9"
- x2="9"
- y1="6.5"
- y2="10"
- />
+ {variant === "fill" ? (
+ <path
+ d="M16.437,12.516L11.011,3.12c-.419-.727-1.171-1.161-2.011-1.161s-1.592,.434-2.011,1.161L1.563,12.516c-.42,.728-.42,1.596,0,2.323s1.172,1.161,2.011,1.161H14.425c.839,0,1.591-.434,2.011-1.161s.42-1.595,0-2.323ZM8.25,6.5c0-.414,.336-.75,.75-.75s.75,.336,.75,.75v3.5c0,.414-.336,.75-.75,.75s-.75-.336-.75-.75V6.5ZM9,13.569c-.552,0-1-.449-1-1s.448-1,1-1,1,.449,1,1-.448,1-1,1Z"
+ fill="currentColor"
+ />
+ ) : (
+ <>
+ <path
+ d="M7.638,3.495L2.213,12.891c-.605,1.048,.151,2.359,1.362,2.359H14.425c1.211,0,1.967-1.31,1.362-2.359L10.362,3.495c-.605-1.048-2.119-1.048-2.724,0Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M9,13.569c-.552,0-1-.449-1-1s.448-1,1-1,1,.449,1,1-.448,1-1,1Z"
+ fill="currentColor"
+ stroke="none"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="9"
+ x2="9"
+ y1="6.5"
+ y2="10"
+ />
+ </>
+ )}
</g>
</svg>
);