Skip to content

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

Refactor subscription page and pricing card components for improved readability and maintainability

Bill Yangea848d019b3f
diff --git a/client/src/app/subscribe/components/FeaturesList.tsx b/client/src/app/subscribe/components/FeaturesList.tsx
new file mode 100644
index 000000000..8a769dae5
--- /dev/null
+++ b/client/src/app/subscribe/components/FeaturesList.tsx
@@ -0,0 +1,44 @@
+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
index 62d9bd1a2..ed8c62b24 100644
--- a/client/src/app/subscribe/components/PricingCard.tsx
+++ b/client/src/app/subscribe/components/PricingCard.tsx
@@ -1,5 +1,4 @@
import React, { useState } from "react";
-import { Check } from "lucide-react";
import { Slider } from "@/components/ui/slider";
import { cn } from "@/lib/utils";
import { toast } from "sonner";
@@ -16,6 +15,7 @@ import {
} from "./utils";
import { trackAdEvent } from "../../../lib/trackAdEvent";
import { DEFAULT_EVENT_LIMIT } from "../../../lib/subscription/constants";
+import { FeaturesList } from "./FeaturesList";
export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
const [eventLimitIndex, setEventLimitIndex] = useState<number>(0);
@@ -194,14 +194,7 @@ export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
</button>
{/* Features */}
- <div className="space-y-3 mt-6">
- {FREE_FEATURES.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>
- ))}
- </div>
+ <FeaturesList features={FREE_FEATURES} />
</div>
</div>
@@ -239,14 +232,7 @@ export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
</button>
{/* Features */}
- <div className="space-y-3 mt-6">
- {STANDARD_FEATURES.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>
- ))}
- </div>
+ <FeaturesList features={STANDARD_FEATURES} />
</div>
</div>
@@ -289,14 +275,7 @@ export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
</button>
{/* Features */}
- <div className="space-y-3 mt-6">
- {PRO_FEATURES.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>
- ))}
- </div>
+ <FeaturesList features={PRO_FEATURES} />
</div>
</div>
@@ -323,14 +302,7 @@ export function PricingCard({ isLoggedIn }: { isLoggedIn: boolean }) {
</a>
{/* Features */}
- <div className="space-y-3 mt-6">
- {ENTERPRISE_FEATURES.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>
- ))}
- </div>
+ <FeaturesList features={ENTERPRISE_FEATURES} />
</div>
</div>
</div>
diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsx
index 661a9f8aa..bf9a614c2 100644
--- a/client/src/app/subscribe/page.tsx
+++ b/client/src/app/subscribe/page.tsx
@@ -17,9 +17,9 @@ export default function Subscribe() {
const router = useRouter();
// Redirect if already subscribed
- if (subscription?.status === "active") {
- router.push("/settings/organization/subscription");
- }
+ // if (subscription?.status === "active") {
+ // router.push("/settings/organization/subscription");
+ // }
// Get the active organization ID
const organizationId = activeOrg?.id;
diff --git a/docs/src/app/(home)/page.tsx b/docs/src/app/(home)/page.tsx
index 013300ca4..f9db9cee7 100644
--- a/docs/src/app/(home)/page.tsx
+++ b/docs/src/app/(home)/page.tsx
@@ -364,7 +364,7 @@ export default function HomePage() {
<TweetCard id="1920899082253434950" className="break-inside-avoid mb-4" />
<TweetCard id="1982378431166963982" className="break-inside-avoid mb-4" />
<TweetCard id="1927817460993884321" className="break-inside-avoid mb-4" />
- <TweetCard id="1971933281324355679" className="break-inside-avoid mb-4" />
+ {/* <TweetCard id="1971933281324355679" className="break-inside-avoid mb-4" /> */}
</div>
</div>
</section>
diff --git a/docs/src/app/layout.tsx b/docs/src/app/layout.tsx
index ae0f064e2..8ea29f0ac 100644
--- a/docs/src/app/layout.tsx
+++ b/docs/src/app/layout.tsx
@@ -77,66 +77,6 @@ const isDev = process.env.NODE_ENV === "development";
export default function Layout({ children }: { children: ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
- <head>
- <Script type="text/javascript" id="mixpanel" strategy="afterInteractive">
- {`(function (e, c) {
- if (!c.__SV) {
- var l, h;
- window.mixpanel = c;
- c._i = [];
- c.init = function (q, r, f) {
- function t(d, a) {
- var g = a.split(".");
- 2 == g.length && (d = d[g[0]], a = g[1]);
- d[a] = function () {
- d.push([a].concat(Array.prototype.slice.call(arguments, 0)))
- }
- }
-
- var b = c;
- "undefined" !== typeof f ? b = c[f] = [] : f = "mixpanel";
- b.people = b.people || [];
- b.toString = function (d) {
- var a = "mixpanel";
- "mixpanel" !== f && (a += "." + f);
- d || (a += " (stub)");
- return a
- };
- b.people.toString = function () {
- return b.toString(1) + ".people (stub)"
- };
- l = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" ");
- for (h = 0; h < l.length; h++) t(b, l[h]);
- var n = "set set_once union unset remove delete".split(" ");
- b.get_group = function () {
- function d(p) {
- a[p] = function () {
- b.push([g, [p].concat(Array.prototype.slice.call(arguments, 0))])
- }
- }
-
- for (var a = {}, g = ["get_group"].concat(Array.prototype.slice.call(arguments, 0)), m = 0; m < n.length; m++) d(n[m]);
- return a
- };
- c._i.push([q, r, f])
- };
- c.__SV = 1.2;
- var k = e.createElement("script");
- k.type = "text/javascript";
- k.async = !0;
- k.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "file:" ===
- e.location.protocol && "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//) ? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js" : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
- e = e.getElementsByTagName("script")[0];
- e.parentNode.insertBefore(k, e)
- }
- })(document, window.mixpanel || [])
-
- mixpanel.init('5409b6daffa187942af0f05518c2a4eb', {
- autocapture: true,
- record_sessions_percent: 0,
- })`}
- </Script>
- </head>
<Script
src="https://demo.rybbit.com/api/script.js"
data-site-id="21"
diff --git a/docs/src/components/GitHubStarButton.tsx b/docs/src/components/GitHubStarButton.tsx
index 0a5f4e1e4..4eb20ba76 100644
--- a/docs/src/components/GitHubStarButton.tsx
+++ b/docs/src/components/GitHubStarButton.tsx
@@ -12,7 +12,7 @@ export function GitHubStarButton() {
const { systemTheme, resolvedTheme } = useTheme();
useEffect(() => {
- if (systemTheme && resolvedTheme) {
+ if (systemTheme && resolvedTheme && window?.rybbit?.event) {
window.rybbit.event("theme", {
resolvedTheme,
systemTheme,
diff --git a/docs/src/components/PricingCard.tsx b/docs/src/components/PricingCard.tsx
index 040f4b2d1..41b063e1f 100644
--- a/docs/src/components/PricingCard.tsx
+++ b/docs/src/components/PricingCard.tsx
@@ -1,7 +1,8 @@
-import { Check, X, CheckCircle } from "lucide-react";
+import { Check, X, CheckCircle, ArrowDown, ArrowUp } from "lucide-react";
import Link from "next/link";
import { cn } from "@/lib/utils";
import { trackAdEvent } from "@/lib/trackAdEvent";
+import { useState } from "react";
interface PricingCardProps {
title: string;
@@ -34,9 +35,13 @@ export function PricingCard({
customButton,
recommended = false,
}: 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
@@ -91,7 +96,7 @@ export function PricingCard({
)}
<div className={cn("my-6", "space-y-3")}>
- {features.map((item, i) => {
+ {displayedFeatures.map((item, i) => {
const isObject = typeof item === "object";
const feature = isObject ? item.feature : item;
const included = isObject ? item.included : true;
@@ -107,6 +112,25 @@ export function PricingCard({
</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 && (