Skip to content

🎥 Make videos programmatically with React

better number formatting

Patric Salvisberg7dde5138b3e3
diff --git a/packages/docs/components/LandingPage/CompanyPricing.tsx b/packages/docs/components/LandingPage/CompanyPricing.tsx
index 3ab0a046a8..7a99ec274d 100644
--- a/packages/docs/components/LandingPage/CompanyPricing.tsx
+++ b/packages/docs/components/LandingPage/CompanyPricing.tsx
@@ -1,4 +1,4 @@
-import React, { useMemo } from "react";
+import React, { useCallback, useMemo } from "react";
import { Counter } from "./Counter";
import styles from "./pricing.module.css";
import { PricingBulletPoint } from "./PricingBulletPoint";
@@ -15,6 +15,15 @@ export const CompanyPricing: React.FC = () => {
const [devSeatCount, setDevSeatCount] = React.useState(1);
const [cloudUnitCount, setCloudUnitCount] = React.useState(1);
+ const formatPrice = useCallback((price: number) => {
+ const formatter = new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: "USD",
+ maximumFractionDigits: 0,
+ });
+ return formatter.format(price);
+ }, []);
+
const totalPrice = useMemo(() => {
return Math.max(
100,
@@ -22,8 +31,15 @@ export const CompanyPricing: React.FC = () => {
);
}, [cloudUnitCount, devSeatCount]);
+ const totalPriceString = useMemo(() => {
+ return formatPrice(totalPrice);
+ }, [formatPrice, totalPrice]);
+
const rendersPerMonth = useMemo(() => {
- return cloudUnitCount * 2000;
+ const formatter = new Intl.NumberFormat("en-US", {
+ maximumFractionDigits: 0,
+ });
+ return formatter.format(cloudUnitCount * 2000);
}, [cloudUnitCount]);
return (
@@ -64,7 +80,7 @@ export const CompanyPricing: React.FC = () => {
style={{ justifyContent: "flex-end" }}
>
<div style={{ ...textUnitWrapper, alignItems: "flex-end" }}>
- <div className={styles.pricetag}>${totalPrice}/mo</div>
+ <div className={styles.pricetag}>{totalPriceString}/mo</div>
{totalPrice <= 100 ? (
<div className={styles.descriptionsmall} style={{ height: 24 }}>
The minimum is $100 per month
diff --git a/packages/docs/components/LandingPage/Pricing.tsx b/packages/docs/components/LandingPage/Pricing.tsx
index 7f08ccc58e..f8d8c2e4c2 100644
--- a/packages/docs/components/LandingPage/Pricing.tsx
+++ b/packages/docs/components/LandingPage/Pricing.tsx
@@ -5,7 +5,14 @@ import { FreePricing2 } from "./FreePricing2";
export const Pricing: React.FC = () => {
return (
- <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "column",
+ gap: 20,
+ marginBottom: 40,
+ }}
+ >
<FreePricing2 />
<CompanyPricing />
<EnterpriseLicense />
diff --git a/packages/docs/components/LandingPage/pricing.module.css b/packages/docs/components/LandingPage/pricing.module.css
index cb14f2f2d4..9ba2dcdfeb 100644
--- a/packages/docs/components/LandingPage/pricing.module.css
+++ b/packages/docs/components/LandingPage/pricing.module.css
@@ -13,7 +13,7 @@
font-family: "GTPlanar", sans-serif;
font-size: 24px;
font-weight: 500;
- width: 38px;
+ width: 44px;
border: none;
text-align: end;
}