-
-
-
-
- {rate} {getCurrencySymbol(walletAddress.assetCode)} per hour
-
-
- Remaining balance: {getCurrencySymbol(walletAddress.assetCode)}
- {remainingBalance}
-
-
+
+
+ Pay as you browse
+ Support content you love
+
+
+
+
+ );
+};
+
+const InfoBanner = () => {
+ const {
+ state: { rateOfPay, balance, walletAddress },
+ } = usePopupState();
+
+ const rate = React.useMemo(() => {
+ const r = Number(rateOfPay) / 10 ** walletAddress.assetScale;
+ const roundedR = roundWithPrecision(r, walletAddress.assetScale);
+
+ return formatCurrency(
+ formatNumber(roundedR, walletAddress.assetScale, true),
+ walletAddress.assetCode,
+ walletAddress.assetScale,
+ );
+ }, [rateOfPay, walletAddress.assetCode, walletAddress.assetScale]);
+
+ const remainingBalance = React.useMemo(() => {
+ const val = Number(balance) / 10 ** walletAddress.assetScale;
+ const rounded = roundWithPrecision(val, walletAddress.assetScale);
+ return formatCurrency(
+ formatNumber(rounded, walletAddress.assetScale, true),
+ walletAddress.assetCode,
+ walletAddress.assetScale,
+ );
+ }, [balance, walletAddress.assetCode, walletAddress.assetScale]);
+
+ return (
+
+
+
+
- Hourly rate
+ - {rate}
- ) : (
-
-
-
- Web Monetization has been turned off.
-
+
+
- Balance
+ - {remainingBalance}
- )}
-
-
-
+
- {tab.url ?
: null}
+
+
+ To adjust your budget or rate of pay, click on{' '}
+
+
+
);
};
diff --git a/src/shared/helpers.ts b/src/shared/helpers.ts
index 2a4ea470..7a5005be 100644
--- a/src/shared/helpers.ts
+++ b/src/shared/helpers.ts
@@ -18,12 +18,17 @@ export const cn = (...inputs: CxOptions) => {
return twMerge(cx(inputs));
};
-export const formatCurrency = (value: any): string => {
- if (value < 1) {
- return `${Math.round(value * 100)}c`;
- } else {
- return `$${parseFloat(value).toFixed(2)}`;
- }
+export const formatCurrency = (
+ value: string | number,
+ currency: string,
+ maximumFractionDigits = 2,
+ locale?: string,
+): string => {
+ return new Intl.NumberFormat(locale, {
+ style: 'currency',
+ currency,
+ maximumFractionDigits,
+ }).format(Number(value));
};
const isWalletAddress = (o: any): o is WalletAddress => {
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 67c82e55..48ab8629 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -17,6 +17,7 @@ module.exports = {
textColor: {
primary: 'rgb(var(--text-primary) / )',
secondary: 'rgb(var(--text-secondary) / )',
+ 'secondary-dark': 'rgb(var(--text-secondary-dark) / )',
weak: 'rgb(var(--text-weak) / )',
medium: 'rgb(var(--text-medium) / )',
strong: 'rgb(var(--text-strong) / )',