Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): redesign ComparePlans comparison table
Richie McIlroyd5253fde94d0
diff --git a/apps/web/components/pages/_components/ComparePlans.tsx b/apps/web/components/pages/_components/ComparePlans.tsxindex cb27a1852..9aee523d4 100644--- a/apps/web/components/pages/_components/ComparePlans.tsx+++ b/apps/web/components/pages/_components/ComparePlans.tsx@@ -1,160 +1,71 @@"use client";import { Button } from "@cap/ui";-import { faCheckCircle } from "@fortawesome/free-solid-svg-icons";+import { classNames } from "@cap/utils";+import { faCheck } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { clsx } from "clsx";-import { useMemo, useRef, useState } from "react";+import { Fragment, useMemo, useState } from "react";import { toast } from "sonner";import { useCurrentUser } from "@/app/Layout/AuthContext";import { useStripeContext } from "@/app/Layout/StripeContext";import { trackEvent } from "@/app/utils/analytics";-import {- CommercialArt,- type CommercialArtRef,-} from "../HomePage/Pricing/CommercialArt";-import { ProArt, type ProArtRef } from "../HomePage/Pricing/ProArt";-const COLUMN_WIDTH = "min-w-[200px]";+type PlanKey = "free" | "desktop" | "pro";type Plan = {+ key: PlanKey;name: string;+ short: string;price: string;href?: string;- disabled?: boolean;};-const getButtonText = (planName: string): string => {- switch (planName) {- case "Free":- return "Download for free";- case "Desktop License":- return "Get Desktop License";- case "Cap Pro":- return "Get started";- default:- return "Get started";- }-};+type FeatureValue = boolean | string;-const getButtonVariant = (planName: string) => {- switch (planName) {- case "Free":- return "gray";- case "Desktop License":- return "dark";- case "Cap Pro":- return "blue";- default:- return "gray";- }+type FeatureRow = {+ label: string;+ free: FeatureValue;+ desktop: FeatureValue;+ pro: FeatureValue;};-// Icon component renderer-const PlanIcon = ({- planName,- commercialArtRef,- proArtRef,-}: {- planName: string;- commercialArtRef: React.RefObject<CommercialArtRef | null>;- proArtRef: React.RefObject<ProArtRef | null>;-}) => {- if (planName === "Desktop License") {- return (- <div- onMouseEnter={() => commercialArtRef.current?.playHoverAnimation()}- onMouseLeave={() => commercialArtRef.current?.playDefaultAnimation()}- className="w-[90px] h-[80px]"- >- <CommercialArt className="w-[80px] h-[80px]" ref={commercialArtRef} />- </div>- );- }-- if (planName === "Cap Pro") {- return (- <div- onMouseEnter={() => proArtRef.current?.playHoverAnimation()}- onMouseLeave={() => proArtRef.current?.playDefaultAnimation()}- className="w-[90px] ml-2 h-[80px]"- >- <ProArt ref={proArtRef} className="w-16 h-[98px]" />- </div>- );- }-- return null;+type FeatureSection = {+ title: string;+ rows: FeatureRow[];};-export const ComparePlans = () => {- const commercialArtRef = useRef<CommercialArtRef>(null);- const proArtRef = useRef<ProArtRef>(null);- const user = useCurrentUser();- const [proLoading, setProLoading] = useState(false);- const [guestLoading, setGuestLoading] = useState(false);- const [commercialLoading, setCommercialLoading] = useState(false);- const stripeCtx = useStripeContext();-- // Check if user is already pro or any loading state is active- const isDisabled = useMemo(- () =>- (user?.email && user.isPro) ||- proLoading ||- guestLoading ||- commercialLoading,- [user, proLoading, guestLoading, commercialLoading],- );-- const plans: Plan[] = useMemo(- () => [- {- name: "Free",- price: "$0 forever",- href: "/login",- disabled: isDisabled,- },- {- name: "Desktop License",- price: "$58 /lifetime or $29 /year",- disabled: isDisabled,- },- {- name: "Cap Pro",- price:- "$8.16 /mo per user, billed annually or $12 /mo per user, billed monthly",- disabled: isDisabled,- },- ],- [isDisabled],- );- // Feature comparison data- const rows = useMemo(- () => [- { label: "Unlimited recordings", free: false, desktop: true, pro: true },- { label: "Commercial usage", free: false, desktop: true, pro: true },+const sections: FeatureSection[] = [+ {+ title: "Recording & editing",+ rows: [{label: "Studio Mode with full editor",free: true,desktop: true,pro: true,},- { label: "Export to any format", free: true, desktop: true, pro: true },- { label: "4K export", free: true, desktop: true, pro: true },{- label: "Cloud storage & bandwidth",+ label: "Unlimited local recordings & editing",free: false,- desktop: false,- pro: "Unlimited",+ desktop: true,+ pro: true,},+ { label: "4K / 60fps export", free: true, desktop: true, pro: true },+ { label: "Export to any format", free: true, desktop: true, pro: true },+ { label: "Commercial usage", free: false, desktop: true, pro: true },+ ],+ },+ {+ title: "Cloud & sharing",+ rows: [{- label: "Auto-generated titles & summaries",- free: false,- desktop: false,- pro: true,+ label: "Shareable links",+ free: "Up to 5 min",+ desktop: "Up to 5 min",+ pro: "Unlimited",},{- label: "Clickable chapters & transcriptions",+ label: "Unlimited cloud storage & bandwidth",free: false,desktop: false,pro: true,@@ -172,46 +83,114 @@ export const ComparePlans = () => {pro: true,},{- label: "Viewer analytics & engagement",+ label: "Custom S3 bucket support",free: false,desktop: false,pro: true,},- { label: "Team workspaces", free: true, desktop: true, pro: true },+ { label: "Loom video importer", free: false, desktop: false, pro: true },+ ],+ },+ {+ title: "AI & collaboration",+ rows: [{- label: "Loom video importer",+ label: "Auto titles, summaries & chapters",free: false,desktop: false,pro: true,},+ { label: "Transcriptions", free: false, desktop: false, pro: true },{- label: "Custom S3 bucket support",+ label: "Viewer analytics & engagement",free: false,desktop: false,pro: true,},- { label: "Priority support", free: false, desktop: false, pro: true },+ { label: "Team workspaces", free: true, desktop: true, pro: true },+ ],+ },+ {+ title: "Support & licensing",+ rows: [+ { label: "Community support", free: true, desktop: true, pro: true },{- label: "Early features access",+ label: "Priority support & early features",free: false,desktop: false,pro: true,},- { label: "Community support", free: true, desktop: true, pro: true },{- label: "License type",- free: "Free",- desktop: "Perpetual (single device)",+ label: "License",+ free: "Personal use",+ desktop: "Perpetual",pro: "Subscription",},],+ },+];++const getButtonVariant = (key: PlanKey) => {+ switch (key) {+ case "pro":+ return "blue" as const;+ default:+ return "outline" as const;+ }+};++const getButtonText = (key: PlanKey): string => {+ switch (key) {+ case "free":+ return "Download";+ case "desktop":+ return "Get license";+ default:+ return "Get started";+ }+};++export const ComparePlans = () => {+ const user = useCurrentUser();+ const [proLoading, setProLoading] = useState(false);+ const [guestLoading, setGuestLoading] = useState(false);+ const [commercialLoading, setCommercialLoading] = useState(false);+ const stripeCtx = useStripeContext();++ const isDisabled = useMemo(+ () =>+ Boolean(+ (user?.email && user.isPro) ||+ proLoading ||+ guestLoading ||+ commercialLoading,+ ),+ [user, proLoading, guestLoading, commercialLoading],+ );++ const plans: Plan[] = useMemo(+ () => [+ {+ key: "free",+ name: "Free",+ short: "Free",+ price: "Free forever",+ href: "/download",+ },+ {+ key: "desktop",+ name: "Desktop License",+ short: "Desktop",+ price: "$29/yr",+ },+ { key: "pro", name: "Cap Pro", short: "Pro", price: "$8.16/user/mo" },+ ],[],);- // Generic checkout handler with error handlingconst handleCheckout = async (url: string,- body: Record<string, any>,+ body: Record<string, unknown>,setLoading: (loading: boolean) => void,errorMessage: string,) => {@@ -268,7 +247,6 @@ export const ComparePlans = () => {const data = await response.json();if (data.auth === false) {- // User not authenticated, do guest checkoutsetProLoading(false);await guestCheckout(finalPlanId);return;@@ -290,145 +268,210 @@ export const ComparePlans = () => {}};- const renderCell = (value: boolean | string) => {+ const handlePlanClick = (key: PlanKey) => {+ trackEvent("pricing_cta_clicked", {+ source_page: "pricing_compare",+ plan_name: key,+ authenticated: Boolean(user?.email),+ is_pro: Boolean(user?.isPro),+ cta_action:+ key === "free"+ ? "download"+ : key === "desktop"+ ? "commercial_checkout"+ : user?.email+ ? "checkout"+ : "guest_checkout",+ target_billing_period: key === "pro" ? "monthly" : null,+ });++ if (key === "free") {+ window.location.href = "/download";+ } else if (key === "desktop") {+ openCommercialCheckout();+ } else {+ planCheckout();+ }+ };++ const renderCell = (value: FeatureValue) => {if (typeof value === "boolean") {return value ? (- <FontAwesomeIcon- className="text-emerald-500 size-4"- icon={faCheckCircle}- />+ <>+ <FontAwesomeIcon+ className="text-blue-500 size-3.5"+ icon={faCheck}+ aria-hidden="true"+ />+ <span className="sr-only">Included</span>+ </>) : (- <span className="text-gray-8">—</span>+ <>+ <span className="text-gray-8" aria-hidden="true">+ —+ </span>+ <span className="sr-only">Not included</span>+ </>);}- return <span className="text-gray-12">{value}</span>;+ return <span className="text-sm text-gray-12">{value}</span>;};+return (- <div className="mx-auto w-full max-w-[1400px]">- <h2 className="mb-6 text-4xl text-center text-gray-12">Compare plans</h2>- <div className="overflow-x-auto w-full">- <div className="overflow-hidden rounded-xl border min-w-fit border-gray-5">- <table className="w-full text-left border-separate border-spacing-0 bg-gray-2">+ <div className="mx-auto w-full max-w-[960px]">+ <h2 className="mb-3 text-3xl font-medium tracking-tight text-center md:text-4xl text-gray-12">+ Compare plans+ </h2>+ <p className="mx-auto mb-12 max-w-md text-center text-gray-10">+ Everything you get with Free, Desktop License, and Cap Pro.+ </p>++ <div className="hidden p-4 rounded-2xl border shadow-sm md:block bg-gray-1 border-gray-5">+ <div className="overflow-x-auto">+ <table className="w-full border-separate table-fixed border-spacing-0 min-w-[640px]"><thead>- <tr className="bg-gray-1">- <th- className={clsx(- "px-4 text-sm font-medium text-gray-12",- COLUMN_WIDTH,- )}- />- {plans.map((plan) => (- <th- key={plan.name}- className={clsx(- "px-4 py-6 text-sm font-semibold text-gray-12",- COLUMN_WIDTH,- )}- >- <div className="flex flex-1 gap-2">- <div className="flex-shrink-0">- <PlanIcon- planName={plan.name}- commercialArtRef={commercialArtRef}- proArtRef={proArtRef}- />- </div>- <div className="flex flex-col flex-1 justify-center text-black">- <p className="text-sm font-semibold text-gray-12">- {plan.name}- </p>- <p className="mt-1 text-[15px] w-full min-w-[250px] max-w-[250px] font-medium text-gray-10">- {plan.price}- </p>- </div>- </div>- </th>- ))}- </tr>- <tr className="bg-gray-1">- <th- className={clsx(- "px-4 pb-4 text-xs font-medium text-transparent border-b border-gray-5",- COLUMN_WIDTH,- )}- >- .- </th>- {plans.map((plan) => (- <th- key={`${plan.name}-cta`}- className={clsx(- "px-4 pb-6 border-b border-gray-5",- COLUMN_WIDTH,- )}- >- <div className="space-y-2">+ <tr className="align-bottom">+ <th className="px-5 pb-6 w-[40%] border-b border-gray-3" />+ {plans.map((plan) => {+ const isPro = plan.key === "pro";+ return (+ <th+ key={plan.key}+ className={classNames(+ "px-3 pt-6 pb-6 w-[20%] font-normal text-center align-bottom",+ isPro+ ? "border-t-2 border-x-2 rounded-t-2xl border-blue-500"+ : "border-b border-gray-3",+ )}+ >+ <p className="text-base font-semibold text-gray-12">+ {plan.name}+ </p>+ <p className="mt-1 mb-4 text-sm text-gray-10">+ {plan.price}+ </p><Button- disabled={plan.disabled}- href={plan.name === "Free" ? plan.href : undefined}- className="w-fit"- onClick={() => {- trackEvent("pricing_cta_clicked", {- source_page: "pricing_compare",- plan_name: plan.name,- authenticated: Boolean(user?.email),- is_pro: Boolean(user?.isPro),- cta_action:- plan.name === "Free"- ? "download"- : plan.name === "Desktop License"- ? "commercial_checkout"- : user?.email- ? "checkout"- : "guest_checkout",- target_billing_period:- plan.name === "Cap Pro" ? "monthly" : null,- });- if (plan.name === "Free") {- window.location.href = "/download";- }- if (plan.name === "Desktop License") {- openCommercialCheckout();- } else {- planCheckout();- }- }}+ disabled={isDisabled}+ onClick={() => handlePlanClick(plan.key)}size="sm"- variant={getButtonVariant(plan.name)}+ variant={getButtonVariant(plan.key)}+ className="w-full">- {getButtonText(plan.name)}+ {getButtonText(plan.key)}</Button>- </div>- </th>- ))}+ </th>+ );+ })}</tr></thead>- <tbody className="[&>tr+tr>td]:border-t [&>tr+tr>td]:border-gray-5">- {rows.map((row) => (- <tr key={row.label} className="bg-gray-2">- <td- className={clsx(- "p-5 text-sm font-medium text-nowrap text-gray-11",- COLUMN_WIDTH,- )}- >- {row.label}- </td>- <td className={clsx("px-4 py-3 text-sm", COLUMN_WIDTH)}>- {renderCell(row.free)}- </td>- <td className={clsx("px-4 py-3 text-sm", COLUMN_WIDTH)}>- {renderCell(row.desktop)}- </td>- <td className={clsx("px-4 py-3 text-sm", COLUMN_WIDTH)}>- {renderCell(row.pro)}- </td>- </tr>+ <tbody>+ {sections.map((section) => (+ <Fragment key={section.title}>+ <tr>+ <td className="px-5 pt-8 pb-3 text-sm font-semibold text-gray-12">+ {section.title}+ </td>+ <td className="pt-8 pb-3" />+ <td className="pt-8 pb-3" />+ <td className="px-3 pt-8 pb-3 border-x-2 border-blue-500" />+ </tr>+ {section.rows.map((row) => (+ <tr key={row.label}>+ <td className="px-5 py-3.5 text-sm border-t border-gray-3 text-gray-11">+ {row.label}+ </td>+ <td className="px-3 py-3.5 text-center border-t border-gray-3">+ {renderCell(row.free)}+ </td>+ <td className="px-3 py-3.5 text-center border-t border-gray-3">+ {renderCell(row.desktop)}+ </td>+ <td className="px-3 py-3.5 text-center border-t border-x-2 border-blue-500 border-t-blue-500/10">+ {renderCell(row.pro)}+ </td>+ </tr>+ ))}+ </Fragment>))}+ <tr>+ <td />+ <td />+ <td />+ <td className="h-4 border-b-2 border-x-2 rounded-b-2xl border-blue-500" />+ </tr></tbody></table></div></div>++ <div className="space-y-8 md:hidden">+ <div className="grid grid-cols-3 gap-2">+ {plans.map((plan) => {+ const isPro = plan.key === "pro";+ return (+ <div+ key={plan.key}+ className={classNames(+ "flex flex-col p-3 text-center rounded-xl bg-gray-1",+ isPro ? "ring-2 ring-blue-500" : "border border-gray-5",+ )}+ >+ <p className="text-sm font-semibold text-gray-12">+ {plan.short}+ </p>+ <p className="mt-0.5 mb-3 text-[11px] text-gray-10">+ {plan.price}+ </p>+ <Button+ disabled={isDisabled}+ onClick={() => handlePlanClick(plan.key)}+ size="xs"+ variant={getButtonVariant(plan.key)}+ className="px-2 mt-auto w-full text-xs"+ >+ {getButtonText(plan.key)}+ </Button>+ </div>+ );+ })}+ </div>++ {sections.map((section) => (+ <div key={section.title}>+ <p className="mb-3 text-sm font-medium text-gray-12">+ {section.title}+ </p>+ <div className="space-y-3">+ {section.rows.map((row) => (+ <div key={row.label}>+ <p className="mb-1.5 text-sm text-gray-11">{row.label}</p>+ <div className="grid grid-cols-3 gap-2">+ {plans.map((plan) => {+ const isPro = plan.key === "pro";+ return (+ <div+ key={plan.key}+ className={classNames(+ "flex flex-col gap-1 justify-center items-center px-1.5 py-2 text-center rounded-lg min-h-[52px]",+ isPro ? "bg-blue-2" : "bg-gray-2",+ )}+ >+ <span className="text-[10px] font-medium tracking-wide uppercase text-gray-9">+ {plan.short}+ </span>+ <span className="flex justify-center items-center text-sm">+ {renderCell(row[plan.key])}+ </span>+ </div>+ );+ })}+ </div>+ </div>+ ))}+ </div>+ </div>+ ))}+ </div></div>);};