|
| 1 | +import {motion} from 'framer-motion'; |
| 2 | +import React, {useState} from 'react'; |
| 3 | + |
| 4 | +interface PricingData { |
| 5 | + name: string; |
| 6 | + calculatePrice: (emails: number) => number; |
| 7 | + color?: string; |
| 8 | +} |
| 9 | + |
| 10 | +interface PricingCalculatorProps { |
| 11 | + competitors: PricingData[]; |
| 12 | + defaultVolume?: number; |
| 13 | +} |
| 14 | + |
| 15 | +const volumeOptions = [ |
| 16 | + {label: '10K emails/month', value: 10000}, |
| 17 | + {label: '100K emails/month', value: 100000}, |
| 18 | + {label: '500K emails/month', value: 500000}, |
| 19 | + {label: '1M emails/month', value: 1000000}, |
| 20 | +]; |
| 21 | + |
| 22 | +/** |
| 23 | + * Interactive pricing calculator comparing Plunk with competitors |
| 24 | + */ |
| 25 | +export function PricingCalculator({competitors, defaultVolume = 100000}: PricingCalculatorProps) { |
| 26 | + const [volume, setVolume] = useState(defaultVolume); |
| 27 | + |
| 28 | + const plunkPrice = volume * 0.001; |
| 29 | + |
| 30 | + return ( |
| 31 | + <motion.div |
| 32 | + initial={{opacity: 0, y: 20}} |
| 33 | + whileInView={{opacity: 1, y: 0}} |
| 34 | + viewport={{once: true}} |
| 35 | + transition={{duration: 0.7, ease: [0.22, 1, 0.36, 1]}} |
| 36 | + className={'overflow-hidden rounded-xl border border-neutral-200 bg-white'} |
| 37 | + > |
| 38 | + {/* Header */} |
| 39 | + <div className={'border-b border-neutral-200 bg-neutral-50 p-8'}> |
| 40 | + <h3 className={'text-2xl font-bold text-neutral-900'}>Pricing Calculator</h3> |
| 41 | + <p className={'mt-2 text-sm text-neutral-600'}> |
| 42 | + Compare costs across platforms at different email volumes |
| 43 | + </p> |
| 44 | + </div> |
| 45 | + |
| 46 | + {/* Volume Selector */} |
| 47 | + <div className={'p-8'}> |
| 48 | + <label className={'block text-sm font-semibold text-neutral-900'}>Monthly Email Volume</label> |
| 49 | + <div className={'mt-4 grid grid-cols-2 gap-3 sm:grid-cols-4'}> |
| 50 | + {volumeOptions.map((option) => ( |
| 51 | + <button |
| 52 | + key={option.value} |
| 53 | + onClick={() => setVolume(option.value)} |
| 54 | + className={`rounded-lg border px-4 py-3 text-sm font-medium transition ${ |
| 55 | + volume === option.value |
| 56 | + ? 'border-neutral-900 bg-neutral-900 text-white' |
| 57 | + : 'border-neutral-300 bg-white text-neutral-900 hover:border-neutral-400' |
| 58 | + }`} |
| 59 | + > |
| 60 | + {option.label} |
| 61 | + </button> |
| 62 | + ))} |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + |
| 66 | + {/* Results */} |
| 67 | + <div className={'space-y-4 p-8 pt-0'}> |
| 68 | + {/* Plunk */} |
| 69 | + <div className={'rounded-lg border border-neutral-900 bg-neutral-50 p-6'}> |
| 70 | + <div className={'flex items-center justify-between'}> |
| 71 | + <div> |
| 72 | + <span className={'text-lg font-bold text-neutral-900'}>Plunk</span> |
| 73 | + <span className={'ml-3 rounded-full bg-neutral-900 px-3 py-1 text-xs font-medium text-white'}> |
| 74 | + Cheapest |
| 75 | + </span> |
| 76 | + </div> |
| 77 | + <div className={'text-right'}> |
| 78 | + <div className={'text-3xl font-bold text-neutral-900'}>${plunkPrice.toFixed(2)}</div> |
| 79 | + <div className={'text-sm text-neutral-600'}>per month</div> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + |
| 84 | + {/* Competitors */} |
| 85 | + {competitors.map((competitor, index) => { |
| 86 | + const price = competitor.calculatePrice(volume); |
| 87 | + const savings = ((price - plunkPrice) / price) * 100; |
| 88 | + |
| 89 | + return ( |
| 90 | + <div key={competitor.name} className={'rounded-lg border border-neutral-200 bg-white p-6'}> |
| 91 | + <div className={'flex items-center justify-between'}> |
| 92 | + <div> |
| 93 | + <span className={'text-lg font-semibold text-neutral-900'}>{competitor.name}</span> |
| 94 | + </div> |
| 95 | + <div className={'text-right'}> |
| 96 | + <div className={'text-3xl font-bold text-neutral-900'}>${price.toFixed(2)}</div> |
| 97 | + <div className={'text-sm text-neutral-600'}>per month</div> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + {savings > 0 && ( |
| 101 | + <div className={'mt-3 text-sm text-neutral-600'}> |
| 102 | + Save <span className={'font-semibold text-neutral-900'}>{savings.toFixed(0)}%</span> with Plunk |
| 103 | + </div> |
| 104 | + )} |
| 105 | + </div> |
| 106 | + ); |
| 107 | + })} |
| 108 | + </div> |
| 109 | + </motion.div> |
| 110 | + ); |
| 111 | +} |
0 commit comments