Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor subscription components and update pricing card structure

Bill Yang6c113f4a6cfc
diff --git a/client/src/app/subscribe/components/FeaturesList.tsx b/client/src/app/subscribe/components/FeaturesList.tsx
deleted file mode 100644
index 8a769dae5..000000000
--- a/client/src/app/subscribe/components/FeaturesList.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import React, { useState } from "react";
-import { ArrowDown, ArrowUp, Check, ChevronDown, ChevronUp } from "lucide-react";
-import { cn } from "@/lib/utils";
-
-interface FeaturesListProps {
- features: string[];
- className?: string;
-}
-
-export function FeaturesList({ features, className }: FeaturesListProps) {
- const [isExpanded, setIsExpanded] = useState(false);
- const shouldShowToggle = features.length > 7;
- const displayedFeatures = shouldShowToggle && !isExpanded ? features.slice(0, 7) : features;
-
- return (
- <div className={cn("space-y-3 mt-6", className)}>
- {displayedFeatures.map((feature, i) => (
- <div key={i} className="flex items-center">
- <Check className="h-4 w-4 text-emerald-600 dark:text-emerald-400 mr-3 shrink-0" />
- <span className="text-sm">{feature}</span>
- </div>
- ))}
-
- {shouldShowToggle && (
- <button
- onClick={() => setIsExpanded(!isExpanded)}
- className="flex items-center text-sm text-neutral-400 dark:text-neutral-400 hover:text-neutral-200 dark:hover:text-neutral-300 transition-colors cursor-pointer mt-2"
- >
- {isExpanded ? (
- <>
- <ArrowUp className="h-4 w-4 mr-3" />
- Show less
- </>
- ) : (
- <>
- <ArrowDown className="h-4 w-4 mr-3" />
- Show more ({features.length - 5} more)
- </>
- )}
- </button>
- )}
- </div>
- );
-}
diff --git a/client/src/app/subscribe/components/PricingCard.tsx b/client/src/app/subscribe/components/PricingCard.tsx
deleted file mode 100644
index 7c1c74444..000000000
--- a/client/src/app/subscribe/components/PricingCard.tsx
+++ /dev/null
@@ -1,319 +0,0 @@
-"use client";
-
-import { Slider } from "@/components/ui/slider";
-import { authClient } from "@/lib/auth";
-import { BACKEND_URL } from "@/lib/const";
-import { cn } from "@/lib/utils";
-import { useState } from "react";
-import { toast } from "@/components/ui/sonner";
-import { DEFAULT_EVENT_LIMIT } from "../../../lib/subscription/constants";
-import { trackAdEvent } from "../../../lib/trackAdEvent";
-import { FeaturesList } from "./FeaturesList";
-import {
- ENTERPRISE_FEATURES,
- EVENT_TIERS,
- FREE_FEATURES,
- PRO_FEATURES,
- STANDARD_FEATURES,
- findPriceForTier,
- formatEventTier,
-} from "./utils";
-
-import { useRouter } from "next/navigation";
-import { useQueryState } from "nuqs";
-
-export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
- const [siteId] = useQueryState("siteId");
- const router = useRouter();
-
- const [eventLimitIndex, setEventLimitIndex] = useState<number>(0);
- const [isAnnual, setIsAnnual] = useState<boolean>(false);
- const [isLoading, setIsLoading] = useState<boolean>(false);
- const { data: activeOrg } = authClient.useActiveOrganization();
-
- const eventLimit = EVENT_TIERS[eventLimitIndex];
-
- // Handle subscription for a specific plan type
- async function handleSubscribe(planType: "standard" | "pro"): Promise<void> {
- // Handle custom tier by redirecting to email contact
- if (eventLimit === "Custom") {
- window.location.href = "https://www.rybbit.com/contact";
- return;
- }
-
- // Check if user is logged in directly
- if (!isLoggedIn) {
- toast.error("Please log in to subscribe.");
- return;
- }
-
- // Check if user has an active organization
- if (!activeOrg) {
- toast.error("Please select an organization to subscribe.");
- return;
- }
-
- const selectedTierPrice = findPriceForTier(eventLimit, isAnnual ? "year" : "month", planType);
-
- if (!selectedTierPrice) {
- toast.error("Selected pricing plan not found. Please adjust the slider.");
- return;
- }
-
- setIsLoading(true);
- try {
- // Use NEXT_PUBLIC_BACKEND_URL if available, otherwise use relative path for same-origin requests
- const baseUrl = window.location.origin;
- const successUrl = `${baseUrl}/settings/organization/subscription?session_id={CHECKOUT_SESSION_ID}`;
- const cancelUrl = `${baseUrl}/subscribe${siteId ? `?siteId=${siteId}` : ""}`;
-
- const response = await fetch(`${BACKEND_URL}/stripe/create-checkout-session`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- credentials: "include", // Send cookies
- body: JSON.stringify({
- priceId: selectedTierPrice.priceId,
- successUrl: successUrl,
- cancelUrl: cancelUrl,
- organizationId: activeOrg.id,
- }),
- });
-
- const data = await response.json();
- trackAdEvent("checkout", { tier: selectedTierPrice.name });
-
- if (!response.ok) {
- throw new Error(data.error || "Failed to create checkout session.");
- }
-
- if (data.checkoutUrl) {
- window.location.href = data.checkoutUrl; // Redirect to Stripe checkout
- } else {
- throw new Error("Checkout URL not received.");
- }
- } catch (error: any) {
- toast.error(`Subscription failed: ${error.message}`);
- setIsLoading(false); // Stop loading on error
- }
- }
-
- // Handle slider changes
- function handleSliderChange(value: number[]): void {
- setEventLimitIndex(value[0]);
- }
-
- // Get pricing information for both plans
- const standardMonthlyPrice = findPriceForTier(eventLimit, "month", "standard")?.price || 0;
- const standardAnnualPrice = findPriceForTier(eventLimit, "year", "standard")?.price || 0;
- const proMonthlyPrice = findPriceForTier(eventLimit, "month", "pro")?.price || 0;
- const proAnnualPrice = findPriceForTier(eventLimit, "year", "pro")?.price || 0;
- const isCustomTier = eventLimit === "Custom";
-
- return (
- <div className="max-w-6xl mx-auto">
- {/* Shared controls section */}
- <div className="max-w-xl mx-auto mb-8">
- <div className="flex justify-between mb-6 items-center">
- <div>
- <h3 className="font-semibold mb-2">Monthly pageviews</h3>
- <div className="text-3xl font-bold text-emerald-400">
- {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}
- </div>
- </div>
- <div className="flex flex-col items-end">
- {/* Billing toggle */}
- <div className="flex mb-2 text-sm">
- <button
- onClick={() => setIsAnnual(false)}
- className={cn(
- "px-3 py-1 rounded-full transition-colors cursor-pointer",
- !isAnnual
- ? "bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 font-medium"
- : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
- )}
- >
- Monthly
- </button>
- <button
- onClick={() => setIsAnnual(true)}
- className={cn(
- "px-3 py-1 rounded-full transition-colors cursor-pointer",
- isAnnual
- ? "bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 font-medium"
- : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
- )}
- >
- Annual
- <span className="ml-1 text-xs text-emerald-500">-17%</span>
- </button>
- </div>
- </div>
- </div>
-
- {/* Slider */}
- <Slider
- defaultValue={[0]}
- max={EVENT_TIERS.length - 1}
- min={0}
- step={1}
- onValueChange={handleSliderChange}
- className="mb-3"
- />
-
- <div className="flex justify-between text-xs text-neutral-600 dark:text-neutral-400">
- {EVENT_TIERS.map((tier, index) => (
- <span
- key={index}
- className={cn(eventLimitIndex === index && "font-bold text-emerald-600 dark:text-emerald-400")}
- >
- {formatEventTier(tier)}
- </span>
- ))}
- </div>
- </div>
-
- {/* Cards section */}
- <div className="grid min-[1100px]:grid-cols-4 min-[600px]:grid-cols-2 min-[400px]:grid-cols-1 gap-6 max-w-6xl mx-auto mb-16">
- {/* Free Plan Card */}
- <div className="bg-neutral-100/30 dark:bg-neutral-800/15 rounded-xl border border-neutral-150 dark:border-neutral-800/60 overflow-hidden text-neutral-600 dark:text-neutral-300 shadow:lg">
- <div className="p-6">
- <div className="mb-4">
- <h3 className="text-xl font-bold mb-2">Free</h3>
- <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">Perfect for hobby projects</p>
- </div>
-
- {/* Price display */}
- <div className="mb-6">
- <div>
- <span className="text-3xl font-bold">{DEFAULT_EVENT_LIMIT.toLocaleString()}</span>
- <span className="ml-1 text-neutral-600 dark:text-neutral-400">pageviews/m</span>
- </div>
- </div>
-
- {/* Current plan button */}
- <button
- onClick={() => (siteId ? router.push(`/${siteId}`) : {})}
- disabled={!siteId}
- className="w-full bg-neutral-200 dark:bg-neutral-850 hover:bg-neutral-150 dark:hover:bg-neutral-800 text-neutral-600 dark:text-neutral-300 font-medium px-5 py-3 rounded-xl border border-neutral-250 dark:border-neutral-800 shadow-lg focus:outline-none focus:ring-2 focus:ring-neutral-400 focus:ring-opacity-50 cursor-pointer transition all duration-200"
- >
- {siteId ? "Continue free" : "Current plan"}
- </button>
-
- {/* Features */}
- <FeaturesList features={FREE_FEATURES} />
- </div>
- </div>
-
- {/* Standard Plan Card */}
- <div className="bg-white dark:bg-neutral-800/50 rounded-xl border border-neutral-150 dark:border-neutral-800/90 overflow-hidden text-neutral-900 dark:text-neutral-100 shadow-lg">
- <div className="p-6">
- <div className="mb-4">
- <h3 className="text-xl font-bold mb-2">Standard</h3>
- <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">
- Everything you need to get started as a small business
- </p>
- </div>
-
- {/* Price display */}
- <div className="mb-6">
- {isCustomTier ? (
- <div className="text-3xl font-bold">Custom</div>
- ) : (
- <div>
- <span className="text-3xl font-bold">
- ${isAnnual ? Math.round(standardAnnualPrice / 12) : standardMonthlyPrice}
- </span>
- <span className="ml-1 text-neutral-600 dark:text-neutral-400">/month</span>
- </div>
- )}
- </div>
-
- {/* Subscribe button */}
- <button
- onClick={() => handleSubscribe("standard")}
- className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-xl shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 disabled:opacity-50 disabled:pointer-events-none cursor-pointer"
- disabled={isLoading}
- >
- {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get started"}
- </button>
-
- {/* Features */}
- <FeaturesList features={STANDARD_FEATURES} />
- </div>
- </div>
-
- {/* Pro Plan Card */}
- <div className="bg-white dark:bg-neutral-800 rounded-xl border-2 border-emerald-500 overflow-hidden text-neutral-900 dark:text-neutral-100 shadow-lg">
- <div className="p-6">
- <div className="mb-4">
- <div className="flex items-center gap-2 mb-2">
- <h3 className="text-xl font-bold">Pro</h3>
- <span className="px-2 py-0.5 text-xs font-semibold bg-emerald-500/30 dark:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-full border border-emerald-500/40 dark:border-emerald-500/30">
- Recommended
- </span>
- </div>
- <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">
- Advanced features for professional teams
- </p>
- </div>
-
- {/* Price display */}
- <div className="mb-6">
- {isCustomTier ? (
- <div className="text-3xl font-bold">Custom</div>
- ) : (
- <div>
- <span className="text-3xl font-bold">
- ${isAnnual ? Math.round(proAnnualPrice / 12) : proMonthlyPrice}
- </span>
- <span className="ml-1 text-neutral-600 dark:text-neutral-400">/month</span>
- </div>
- )}
- </div>
-
- {/* Subscribe button */}
- <button
- onClick={() => handleSubscribe("pro")}
- className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-xl shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 disabled:opacity-50 disabled:pointer-events-none cursor-pointer"
- disabled={isLoading}
- >
- {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get started"}
- </button>
-
- {/* Features */}
- <FeaturesList features={PRO_FEATURES} />
- </div>
- </div>
-
- {/* Enterprise Plan Card */}
- <div className="bg-white dark:bg-neutral-800/50 rounded-xl border border-neutral-150 dark:border-neutral-800/90 overflow-hidden text-neutral-900 dark:text-neutral-100 shadow-lg">
- <div className="p-6">
- <div className="mb-4">
- <h3 className="text-xl font-bold mb-2">Enterprise</h3>
- <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">
- Advanced features for enterprise teams
- </p>
- </div>
-
- {/* Price display */}
- <div className="mb-6">
- <div className="text-3xl font-bold">Custom</div>
- </div>
-
- {/* Contact button */}
- <a href="https://www.rybbit.com/contact" className="w-full block">
- <button className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-xl shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 cursor-pointer">
- Contact us
- </button>
- </a>
-
- {/* Features */}
- <FeaturesList features={ENTERPRISE_FEATURES} />
- </div>
- </div>
- </div>
- </div>
- );
-}
diff --git a/client/src/app/subscribe/components/PricingCards.tsx b/client/src/app/subscribe/components/PricingCards.tsx
new file mode 100644
index 000000000..6f65c76f7
--- /dev/null
+++ b/client/src/app/subscribe/components/PricingCards.tsx
@@ -0,0 +1,261 @@
+"use client";
+
+import { Slider } from "@/components/ui/slider";
+import { authClient } from "@/lib/auth";
+import { BACKEND_URL } from "@/lib/const";
+import { cn } from "@/lib/utils";
+import { useState } from "react";
+import { toast } from "@/components/ui/sonner";
+import { DEFAULT_EVENT_LIMIT } from "../../../lib/subscription/constants";
+import { trackAdEvent } from "../../../lib/trackAdEvent";
+import { PricingCard } from "@/components/pricing/PricingCard";
+import {
+ ENTERPRISE_FEATURES,
+ EVENT_TIERS,
+ FREE_FEATURES,
+ PRO_FEATURES,
+ STANDARD_FEATURES,
+ findPriceForTier,
+ formatEventTier,
+} from "./utils";
+
+import { useRouter } from "next/navigation";
+import { useQueryState } from "nuqs";
+
+export function PricingCards({ isLoggedIn }: { isLoggedIn: boolean }) {
+ const [siteId] = useQueryState("siteId");
+ const router = useRouter();
+
+ const [eventLimitIndex, setEventLimitIndex] = useState<number>(0);
+ const [isAnnual, setIsAnnual] = useState<boolean>(true);
+ const [isLoading, setIsLoading] = useState<boolean>(false);
+ const { data: activeOrg } = authClient.useActiveOrganization();
+
+ const eventLimit = EVENT_TIERS[eventLimitIndex];
+
+ // Handle subscription for a specific plan type
+ async function handleSubscribe(planType: "standard" | "pro"): Promise<void> {
+ // Handle custom tier by redirecting to email contact
+ if (eventLimit === "Custom") {
+ window.location.href = "https://www.rybbit.com/contact";
+ return;
+ }
+
+ // Check if user is logged in directly
+ if (!isLoggedIn) {
+ toast.error("Please log in to subscribe.");
+ return;
+ }
+
+ // Check if user has an active organization
+ if (!activeOrg) {
+ toast.error("Please select an organization to subscribe.");
+ return;
+ }
+
+ const selectedTierPrice = findPriceForTier(eventLimit, isAnnual ? "year" : "month", planType);
+
+ if (!selectedTierPrice) {
+ toast.error("Selected pricing plan not found. Please adjust the slider.");
+ return;
+ }
+
+ setIsLoading(true);
+ try {
+ // Use NEXT_PUBLIC_BACKEND_URL if available, otherwise use relative path for same-origin requests
+ const baseUrl = window.location.origin;
+ const successUrl = `${baseUrl}/settings/organization/subscription?session_id={CHECKOUT_SESSION_ID}`;
+ const cancelUrl = `${baseUrl}/subscribe${siteId ? `?siteId=${siteId}` : ""}`;
+
+ const response = await fetch(`${BACKEND_URL}/stripe/create-checkout-session`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ credentials: "include", // Send cookies
+ body: JSON.stringify({
+ priceId: selectedTierPrice.priceId,
+ successUrl: successUrl,
+ cancelUrl: cancelUrl,
+ organizationId: activeOrg.id,
+ }),
+ });
+
+ const data = await response.json();
+ trackAdEvent("checkout", { tier: selectedTierPrice.name });
+
+ if (!response.ok) {
+ throw new Error(data.error || "Failed to create checkout session.");
+ }
+
+ if (data.checkoutUrl) {
+ window.location.href = data.checkoutUrl; // Redirect to Stripe checkout
+ } else {
+ throw new Error("Checkout URL not received.");
+ }
+ } catch (error: any) {
+ toast.error(`Subscription failed: ${error.message}`);
+ setIsLoading(false); // Stop loading on error
+ }
+ }
+
+ // Handle slider changes
+ function handleSliderChange(value: number[]): void {
+ setEventLimitIndex(value[0]);
+ }
+
+ // Get pricing information for both plans
+ const standardMonthlyPrice = findPriceForTier(eventLimit, "month", "standard")?.price || 0;
+ const standardAnnualPrice = findPriceForTier(eventLimit, "year", "standard")?.price || 0;
+ const proMonthlyPrice = findPriceForTier(eventLimit, "month", "pro")?.price || 0;
+ const proAnnualPrice = findPriceForTier(eventLimit, "year", "pro")?.price || 0;
+ const isCustomTier = eventLimit === "Custom";
+
+ return (
+ <div className="max-w-[1300px] mx-auto">
+ {/* Shared controls section */}
+ <div className="max-w-xl mx-auto mb-8">
+ <div className="flex justify-between mb-6 items-center">
+ <div>
+ <h3 className="font-semibold mb-2">Monthly pageviews</h3>
+ <div className="text-3xl font-bold text-emerald-400">
+ {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}
+ </div>
+ </div>
+ <div className="flex flex-col items-end">
+ {/* Billing toggle */}
+ <div className="relative flex items-center">
+ <div className="flex bg-neutral-150 dark:bg-neutral-850 border border-neutral-250 dark:border-neutral-750 rounded-full p-1 text-sm">
+ <button
+ onClick={() => setIsAnnual(false)}
+ className={cn(
+ "px-3 py-1 rounded-full transition-colors cursor-pointer",
+ !isAnnual
+ ? "bg-white dark:bg-white/20 text-neutral-700 dark:text-neutral-100 font-medium"
+ : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
+ )}
+ >
+ Monthly
+ </button>
+ <button
+ onClick={() => setIsAnnual(true)}
+ className={cn(
+ "px-3 py-1 rounded-full transition-colors cursor-pointer",
+ isAnnual
+ ? "bg-white dark:bg-white/20 text-neutral-700 dark:text-neutral-100 font-medium"
+ : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
+ )}
+ >
+ Annual
+ </button>
+ </div>
+ <span className="absolute -top-3 -right-12 text-xs text-white bg-emerald-500 border border-emerald-500 rounded-full px-2 py-0.5 whitespace-nowrap">
+ 2 months free
+ </span>
+ </div>
+ </div>
+ </div>
+
+ {/* Slider */}
+ <Slider
+ defaultValue={[0]}
+ max={EVENT_TIERS.length - 1}
+ min={0}
+ step={1}
+ onValueChange={handleSliderChange}
+ className="mb-3"
+ />
+
+ <div className="flex justify-between text-xs text-neutral-600 dark:text-neutral-400">
+ {EVENT_TIERS.map((tier, index) => (
+ <span
+ key={index}
+ className={cn(eventLimitIndex === index && "font-bold text-emerald-600 dark:text-emerald-400")}
+ >
+ {index === EVENT_TIERS.length - 1 && typeof tier !== "number"
+ ? "20M+"
+ : formatEventTier(tier)}
+ </span>
+ ))}
+ </div>
+ </div>
+
+ {/* Cards section */}
+ <div className="grid min-[1100px]:grid-cols-4 min-[600px]:grid-cols-2 min-[400px]:grid-cols-1 gap-6 max-w-[1300px] mx-auto mb-16">
+ <PricingCard
+ title="Free"
+ description="Perfect for hobby projects"
+ priceDisplay={
+ <div>
+ <span className="text-3xl font-bold">{DEFAULT_EVENT_LIMIT.toLocaleString()}</span>
+ <span className="ml-1 text-neutral-600 dark:text-neutral-400">pageviews/m</span>
+ </div>
+ }
+ buttonText={siteId ? "Continue free" : "Current plan"}
+ buttonVariant="default"
+ features={FREE_FEATURES}
+ variant="free"
+ onClick={() => (siteId ? router.push(`/${siteId}`) : undefined)}
+ disabled={!siteId}
+ />
+
+ <PricingCard
+ title="Standard"
+ description="Everything you need to get started as a small business"
+ priceDisplay={
+ isCustomTier ? (
+ <div className="text-3xl font-bold">Custom</div>
+ ) : (
+ <div>
+ <span className="text-3xl font-bold">
+ ${isAnnual ? Math.round(standardAnnualPrice / 12) : standardMonthlyPrice}
+ </span>
+ <span className="ml-1 text-neutral-600 dark:text-neutral-400">/month</span>
+ </div>
+ )
+ }
+ buttonText={isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get started"}
+ features={STANDARD_FEATURES}
+ onClick={() => handleSubscribe("standard")}
+ disabled={isLoading}
+ />
+
+ <PricingCard
+ title="Pro"
+ description="Advanced features for professional teams"
+ priceDisplay={
+ isCustomTier ? (
+ <div className="text-3xl font-bold">Custom</div>
+ ) : (
+ <div>
+ <span className="text-3xl font-bold">
+ ${isAnnual ? Math.round(proAnnualPrice / 12) : proMonthlyPrice}
+ </span>
+ <span className="ml-1 text-neutral-600 dark:text-neutral-400">/month</span>
+ </div>
+ )
+ }
+ buttonText={isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Get started"}
+ features={PRO_FEATURES}
+ recommended={true}
+ onClick={() => handleSubscribe("pro")}
+ disabled={isLoading}
+ />
+
+ <PricingCard
+ title="Enterprise"
+ description="Advanced features for enterprise teams"
+ priceDisplay={<div className="text-3xl font-bold">Custom</div>}
+ features={ENTERPRISE_FEATURES}
+ customButton={
+ <a href="https://www.rybbit.com/contact" className="w-full block">
+ <button className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-lg shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 cursor-pointer">
+ Contact us
+ </button>
+ </a>
+ }
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/app/subscribe/components/utils.ts b/client/src/app/subscribe/components/utils.ts
index b5af95cf8..e69292c6c 100644
--- a/client/src/app/subscribe/components/utils.ts
+++ b/client/src/app/subscribe/components/utils.ts
@@ -3,6 +3,8 @@
import { FREE_SITE_LIMIT, STANDARD_SITE_LIMIT, STANDARD_TEAM_LIMIT } from "../../../lib/const";
import { getStripePrices, STRIPE_TIERS } from "../../../lib/stripe";
+import { FeatureItem } from "@/components/pricing/PricingCard";
+
export const EVENT_TIERS = [...STRIPE_TIERS.map(tier => tier.events), "Custom"];
export const STANDARD_FEATURES = [
@@ -45,12 +47,14 @@ export const ENTERPRISE_FEATURES = [
"Slack/live chat support",
];
-export const FREE_FEATURES = [
- "1 user",
- `${FREE_SITE_LIMIT} website`,
- "Web analytics dashboard",
- "Custom events",
- "6 month data retention",
+export const FREE_FEATURES: FeatureItem[] = [
+ { feature: "1 user", included: true },
+ { feature: `${FREE_SITE_LIMIT} website`, included: true },
+ { feature: "Web analytics dashboard", included: true },
+ { feature: "Custom events", included: true },
+ { feature: "6 month data retention", included: true },
+ { feature: "Advanced features", included: false },
+ { feature: "Email support", included: false },
];
const stripePrices = getStripePrices();
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index 68d1e9abd..2e74ba0fd 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -7,7 +7,7 @@ import { Suspense } from "react";
import { StandardPage } from "../../components/StandardPage";
import { UsageChart } from "../../components/UsageChart";
import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";
-import { PricingCard } from "./components/PricingCard";
+import { PricingCards } from "./components/PricingCards";
import { PricingHeader } from "./components/PricingHeader";
import { useQueryState } from "nuqs";
@@ -38,7 +38,7 @@ function SubscribeContent() {
<PricingHeader />
{/* Pricing Card */}
- <PricingCard isLoggedIn={!!sessionData?.user} />
+ <PricingCards isLoggedIn={!!sessionData?.user} />
</div>
</StandardPage>
);
@@ -50,7 +50,7 @@ function SubscribeContent() {
<PricingHeader />
{/* Pricing Card */}
- <PricingCard isLoggedIn={!!sessionData?.user} />
+ <PricingCards isLoggedIn={!!sessionData?.user} />
{/* Usage Stats and Chart */}
{organizationId && (
diff --git a/client/src/components/pricing/PricingCard.tsx b/client/src/components/pricing/PricingCard.tsx
new file mode 100644
index 000000000..5a715044e
--- /dev/null
+++ b/client/src/components/pricing/PricingCard.tsx
@@ -0,0 +1,139 @@
+import { Check, X, ArrowDown, ArrowUp } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { useState } from "react";
+
+export type FeatureItem = { feature: string; included?: boolean } | string;
+
+export interface PricingCardProps {
+ title: string;
+ description: string;
+ priceDisplay: React.ReactNode;
+ buttonText?: string;
+ buttonVariant?: "default" | "primary";
+ features: FeatureItem[];
+ footerText?: React.ReactNode;
+ variant?: "free" | "default";
+ recommended?: boolean;
+ customButton?: React.ReactNode;
+ onClick?: () => void;
+ disabled?: boolean;
+}
+
+export function PricingCard({
+ title,
+ description,
+ priceDisplay,
+ buttonText,
+ buttonVariant = "primary",
+ features,
+ footerText,
+ variant = "default",
+ recommended = false,
+ customButton,
+ onClick,
+ disabled,
+}: PricingCardProps) {
+ const [isExpanded, setIsExpanded] = useState(false);
+ const isFree = variant === "free";
+ const isPrimary = buttonVariant === "primary";
+
+ const shouldShowToggle = features.length > 7;
+ const displayedFeatures = shouldShowToggle && !isExpanded ? features.slice(0, 7) : features;
+
+ return (
+ <div className="w-full flex-shrink-0">
+ <div className="bg-neutral-200/20 dark:bg-neutral-900/40 p-2 rounded-3xl border border-neutral-200 dark:border-neutral-800 h-full">
+ <div
+ className={cn(
+ "rounded-2xl border overflow-hidden backdrop-blur-sm shadow-xl h-full",
+ recommended
+ ? "bg-neutral-50 dark:bg-neutral-800/60 border-emerald-500 border-2"
+ : isFree
+ ? "bg-neutral-50/80 dark:bg-neutral-800/15 border-neutral-200/60 dark:border-neutral-800/60 text-neutral-600 dark:text-neutral-300"
+ : "bg-neutral-50/50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-800"
+ )}
+ >
+ <div className="p-6">
+ <div className="mb-4">
+ <div className="flex items-center gap-2 mb-2">
+ <h3 className="text-xl font-bold">{title}</h3>
+ {recommended && (
+ <span className="px-2 py-0.5 text-xs font-semibold bg-emerald-500/30 dark:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-full border border-emerald-500/40 dark:border-emerald-500/30">
+ Recommended
+ </span>
+ )}
+ </div>
+ <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">{description}</p>
+ </div>
+
+ {/* Price display */}
+ <div className="mb-6">{priceDisplay}</div>
+
+ {customButton ? (
+ customButton
+ ) : (
+ <button
+ onClick={onClick}
+ disabled={disabled}
+ className={cn(
+ "w-full font-medium px-5 py-3 rounded-lg transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-opacity-50 cursor-pointer",
+ isPrimary
+ ? "bg-emerald-600 hover:bg-emerald-500 text-white shadow-lg shadow-emerald-900/20 focus:ring-emerald-500 disabled:opacity-50 disabled:pointer-events-none"
+ : "bg-neutral-200 dark:bg-neutral-850 hover:bg-neutral-150 dark:hover:bg-neutral-800 text-neutral-600 dark:text-neutral-300 border border-neutral-250 dark:border-neutral-800 shadow-lg focus:ring-neutral-400"
+ )}
+ >
+ {buttonText}
+ </button>
+ )}
+
+ <div className="mt-6 mb-1 space-y-3">
+ {displayedFeatures.map((item, i) => {
+ const isObject = typeof item === "object";
+ const feature = isObject ? item.feature : item;
+ const included = isObject ? item.included !== false : true;
+
+ return (
+ <div key={i} className="flex items-center">
+ {included ? (
+ <Check className="h-4 w-4 text-emerald-600 dark:text-emerald-400 mr-3 shrink-0" />
+ ) : (
+ <X className="h-4 w-4 text-neutral-400 dark:text-neutral-500 mr-3 shrink-0" />
+ )}
+ <span className={cn("text-sm", !included && "text-neutral-400 dark:text-neutral-500")}>
+ {feature}
+ </span>
+ </div>
+ );
+ })}
+
+ {shouldShowToggle && (
+ <button
+ onClick={() => setIsExpanded(!isExpanded)}
+ className="flex items-center text-sm text-neutral-400 dark:text-neutral-400 hover:text-neutral-200 dark:hover:text-neutral-300 transition-colors cursor-pointer mt-2"
+ >
+ {isExpanded ? (
+ <>
+ <ArrowUp className="h-4 w-4 mr-3" />
+ Show less
+ </>
+ ) : (
+ <>
+ <ArrowDown className="h-4 w-4 mr-3" />
+ Show more ({features.length - 7} more)
+ </>
+ )}
+ </button>
+ )}
+ </div>
+
+ {footerText && (
+ <p className="text-center text-sm text-neutral-600 dark:text-neutral-400 mt-4 flex items-center justify-center gap-2">
+ {footerText}
+ </p>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/docs/src/components/PricingCard.tsx b/docs/src/components/PricingCard.tsx
index 9167e416d..d4d8be6ed 100644
--- a/docs/src/components/PricingCard.tsx
+++ b/docs/src/components/PricingCard.tsx
@@ -1,23 +1,26 @@
-import { Check, X, CheckCircle, ArrowDown, ArrowUp } from "lucide-react";
-import Link from "next/link";
+import { Check, X, ArrowDown, ArrowUp } from "lucide-react";
import { cn } from "@/lib/utils";
import { trackAdEvent } from "@/lib/trackAdEvent";
+import Link from "next/link";
import { useState } from "react";
-interface PricingCardProps {
+export type FeatureItem = { feature: string; included?: boolean } | string;
+
+export interface PricingCardProps {
title: string;
description: string;
priceDisplay: React.ReactNode;
buttonText?: string;
buttonHref?: string;
buttonVariant?: "default" | "primary";
- features: Array<{ feature: string; included?: boolean } | string>;
+ features: FeatureItem[];
footerText?: React.ReactNode;
variant?: "free" | "default";
- eventLocation?: string;
- onClick?: () => void;
- customButton?: React.ReactNode;
recommended?: boolean;
+ customButton?: React.ReactNode;
+ onClick?: () => void;
+ disabled?: boolean;
+ eventLocation?: string;
}
export function PricingCard({
@@ -30,10 +33,11 @@ export function PricingCard({
features,
footerText,
variant = "default",
- eventLocation,
- onClick,
- customButton,
recommended = false,
+ customButton,
+ onClick,
+ disabled,
+ eventLocation,
}: PricingCardProps) {
const [isExpanded, setIsExpanded] = useState(false);
const isFree = variant === "free";
@@ -49,97 +53,113 @@ export function PricingCard({
className={cn(
"rounded-2xl border overflow-hidden backdrop-blur-sm shadow-xl h-full",
recommended
- ? "bg-neutral-100/80 dark:bg-neutral-800/100 border-emerald-500 border-2"
+ ? "bg-neutral-100/80 dark:bg-neutral-800 border-emerald-500 border-2"
: isFree
- ? "bg-neutral-100/30 dark:bg-neutral-800/15 border-neutral-300/60 dark:border-neutral-800/60 text-neutral-600 dark:text-neutral-300"
- : "bg-neutral-50 dark:bg-neutral-900 border-neutral-300 dark:border-neutral-800"
+ ? "bg-neutral-100/30 dark:bg-neutral-800/15 border-neutral-300/60 dark:border-neutral-800/60 text-neutral-600 dark:text-neutral-300"
+ : "bg-neutral-50 dark:bg-neutral-900 border-neutral-300 dark:border-neutral-800"
)}
>
- <div className="p-6">
- <div className="mb-4">
- <div className="flex items-center gap-2 mb-2">
- <h3 className="text-xl font-bold">{title}</h3>
- {recommended && (
- <span className="px-2 py-0.5 text-xs font-semibold bg-emerald-500/30 dark:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-full border border-emerald-500/40 dark:border-emerald-500/30">
- Recommended
- </span>
- )}
+ <div className="p-6">
+ <div className="mb-4">
+ <div className="flex items-center gap-2 mb-2">
+ <h3 className="text-xl font-bold">{title}</h3>
+ {recommended && (
+ <span className="px-2 py-0.5 text-xs font-semibold bg-emerald-500/30 dark:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-full border border-emerald-500/40 dark:border-emerald-500/30">
+ Recommended
+ </span>
+ )}
+ </div>
+ <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">{description}</p>
</div>
- <p className="text-sm text-neutral-600 dark:text-neutral-400 h-10">{description}</p>
- </div>
- {/* Price display */}
- <div className="mb-6">{priceDisplay}</div>
+ {/* Price display */}
+ <div className="mb-6">{priceDisplay}</div>
- {customButton ? (
- customButton
- ) : (
- <Link href={buttonHref!} className="w-full block">
+ {customButton ? (
+ customButton
+ ) : buttonHref ? (
+ <Link href={buttonHref} className="w-full block">
+ <button
+ onClick={() => {
+ if (eventLocation) {
+ trackAdEvent("signup", { location: "pricing" });
+ }
+ onClick?.();
+ }}
+ disabled={disabled}
+ data-rybbit-event={eventLocation ? "signup" : undefined}
+ data-rybbit-prop-location={eventLocation}
+ className={cn(
+ "w-full font-medium px-5 py-3 rounded-lg transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-opacity-50 cursor-pointer",
+ isPrimary
+ ? "bg-emerald-600 hover:bg-emerald-500 text-white shadow-lg shadow-emerald-900/20 focus:ring-emerald-500 disabled:opacity-50 disabled:pointer-events-none"
+ : "bg-neutral-300 dark:bg-neutral-700 hover:bg-neutral-200 dark:hover:bg-neutral-600 text-neutral-900 dark:text-white"
+ )}
+ >
+ {buttonText}
+ </button>
+ </Link>
+ ) : (
<button
- onClick={() => {
- if (eventLocation) {
- trackAdEvent("signup", { location: "pricing" });
- }
- onClick?.();
- }}
- data-rybbit-event={eventLocation ? "signup" : undefined}
- data-rybbit-prop-location={eventLocation}
+ onClick={onClick}
+ disabled={disabled}
className={cn(
"w-full font-medium px-5 py-3 rounded-lg transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-opacity-50 cursor-pointer",
isPrimary
- ? "bg-emerald-600 hover:bg-emerald-500 text-white shadow-lg shadow-emerald-900/20 focus:ring-emerald-500"
+ ? "bg-emerald-600 hover:bg-emerald-500 text-white shadow-lg shadow-emerald-900/20 focus:ring-emerald-500 disabled:opacity-50 disabled:pointer-events-none"
: "bg-neutral-300 dark:bg-neutral-700 hover:bg-neutral-200 dark:hover:bg-neutral-600 text-neutral-900 dark:text-white"
)}
>
{buttonText}
</button>
- </Link>
- )}
+ )}
+
+ <div className="mt-6 mb-1 space-y-3">
+ {displayedFeatures.map((item, i) => {
+ const isObject = typeof item === "object";
+ const feature = isObject ? item.feature : item;
+ const included = isObject ? item.included !== false : true;
- <div className={cn("mt-6 mb-1", "space-y-3")}>
- {displayedFeatures.map((item, i) => {
- const isObject = typeof item === "object";
- const feature = isObject ? item.feature : item;
- const included = isObject ? item.included : true;
+ return (
+ <div key={i} className="flex items-center">
+ {included ? (
+ <Check className="h-4 w-4 text-emerald-600 dark:text-emerald-400 mr-3 shrink-0" />
+ ) : (
+ <X className="h-4 w-4 text-neutral-400 dark:text-neutral-500 mr-3 shrink-0" />
+ )}
+ <span className={cn("text-sm", !included && "text-neutral-400 dark:text-neutral-500")}>
+ {feature}
+ </span>
+ </div>
+ );
+ })}
- return (
- <div key={i} className="flex items-center">
- {included ? (
- <Check className="h-4 w-4 text-emerald-600 dark:text-emerald-400 mr-3 shrink-0" />
+ {shouldShowToggle && (
+ <button
+ onClick={() => setIsExpanded(!isExpanded)}
+ className="flex items-center text-sm text-neutral-400 dark:text-neutral-400 hover:text-neutral-200 dark:hover:text-neutral-300 transition-colors cursor-pointer mt-2"
+ >
+ {isExpanded ? (
+ <>
+ <ArrowUp className="h-4 w-4 mr-3" />
+ Show less
+ </>
) : (
- <X className="h-4 w-4 text-neutral-500 dark:text-neutral-400 mr-3 shrink-0" />
+ <>
+ <ArrowDown className="h-4 w-4 mr-3" />
+ Show more ({features.length - 7} more)
+ </>
)}
- <span className="text-sm">{feature}</span>
- </div>
- );
- })}
+ </button>
+ )}
+ </div>
- {shouldShowToggle && (
- <button
- onClick={() => setIsExpanded(!isExpanded)}
- className="flex items-center text-sm text-neutral-400 dark:text-neutral-400 hover:text-neutral-200 dark:hover:text-neutral-300 transition-colors cursor-pointer mt-2"
- >
- {isExpanded ? (
- <>
- <ArrowUp className="h-4 w-4 mr-3" />
- Show less
- </>
- ) : (
- <>
- <ArrowDown className="h-4 w-4 mr-3" />
- Show more ({features.length - 7} more)
- </>
- )}
- </button>
+ {footerText && (
+ <p className="text-center text-sm text-neutral-600 dark:text-neutral-400 mt-4 flex items-center justify-center gap-2">
+ {footerText}
+ </p>
)}
</div>
-
- {footerText && (
- <p className="text-center text-sm text-neutral-600 dark:text-neutral-400 mt-4 flex items-center justify-center gap-2">
- {footerText}
- </p>
- )}
- </div>
</div>
</div>
</div>