You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import cn from 'classnames'
  6. import { GoldCoin } from '../../base/icons/src/vender/solid/FinanceAndECommerce'
  7. import { Sparkles } from '../../base/icons/src/public/billing'
  8. import s from './style.module.css'
  9. import { useModalContext } from '@/context/modal-context'
  10. type Props = {
  11. className?: string
  12. isFull?: boolean
  13. size?: 'md' | 'lg'
  14. isPlain?: boolean
  15. isShort?: boolean
  16. onClick?: () => void
  17. }
  18. const PlainBtn = ({ className, onClick }: { className?: string; onClick: () => {} }) => {
  19. const { t } = useTranslation()
  20. return (
  21. <div
  22. className={cn(className, 'flex items-center h-8 px-3 rounded-lg border border-gray-200 bg-white shadow-sm cursor-pointer')}
  23. onClick={onClick}
  24. >
  25. <div className='leading-[18px] text-[13px] font-medium text-gray-700'>
  26. {t('billing.upgradeBtn.plain')}
  27. </div>
  28. </div>
  29. )
  30. }
  31. const UpgradeBtn: FC<Props> = ({
  32. className,
  33. isPlain = false,
  34. isFull = false,
  35. isShort = false,
  36. size = 'md',
  37. onClick,
  38. }) => {
  39. const { t } = useTranslation()
  40. const { setShowPricingModal } = useModalContext()
  41. if (isPlain)
  42. return <PlainBtn onClick={onClick || setShowPricingModal as any} className={className} />
  43. return (
  44. <div
  45. className={cn(
  46. s.upgradeBtn,
  47. className,
  48. isFull ? 'justify-center' : 'px-3',
  49. size === 'lg' ? 'h-10' : 'h-9',
  50. 'relative flex items-center cursor-pointer border rounded-[20px] border-[#0096EA] text-white',
  51. )}
  52. onClick={onClick || setShowPricingModal}
  53. >
  54. <GoldCoin className='mr-1 w-3.5 h-3.5' />
  55. <div className='text-xs font-normal'>{t(`billing.upgradeBtn.${isShort ? 'encourageShort' : 'encourage'}`)}</div>
  56. <Sparkles
  57. className='absolute -right-1 -top-2 w-4 h-5 bg-cover'
  58. />
  59. </div>
  60. )
  61. }
  62. export default React.memo(UpgradeBtn)