promotionPriceDisplay.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import styled from '@emotion/styled';
  2. import {space} from 'sentry/styles/space';
  3. export default function PromotionPriceDisplay({
  4. price,
  5. title,
  6. promo = false,
  7. showDecimals = true,
  8. }: {
  9. price: number;
  10. title: string;
  11. promo?: boolean;
  12. showDecimals?: boolean;
  13. }) {
  14. const priceString = showDecimals ? price.toFixed(2) : price.toString();
  15. return (
  16. <div>
  17. <PriceHeader>{title}</PriceHeader>
  18. <Price>
  19. <Currency>$</Currency>
  20. <Amount promo={promo}>{priceString}</Amount>
  21. <BillingInterval>{`/mo`}</BillingInterval>
  22. </Price>
  23. </div>
  24. );
  25. }
  26. const PriceHeader = styled('div')`
  27. text-transform: uppercase;
  28. font-weight: bold;
  29. color: ${p => p.theme.gray400};
  30. font-size: ${p => p.theme.fontSizeMedium};
  31. `;
  32. const Price = styled('div')`
  33. display: flex;
  34. color: ${p => p.theme.textColor};
  35. `;
  36. const Currency = styled('div')`
  37. padding-top: ${space(0.5)};
  38. `;
  39. const Amount = styled('div')<{promo?: boolean}>`
  40. font-size: 30px;
  41. font-weight: ${p => (p.promo ? 'bold' : 'none')};
  42. text-decoration: ${p => (p.promo ? 'none' : 'line-through')};
  43. color: ${p => (p.promo ? p.theme.headingColor : p.theme.gray300)};
  44. `;
  45. const BillingInterval = styled('div')`
  46. font-size: ${p => p.theme.fontSizeMedium};
  47. padding-bottom: 7px;
  48. align-self: end;
  49. `;