Skip to content

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

Refactor layout components to enhance structure and introduce StandardPage wrapper

Bill Yang3e820777266c
diff --git a/client/src/app/[site]/Header/Header.tsx b/client/src/app/[site]/Header/Header.tsx
deleted file mode 100644
index 5ce2da126..000000000
--- a/client/src/app/[site]/Header/Header.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-"use client";
-import { ChartBarDecreasing, ChartLine, Radio, User } from "lucide-react";
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-import { useGetSites } from "../../../api/admin/sites";
-import { SiteSettings } from "../../../components/SiteSettings/SiteSettings";
-import LiveUserCount from "./LiveUserCount";
-import { UsageBanners } from "./UsageBanners";
-
-export function Header() {
- const { data: sites } = useGetSites();
- const pathname = usePathname();
-
- const site = sites?.find(
- (site) => site.siteId === Number(pathname.split("/")[1])
- );
-
- // Check which tab is active based on the current path
- const getTabPath = (tabName: string) => {
- return `/${pathname.split("/")[1]}/${tabName.toLowerCase()}`;
- };
-
- const isActiveTab = (tabName: string) => {
- if (!pathname.includes("/")) return false;
-
- const route = pathname.split("/")[2] || "main";
- return route === tabName.toLowerCase();
- };
-
- return (
- <div className="flex flex-col">
- {/* Usage Banners */}
- <UsageBanners site={site} />
-
- <div className="flex items-center justify-between py-2">
- <div className="flex gap-3">
- <div className="flex items-center gap-2 text-xl font-bold">
- <img
- className="w-7 mr-1"
- src={`https://www.google.com/s2/favicons?domain=${site?.domain}&sz=64`}
- />
- <div>{site?.domain}</div>
- </div>
- <div className="flex items-center gap-1 text-base text-neutral-600 dark:text-neutral-400">
- <LiveUserCount />
- <SiteSettings siteId={site?.siteId ?? 0} />
- </div>
- </div>
- <div className="flex space-x-2">
- <TabButton
- label="Main"
- active={isActiveTab("main")}
- href={getTabPath("main")}
- icon={<ChartLine size={20} />}
- />
- <TabButton
- label="Sessions"
- active={isActiveTab("sessions")}
- href={getTabPath("sessions")}
- icon={<User size={20} />}
- />
- <TabButton
- label="Realtime"
- active={isActiveTab("realtime")}
- href={getTabPath("realtime")}
- icon={<Radio size={20} />}
- />
- <TabButton
- label="Retention"
- active={isActiveTab("retention")}
- href={getTabPath("retention")}
- icon={<ChartBarDecreasing size={20} />}
- />
- <TabButton
- label="Reports"
- active={isActiveTab("reports")}
- href={getTabPath("reports")}
- icon={<ChartBarDecreasing size={20} />}
- />
- </div>
- </div>
- </div>
- );
-}
-
-// Tab Button component with navigation
-function TabButton({
- label,
- active = false,
- href,
- icon,
-}: {
- label: string;
- active?: boolean;
- href: string;
- icon?: React.ReactNode;
-}) {
- return (
- <Link href={href} className="focus:outline-none">
- <button
- className={`px-3 py-2 rounded-lg font-sm transition-colors ${
- active
- ? "bg-neutral-800 text-white hover:bg-neutral-800/75 "
- : "text-neutral-400 hover:text-white hover:bg-neutral-800/50"
- }`}
- >
- <div className="flex items-center gap-2">
- {icon}
- {label}
- </div>
- </button>
- </Link>
- );
-}
diff --git a/client/src/app/[site]/components/Header/Header.tsx b/client/src/app/[site]/components/Header/Header.tsx
new file mode 100644
index 000000000..357ce65d8
--- /dev/null
+++ b/client/src/app/[site]/components/Header/Header.tsx
@@ -0,0 +1,29 @@
+"use client";
+import { usePathname } from "next/navigation";
+import { useGetSites } from "../../../../api/admin/sites";
+import { SiteSettings } from "../../../../components/SiteSettings/SiteSettings";
+import LiveUserCount from "./LiveUserCount";
+import { UsageBanners } from "./UsageBanners";
+
+export function Header() {
+ const { data: sites } = useGetSites();
+ const pathname = usePathname();
+
+ const site = sites?.find(
+ (site) => site.siteId === Number(pathname.split("/")[1])
+ );
+
+ return (
+ <div className="flex flex-col">
+ <div className="flex items-center justify-between py-2">
+ <div className="flex gap-3">
+ <div className="flex items-center gap-1 text-base text-neutral-600 dark:text-neutral-400">
+ <LiveUserCount />
+ <SiteSettings siteId={site?.siteId ?? 0} />
+ </div>
+ </div>
+ </div>
+ {/* <UsageBanners site={site} /> */}
+ </div>
+ );
+}
diff --git a/client/src/app/[site]/Header/LiveUserCount.tsx b/client/src/app/[site]/components/Header/LiveUserCount.tsx
similarity index 88%
rename from client/src/app/[site]/Header/LiveUserCount.tsx
rename to client/src/app/[site]/components/Header/LiveUserCount.tsx
index 93e8ed751..09422415e 100644
--- a/client/src/app/[site]/Header/LiveUserCount.tsx
+++ b/client/src/app/[site]/components/Header/LiveUserCount.tsx
@@ -1,9 +1,9 @@
-import { useGetLiveUsercount } from "../../../api/analytics/useLiveUserCount";
+import { useGetLiveUsercount } from "../../../../api/analytics/useLiveUserCount";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
-} from "../../../components/ui/tooltip";
+} from "../../../../components/ui/tooltip";
import NumberFlow from "@number-flow/react";
export default function LiveUserCount() {
diff --git a/client/src/app/[site]/Header/UsageBanners.tsx b/client/src/app/[site]/components/Header/UsageBanners.tsx
similarity index 96%
rename from client/src/app/[site]/Header/UsageBanners.tsx
rename to client/src/app/[site]/components/Header/UsageBanners.tsx
index c95832f93..63c6c5b7a 100644
--- a/client/src/app/[site]/Header/UsageBanners.tsx
+++ b/client/src/app/[site]/components/Header/UsageBanners.tsx
@@ -4,9 +4,9 @@ import {
Alert,
AlertDescription,
AlertTitle,
-} from "../../../components/ui/alert";
-import { Button } from "../../../components/ui/button";
-import { GetSitesResponse } from "../../../api/admin/sites";
+} from "../../../../components/ui/alert";
+import { Button } from "../../../../components/ui/button";
+import { GetSitesResponse } from "../../../../api/admin/sites";
interface UsageBannersProps {
site: GetSitesResponse[0] | undefined;
diff --git a/client/src/app/[site]/components/NoData.tsx b/client/src/app/[site]/components/NoData.tsx
index 4d109331a..d2c5e867f 100644
--- a/client/src/app/[site]/components/NoData.tsx
+++ b/client/src/app/[site]/components/NoData.tsx
@@ -2,6 +2,7 @@ import { CodeSnippet } from "../../../components/CodeSnippet";
import { Card, CardContent, CardHeader } from "../../../components/ui/card";
import { GetSitesResponse } from "../../../api/admin/sites";
import { BACKEND_URL } from "../../../lib/const";
+import { StandardPage } from "../../../components/StandardPage";
export function NoData({
siteMetadata,
@@ -9,29 +10,31 @@ export function NoData({
siteMetadata?: GetSitesResponse[number];
}) {
return (
- <div className="flex justify-center items-center mt-5">
- <Card className="w-[500px] p-2">
- <CardHeader className="flex justify-center items-center">
- <div className="text-xl font-medium text-center w-full">
- Waiting for analytics from {siteMetadata?.domain}...
- </div>
- <div className="p-5">
- {/* @ts-ignore */}
- <l-ping size={50} color="hsl(var(--emerald-400))" speed="3" />
- </div>
- </CardHeader>
- <CardContent className="flex flex-col gap-4">
- <div className="flex flex-col gap-1">
- <div className="text-sm text-muted-foreground">
- Place this snippet in the &lt;head&gt; of your website
+ <StandardPage>
+ <div className="flex justify-center items-center mt-5">
+ <Card className="w-[500px] p-2">
+ <CardHeader className="flex justify-center items-center">
+ <div className="text-xl font-medium text-center w-full">
+ Waiting for analytics from {siteMetadata?.domain}...
</div>
- <CodeSnippet
- language="HTML"
- code={`<script\n src="${BACKEND_URL}/script.js"\n site-id="${siteMetadata?.siteId}"\n defer\n/>`}
- />
- </div>
- </CardContent>
- </Card>
- </div>
+ <div className="p-5">
+ {/* @ts-ignore */}
+ <l-ping size={50} color="hsl(var(--emerald-400))" speed="3" />
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-4">
+ <div className="flex flex-col gap-1">
+ <div className="text-sm text-muted-foreground">
+ Place this snippet in the &lt;head&gt; of your website
+ </div>
+ <CodeSnippet
+ language="HTML"
+ code={`<script\n src="${BACKEND_URL}/script.js"\n site-id="${siteMetadata?.siteId}"\n defer\n/>`}
+ />
+ </div>
+ </CardContent>
+ </Card>
+ </div>
+ </StandardPage>
);
}
diff --git a/client/src/app/[site]/components/Sidebar/Sidebar.tsx b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
new file mode 100644
index 000000000..fd994afe7
--- /dev/null
+++ b/client/src/app/[site]/components/Sidebar/Sidebar.tsx
@@ -0,0 +1,105 @@
+"use client";
+import { ChartBarDecreasing, ChartLine, Radio, User } from "lucide-react";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { useGetSites } from "../../../../api/admin/sites";
+
+export function Sidebar() {
+ const { data: sites } = useGetSites();
+ const pathname = usePathname();
+
+ const site = sites?.find(
+ (site) => site.siteId === Number(pathname.split("/")[1])
+ );
+
+ // Check which tab is active based on the current path
+ const getTabPath = (tabName: string) => {
+ return `/${pathname.split("/")[1]}/${tabName.toLowerCase()}`;
+ };
+
+ const isActiveTab = (tabName: string) => {
+ if (!pathname.includes("/")) return false;
+
+ const route = pathname.split("/")[2] || "main";
+ return route === tabName.toLowerCase();
+ };
+
+ return (
+ <div className="w-56 bg-neutral-900 border-r border-neutral-850 h-full flex flex-col">
+ {site && (
+ <div className="p-4 border-b border-t border-neutral-800">
+ <div className="flex items-center gap-2">
+ <img
+ className="w-6"
+ src={`https://www.google.com/s2/favicons?domain=${site.domain}&sz=64`}
+ alt={site.domain}
+ />
+ <div className="font-medium text-white truncate">{site.domain}</div>
+ </div>
+ </div>
+ )}
+ <div className="flex flex-col space-y-1 p-3 mt-2">
+ <SidebarLink
+ label="Main"
+ active={isActiveTab("main")}
+ href={getTabPath("main")}
+ icon={<ChartLine size={18} />}
+ />
+ <SidebarLink
+ label="Sessions"
+ active={isActiveTab("sessions")}
+ href={getTabPath("sessions")}
+ icon={<User size={18} />}
+ />
+ <SidebarLink
+ label="Realtime"
+ active={isActiveTab("realtime")}
+ href={getTabPath("realtime")}
+ icon={<Radio size={18} />}
+ />
+ <SidebarLink
+ label="Retention"
+ active={isActiveTab("retention")}
+ href={getTabPath("retention")}
+ icon={<ChartBarDecreasing size={18} />}
+ />
+ <SidebarLink
+ label="Reports"
+ active={isActiveTab("reports")}
+ href={getTabPath("reports")}
+ icon={<ChartBarDecreasing size={18} />}
+ />
+ </div>
+ </div>
+ );
+}
+
+// Sidebar Link component
+function SidebarLink({
+ label,
+ active = false,
+ href,
+ icon,
+}: {
+ label: string;
+ active?: boolean;
+ href: string;
+ icon?: React.ReactNode;
+}) {
+ return (
+ <Link href={href} className="focus:outline-none">
+ <div
+ className={`px-3 py-2.5 rounded-lg transition-colors w-full ${
+ active
+ ? "bg-neutral-800 text-white"
+ : "text-neutral-200 hover:text-white hover:bg-neutral-800/50"
+ }`}
+ >
+ <div className="flex items-center gap-2">
+ {icon}
+ <span className="text-sm">{label}</span>
+ </div>
+ </div>
+ </Link>
+ );
+}
diff --git a/client/src/app/[site]/layout.tsx b/client/src/app/[site]/layout.tsx
index f9c309e99..4b12eee44 100644
--- a/client/src/app/[site]/layout.tsx
+++ b/client/src/app/[site]/layout.tsx
@@ -3,9 +3,11 @@ import { usePathname } from "next/navigation";
import { useEffect } from "react";
import { useStore } from "../../lib/store";
import { useSyncStateWithUrl } from "../../lib/urlParams";
-import { Header } from "./Header/Header";
+import { Header } from "./components/Header/Header";
import { useSiteHasData, useGetSiteMetadata } from "../../api/admin/sites";
import { NoData } from "./components/NoData";
+import { TopBar } from "../../components/TopBar";
+import { Sidebar } from "./components/Sidebar/Sidebar";
export default function SiteLayout({
children,
@@ -41,9 +43,17 @@ export default function SiteLayout({
}
return (
- <>
- <Header />
- {children}
- </>
+ <div className="flex flex-col h-screen">
+ <TopBar />
+ <div className="flex flex-1 overflow-hidden">
+ <Sidebar />
+ <div className="flex-1 overflow-auto">
+ <div className="px-4 py-4 max-w-[1400px] mx-auto w-full">
+ <Header />
+ <div className="mt-6">{children}</div>
+ </div>
+ </div>
+ </div>
+ </div>
);
}
diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsx
index 4223a6d98..81358f84f 100644
--- a/client/src/app/layout.tsx
+++ b/client/src/app/layout.tsx
@@ -60,12 +60,7 @@ export default function RootLayout({
{children}
</div>
) : (
- <div className="min-h-full">
- <TopBar />
- <main className="flex min-h-screen flex-col items-center p-4">
- <div className="w-full max-w-6xl">{children}</div>
- </main>
- </div>
+ children
)}
</QueryProvider>
</TooltipProvider>
diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx
index 09579ec19..ee7065b5d 100644
--- a/client/src/app/page.tsx
+++ b/client/src/app/page.tsx
@@ -9,6 +9,7 @@ import { Card, CardDescription, CardTitle } from "../components/ui/card";
import { authClient } from "../lib/auth";
import { AddSite } from "./components/AddSite";
import { CreateOrganizationDialog } from "./components/CreateOrganizationDialog";
+import { StandardPage } from "../components/StandardPage";
export default function Home() {
const {
@@ -32,7 +33,7 @@ export default function Home() {
};
return (
- <div className="flex min-h-screen flex-col pt-1">
+ <StandardPage>
<div className="flex justify-between items-center mb-4">
<div className="text-2xl font-bold">Websites</div>
<AddSite disabled={hasNoOrganizations} />
@@ -100,6 +101,6 @@ export default function Home() {
onOpenChange={setCreateOrgDialogOpen}
onSuccess={handleOrganizationCreated}
/>
- </div>
+ </StandardPage>
);
}
diff --git a/client/src/app/settings/layout.tsx b/client/src/app/settings/layout.tsx
index bef7105e5..068b49942 100644
--- a/client/src/app/settings/layout.tsx
+++ b/client/src/app/settings/layout.tsx
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import { Button } from "../../components/ui/button";
import { CreditCard, User, Users } from "lucide-react";
import { usePathname, useRouter } from "next/navigation";
+import { StandardPage } from "../../components/StandardPage";
export default function SettingsLayout({
children,
@@ -24,43 +25,45 @@ export default function SettingsLayout({
}, [pathname]);
return (
- <div className="max-w-6xl grid grid-cols-[200px_1fr] gap-6">
- <div className="flex flex-col gap-2">
- <Button
- variant={selectedTab === "account" ? "default" : "ghost"}
- onClick={() => {
- setSelectedTab("account");
- router.push("/settings/account");
- }}
- className="justify-start"
- >
- <User size={16} />
- Account
- </Button>
- <Button
- variant={selectedTab === "organizations" ? "default" : "ghost"}
- onClick={() => {
- setSelectedTab("organizations");
- router.push("/settings/organizations");
- }}
- className="justify-start"
- >
- <Users size={16} />
- Organizations
- </Button>
- <Button
- variant={selectedTab === "subscription" ? "default" : "ghost"}
- onClick={() => {
- setSelectedTab("subscription");
- router.push("/settings/subscription");
- }}
- className="justify-start"
- >
- <CreditCard size={16} />
- Subscription
- </Button>
+ <StandardPage>
+ <div className=" grid grid-cols-[200px_1fr] gap-6">
+ <div className="flex flex-col gap-2">
+ <Button
+ variant={selectedTab === "account" ? "default" : "ghost"}
+ onClick={() => {
+ setSelectedTab("account");
+ router.push("/settings/account");
+ }}
+ className="justify-start"
+ >
+ <User size={16} />
+ Account
+ </Button>
+ <Button
+ variant={selectedTab === "organizations" ? "default" : "ghost"}
+ onClick={() => {
+ setSelectedTab("organizations");
+ router.push("/settings/organizations");
+ }}
+ className="justify-start"
+ >
+ <Users size={16} />
+ Organizations
+ </Button>
+ <Button
+ variant={selectedTab === "subscription" ? "default" : "ghost"}
+ onClick={() => {
+ setSelectedTab("subscription");
+ router.push("/settings/subscription");
+ }}
+ className="justify-start"
+ >
+ <CreditCard size={16} />
+ Subscription
+ </Button>
+ </div>
+ {children}
</div>
- {children}
- </div>
+ </StandardPage>
);
}
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index 71cd31f68..188aec089 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -17,6 +17,7 @@ import { STRIPE_PRICES } from "@/lib/stripe";
import { Slider } from "@/components/ui/slider";
import { Badge } from "@/components/ui/badge";
import { cn } from "@/lib/utils";
+import { StandardPage } from "../../components/StandardPage";
// Available event tiers for the slider
const EVENT_TIERS = [20_000, 100_000, 250_000, 500_000, 1_000_000, 2_000_000];
@@ -394,193 +395,195 @@ export default function Subscribe() {
});
return (
- <div className="container mx-auto py-12">
- <div className="mb-12 text-center max-w-3xl mx-auto">
- <h1 className="text-4xl font-bold tracking-tight mb-4 ">
- Choose Your Analytics Plan
- </h1>
- <p className="text-lg text-neutral-600 dark:text-neutral-400 mb-6">
- Find the perfect plan to track your site's performance
- </p>
-
- {/* Billing toggle buttons */}
- <div className="flex justify-center mb-8 mt-10">
- <div className="bg-neutral-100 dark:bg-neutral-800 p-1 rounded-full inline-flex relative">
- <button
- onClick={() => setIsAnnual(false)}
- className={cn(
- "px-6 py-2 rounded-full text-sm font-medium transition-all",
- !isAnnual
- ? "bg-white dark:bg-neutral-700 shadow-sm text-black dark:text-white"
- : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
- )}
- >
- Monthly
- </button>
- <div className="relative">
+ <StandardPage>
+ <div className="container mx-auto py-12">
+ <div className="mb-12 text-center max-w-3xl mx-auto">
+ <h1 className="text-4xl font-bold tracking-tight mb-4 ">
+ Choose Your Analytics Plan
+ </h1>
+ <p className="text-lg text-neutral-600 dark:text-neutral-400 mb-6">
+ Find the perfect plan to track your site's performance
+ </p>
+
+ {/* Billing toggle buttons */}
+ <div className="flex justify-center mb-8 mt-10">
+ <div className="bg-neutral-100 dark:bg-neutral-800 p-1 rounded-full inline-flex relative">
<button
- onClick={() => setIsAnnual(true)}
+ onClick={() => setIsAnnual(false)}
className={cn(
"px-6 py-2 rounded-full text-sm font-medium transition-all",
- isAnnual
+ !isAnnual
? "bg-white dark:bg-neutral-700 shadow-sm text-black dark:text-white"
: "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
)}
>
- Annual
+ Monthly
</button>
- <Badge className="absolute -top-2 -right-2 bg-emerald-500 text-white border-0 pointer-events-none">
- 2 months free
- </Badge>
+ <div className="relative">
+ <button
+ onClick={() => setIsAnnual(true)}
+ className={cn(
+ "px-6 py-2 rounded-full text-sm font-medium transition-all",
+ isAnnual
+ ? "bg-white dark:bg-neutral-700 shadow-sm text-black dark:text-white"
+ : "text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-200"
+ )}
+ >
+ Annual
+ </button>
+ <Badge className="absolute -top-2 -right-2 bg-emerald-500 text-white border-0 pointer-events-none">
+ 2 months free
+ </Badge>
+ </div>
</div>
</div>
</div>
- </div>
- <div className="mb-12 max-w-3xl mx-auto p-6 bg-white dark:bg-neutral-900 rounded-xl shadow-sm border border-neutral-100 dark:border-neutral-800">
- <div className="mb-6">
- <h2 className="text-xl font-medium mb-4">
- How many events do you need?
- </h2>
- <div className="flex justify-between mb-4">
- <span className="text-neutral-600 dark:text-neutral-400">
- Events per month
- </span>
- <span className="font-bold text-lg bg-clip-text text-transparent bg-gradient-to-r from-green-500 to-emerald-400">
- {eventLimit.toLocaleString()}
- </span>
+ <div className="mb-12 max-w-3xl mx-auto p-6 bg-white dark:bg-neutral-900 rounded-xl shadow-sm border border-neutral-100 dark:border-neutral-800">
+ <div className="mb-6">
+ <h2 className="text-xl font-medium mb-4">
+ How many events do you need?
+ </h2>
+ <div className="flex justify-between mb-4">
+ <span className="text-neutral-600 dark:text-neutral-400">
+ Events per month
+ </span>
+ <span className="font-bold text-lg bg-clip-text text-transparent bg-gradient-to-r from-green-500 to-emerald-400">
+ {eventLimit.toLocaleString()}
+ </span>
+ </div>
+ </div>
+
+ <Slider
+ defaultValue={[0]} // Default to index 0 (20k)
+ max={EVENT_TIERS.length - 1}
+ min={0}
+ step={1}
+ onValueChange={handleSliderChange}
+ className="mb-6"
+ />
+
+ <div className="flex justify-between text-xs text-neutral-500">
+ {EVENT_TIERS.map((tier, index) => (
+ <span
+ key={index}
+ className={
+ eventLimitIndex === index ? "font-bold text-emerald-400" : ""
+ }
+ >
+ {tier.toLocaleString()}
+ </span>
+ ))}
</div>
</div>
- <Slider
- defaultValue={[0]} // Default to index 0 (20k)
- max={EVENT_TIERS.length - 1}
- min={0}
- step={1}
- onValueChange={handleSliderChange}
- className="mb-6"
- />
-
- <div className="flex justify-between text-xs text-neutral-500">
- {EVENT_TIERS.map((tier, index) => (
- <span
- key={index}
- className={
- eventLimitIndex === index ? "font-bold text-emerald-400" : ""
- }
- >
- {tier.toLocaleString()}
- </span>
+ <div className="grid gap-8 md:grid-cols-4 max-w-6xl mx-auto">
+ {plans.map((plan) => (
+ <div key={plan.id} className="transition-all duration-300 h-full">
+ <Card
+ className={`flex flex-col h-full transition-transform duration-300 transform hover:scale-[1.01] hover:shadow-md cursor-pointer overflow-hidden ${
+ plan.id === "free" && !isFreeAvailable
+ ? "opacity-50 cursor-not-allowed"
+ : ""
+ }`}
+ >
+ <div className={`${plan.color} h-3 w-full`}></div>
+
+ <CardHeader className="pb-4">
+ <CardTitle className="text-xl">{plan.name}</CardTitle>
+ <CardDescription className="space-y-3">
+ <div className="flex items-baseline">
+ <span className="text-3xl font-bold text-neutral-900 dark:text-white">
+ {plan.price}
+ </span>
+ {plan.interval && (
+ <span className="ml-1 text-neutral-500">
+ /{plan.interval}
+ </span>
+ )}
+ </div>
+ {isAnnual &&
+ plan.id !== "free" &&
+ plan.id !== "enterprise" && (
+ <Badge className="bg-emerald-500 text-white border-0">
+ 2 months free
+ </Badge>
+ )}
+ <p>{plan.description}</p>
+ </CardDescription>
+ </CardHeader>
+
+ <CardContent className="pt-0 flex-grow">
+ <div className="w-full h-px bg-neutral-200 dark:bg-neutral-800 mb-4"></div>
+ <ul className="space-y-3 text-sm">
+ {plan.features.map((feature, i) => (
+ <li key={feature} className="flex items-start">
+ <Check
+ className={`mr-2 h-4 w-4 ${
+ i === 0 ? "text-emerald-400" : "text-green-400"
+ } shrink-0`}
+ />
+ <span>{feature}</span>
+ </li>
+ ))}
+ </ul>
+ </CardContent>
+
+ <CardFooter>
+ {plan.id === "basic" || plan.id === "pro" ? (
+ <Button
+ onClick={() => handleSubscribe(plan.id)}
+ className={`w-full ${
+ plan.id === "pro"
+ ? "bg-gradient-to-r from-green-500 to-emerald-400 hover:from-green-600 hover:to-emerald-500"
+ : ""
+ }`}
+ variant={plan.id === "pro" ? "default" : "outline"}
+ >
+ Subscribe to {plan.name}
+ </Button>
+ ) : plan.id === "enterprise" ? (
+ <Button
+ onClick={handleContactEnterprise}
+ className="w-full bg-gradient-to-r from-slate-500 to-blue-400 hover:from-slate-600 hover:to-blue-500"
+ >
+ Contact Sales
+ </Button>
+ ) : (
+ <Button
+ className="w-full border-neutral-300 text-gray-700 dark:border-neutral-700 dark:text-neutral-300"
+ variant="outline"
+ disabled={!isFreeAvailable}
+ >
+ {isFreeAvailable ? "Current Plan" : "Not Available"}
+ </Button>
+ )}
+ </CardFooter>
+ </Card>
+ </div>
))}
</div>
- </div>
- <div className="grid gap-8 md:grid-cols-4 max-w-6xl mx-auto">
- {plans.map((plan) => (
- <div key={plan.id} className="transition-all duration-300 h-full">
- <Card
- className={`flex flex-col h-full transition-transform duration-300 transform hover:scale-[1.01] hover:shadow-md cursor-pointer overflow-hidden ${
- plan.id === "free" && !isFreeAvailable
- ? "opacity-50 cursor-not-allowed"
- : ""
- }`}
- >
- <div className={`${plan.color} h-3 w-full`}></div>
-
- <CardHeader className="pb-4">
- <CardTitle className="text-xl">{plan.name}</CardTitle>
- <CardDescription className="space-y-3">
- <div className="flex items-baseline">
- <span className="text-3xl font-bold text-neutral-900 dark:text-white">
- {plan.price}
- </span>
- {plan.interval && (
- <span className="ml-1 text-neutral-500">
- /{plan.interval}
- </span>
- )}
- </div>
- {isAnnual &&
- plan.id !== "free" &&
- plan.id !== "enterprise" && (
- <Badge className="bg-emerald-500 text-white border-0">
- 2 months free
- </Badge>
- )}
- <p>{plan.description}</p>
- </CardDescription>
- </CardHeader>
-
- <CardContent className="pt-0 flex-grow">
- <div className="w-full h-px bg-neutral-200 dark:bg-neutral-800 mb-4"></div>
- <ul className="space-y-3 text-sm">
- {plan.features.map((feature, i) => (
- <li key={feature} className="flex items-start">
- <Check
- className={`mr-2 h-4 w-4 ${
- i === 0 ? "text-emerald-400" : "text-green-400"
- } shrink-0`}
- />
- <span>{feature}</span>
- </li>
- ))}
- </ul>
- </CardContent>
-
- <CardFooter>
- {plan.id === "basic" || plan.id === "pro" ? (
- <Button
- onClick={() => handleSubscribe(plan.id)}
- className={`w-full ${
- plan.id === "pro"
- ? "bg-gradient-to-r from-green-500 to-emerald-400 hover:from-green-600 hover:to-emerald-500"
- : ""
- }`}
- variant={plan.id === "pro" ? "default" : "outline"}
- >
- Subscribe to {plan.name}
- </Button>
- ) : plan.id === "enterprise" ? (
- <Button
- onClick={handleContactEnterprise}
- className="w-full bg-gradient-to-r from-slate-500 to-blue-400 hover:from-slate-600 hover:to-blue-500"
- >
- Contact Sales
- </Button>
- ) : (
- <Button
- className="w-full border-neutral-300 text-gray-700 dark:border-neutral-700 dark:text-neutral-300"
- variant="outline"
- disabled={!isFreeAvailable}
- >
- {isFreeAvailable ? "Current Plan" : "Not Available"}
- </Button>
- )}
- </CardFooter>
- </Card>
+ <div className="mt-16 text-center text-sm max-w-2xl mx-auto p-6 bg-white dark:bg-neutral-900 rounded-xl shadow-sm border border-neutral-100 dark:border-neutral-800">
+ <div className="flex items-center justify-center mb-4">
+ <Users className="h-5 w-5 text-emerald-400 mr-2" />
+ <span className="font-medium">Important Information</span>
</div>
- ))}
- </div>
-
- <div className="mt-16 text-center text-sm max-w-2xl mx-auto p-6 bg-white dark:bg-neutral-900 rounded-xl shadow-sm border border-neutral-100 dark:border-neutral-800">
- <div className="flex items-center justify-center mb-4">
- <Users className="h-5 w-5 text-emerald-400 mr-2" />
- <span className="font-medium">Important Information</span>
+ <p className="mb-3 text-neutral-600 dark:text-neutral-400">
+ All paid plans include a 14-day free trial. No credit card required
+ until your trial ends.
+ </p>
+ <p className="text-neutral-600 dark:text-neutral-400">
+ Have questions about our plans?{" "}
+ <a
+ href="/contact"
+ className="text-emerald-400 hover:underline font-medium"
+ >
+ Contact our sales team
+ </a>
+ </p>
</div>
- <p className="mb-3 text-neutral-600 dark:text-neutral-400">
- All paid plans include a 14-day free trial. No credit card required
- until your trial ends.
- </p>
- <p className="text-neutral-600 dark:text-neutral-400">
- Have questions about our plans?{" "}
- <a
- href="/contact"
- className="text-emerald-400 hover:underline font-medium"
- >
- Contact our sales team
- </a>
- </p>
</div>
- </div>
+ </StandardPage>
);
}
diff --git a/client/src/components/StandardPage.tsx b/client/src/components/StandardPage.tsx
new file mode 100644
index 000000000..b001b7e0b
--- /dev/null
+++ b/client/src/components/StandardPage.tsx
@@ -0,0 +1,12 @@
+import { TopBar } from "./TopBar";
+
+export function StandardPage({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="min-h-full">
+ <TopBar />
+ <main className="flex min-h-screen flex-col items-center p-4">
+ <div className="w-full max-w-6xl">{children}</div>
+ </main>
+ </div>
+ );
+}
diff --git a/client/src/components/TopBar.tsx b/client/src/components/TopBar.tsx
index 19c77fad0..72affad41 100644
--- a/client/src/components/TopBar.tsx
+++ b/client/src/components/TopBar.tsx
@@ -24,8 +24,8 @@ export function TopBar() {
const queryClient = useQueryClient();
return (
- <div className="flex pt-2 items-center w-full pb-4 bg-neutral-900 justify-center">
- <div className="flex items-center justify-between max-w-6xl flex-1">
+ <div className="flex pt-2 pb-4 px-3 items-center w-full bg-neutral-900 justify-center">
+ <div className="flex items-center justify-between flex-1">
<div className="flex items-center space-x-4">
<Link href="/" className="font-bold text-xl">
🐸 Frogstats