|
| 1 | +import { faCheck, faPlus, Icon, type IconProp } from "@rivet-gg/icons"; |
| 2 | +import type { ReactNode } from "react"; |
| 3 | +import { Button, cn } from "@/components"; |
| 4 | + |
| 5 | +type PlanCardProps = { |
| 6 | + title: string; |
| 7 | + price: string; |
| 8 | + features: { icon: IconProp; label: ReactNode }[]; |
| 9 | + usageBased?: boolean; |
| 10 | + custom?: boolean; |
| 11 | + current?: boolean; |
| 12 | + buttonProps?: React.ComponentProps<typeof Button>; |
| 13 | +} & React.ComponentProps<"div">; |
| 14 | + |
| 15 | +function PlanCard({ |
| 16 | + title, |
| 17 | + price, |
| 18 | + features, |
| 19 | + usageBased, |
| 20 | + current, |
| 21 | + custom, |
| 22 | + className, |
| 23 | + buttonProps, |
| 24 | + ...props |
| 25 | +}: PlanCardProps) { |
| 26 | + return ( |
| 27 | + <div |
| 28 | + className={cn( |
| 29 | + "border rounded-lg p-6 h-full flex flex-col hover:bg-secondary/20 transition-colors", |
| 30 | + current && "border-primary", |
| 31 | + className, |
| 32 | + )} |
| 33 | + {...props} |
| 34 | + > |
| 35 | + <h3 className="text-lg font-medium mb-2">{title}</h3> |
| 36 | + <div className="min-h-20"> |
| 37 | + <p className=""> |
| 38 | + <span className="text-4xl font-bold">{price}</span> |
| 39 | + {custom ? null : ( |
| 40 | + <span className="text-muted-foreground ml-1">/mo</span> |
| 41 | + )} |
| 42 | + </p> |
| 43 | + {usageBased ? ( |
| 44 | + <p className="text-xs text-muted-foreground">+ Usage</p> |
| 45 | + ) : null} |
| 46 | + </div> |
| 47 | + <div className="text-sm text-primary-foreground border-t pt-2 flex-1"> |
| 48 | + <p>Includes:</p> |
| 49 | + <ul className="text-muted-foreground mt-2 space-y-1"> |
| 50 | + {features?.map((feature, index) => ( |
| 51 | + <li key={feature.label}> |
| 52 | + <Icon icon={feature.icon} /> {feature.label} |
| 53 | + </li> |
| 54 | + ))} |
| 55 | + </ul> |
| 56 | + </div> |
| 57 | + {current ? ( |
| 58 | + <Button |
| 59 | + variant="secondary" |
| 60 | + className="w-full mt-4" |
| 61 | + {...buttonProps} |
| 62 | + > |
| 63 | + Current Plan |
| 64 | + </Button> |
| 65 | + ) : ( |
| 66 | + <Button className="w-full mt-4" {...buttonProps}> |
| 67 | + {custom ? "Contact Us" : "Upgrade"} |
| 68 | + </Button> |
| 69 | + )} |
| 70 | + </div> |
| 71 | + ); |
| 72 | +} |
| 73 | + |
| 74 | +export const CommunityPlan = (props: Partial<PlanCardProps>) => { |
| 75 | + return ( |
| 76 | + <PlanCard |
| 77 | + title="Community" |
| 78 | + price="$0" |
| 79 | + features={[ |
| 80 | + { icon: faPlus, label: "$5 Free credits" }, |
| 81 | + { icon: faCheck, label: "Community Support" }, |
| 82 | + ]} |
| 83 | + {...props} |
| 84 | + /> |
| 85 | + ); |
| 86 | +}; |
| 87 | + |
| 88 | +export const ProPlan = (props: Partial<PlanCardProps>) => { |
| 89 | + return ( |
| 90 | + <PlanCard |
| 91 | + title="Pro" |
| 92 | + price="$20" |
| 93 | + usageBased |
| 94 | + features={[ |
| 95 | + { icon: faPlus, label: "$20 Free credits" }, |
| 96 | + { icon: faCheck, label: "Everything in Community" }, |
| 97 | + { icon: faCheck, label: "No Usage Limits" }, |
| 98 | + { icon: faCheck, label: "Unlimited Seats" }, |
| 99 | + { icon: faCheck, label: "Email Support" }, |
| 100 | + ]} |
| 101 | + {...props} |
| 102 | + /> |
| 103 | + ); |
| 104 | +}; |
| 105 | + |
| 106 | +export const TeamPlan = (props: Partial<PlanCardProps>) => { |
| 107 | + return ( |
| 108 | + <PlanCard |
| 109 | + title="Team" |
| 110 | + price="$200" |
| 111 | + usageBased |
| 112 | + features={[ |
| 113 | + { icon: faPlus, label: "$200 Free credits" }, |
| 114 | + { icon: faCheck, label: "Everything in Pro" }, |
| 115 | + { icon: faCheck, label: "Dedicated Hardware" }, |
| 116 | + { icon: faCheck, label: "Custom Regions" }, |
| 117 | + { icon: faCheck, label: "Slack Support" }, |
| 118 | + ]} |
| 119 | + {...props} |
| 120 | + /> |
| 121 | + ); |
| 122 | +}; |
| 123 | + |
| 124 | +export const EnterprisePlan = (props: Partial<PlanCardProps>) => { |
| 125 | + return ( |
| 126 | + <PlanCard |
| 127 | + title="Enterprise" |
| 128 | + price="Custom" |
| 129 | + custom |
| 130 | + features={[ |
| 131 | + { icon: faPlus, label: "Everything in Team" }, |
| 132 | + { icon: faCheck, label: "Priority Support" }, |
| 133 | + { icon: faCheck, label: "SLA" }, |
| 134 | + { icon: faCheck, label: "OIDC SSO provider" }, |
| 135 | + { icon: faCheck, label: "ON-Prem Deployment" }, |
| 136 | + { |
| 137 | + icon: faCheck, |
| 138 | + label: "Custom Storage Reads, Writes and Stored Data", |
| 139 | + }, |
| 140 | + { icon: faCheck, label: "Custom Log Retention" }, |
| 141 | + ]} |
| 142 | + {...props} |
| 143 | + /> |
| 144 | + ); |
| 145 | +}; |
0 commit comments