From 66a313bef2832445ee96193d0a99c4abf8f2043d Mon Sep 17 00:00:00 2001 From: saml33 Date: Thu, 14 Mar 2024 12:31:49 +1100 Subject: [PATCH] add tooltip to limit price difference --- components/shared/TradePriceDifference.tsx | 25 +++++++++++++--------- public/locales/en/trade.json | 1 + public/locales/es/trade.json | 1 + public/locales/pt/trade.json | 1 + public/locales/ru/trade.json | 1 + public/locales/zh/trade.json | 1 + public/locales/zh_tw/trade.json | 1 + yarn.lock | 4 ++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/components/shared/TradePriceDifference.tsx b/components/shared/TradePriceDifference.tsx index 2dfd6294..1d8b20e7 100644 --- a/components/shared/TradePriceDifference.tsx +++ b/components/shared/TradePriceDifference.tsx @@ -1,4 +1,6 @@ import { useMemo } from 'react' +import Tooltip from './Tooltip' +import { useTranslation } from 'react-i18next' const TradePriceDifference = ({ currentPrice, @@ -7,6 +9,7 @@ const TradePriceDifference = ({ currentPrice: number | undefined newPrice: number | undefined }) => { + const { t } = useTranslation('trade') const priceDifference = useMemo(() => { if (!currentPrice || !newPrice) return 0 const difference = ((newPrice - currentPrice) / currentPrice) * 100 @@ -14,16 +17,18 @@ const TradePriceDifference = ({ }, [currentPrice, newPrice]) return ( -

= 0 ? 'text-th-up' : 'text-th-down' - }`} - > - {priceDifference - ? (priceDifference > 0 ? '+' : '') + priceDifference.toFixed(2) - : '0.00'} - % -

+ +

= 0 ? 'text-th-up' : 'text-th-down' + }`} + > + {priceDifference + ? (priceDifference > 0 ? '+' : '') + priceDifference.toFixed(2) + : '0.00'} + % +

+
) } diff --git a/public/locales/en/trade.json b/public/locales/en/trade.json index 36882c14..f6b0f281 100644 --- a/public/locales/en/trade.json +++ b/public/locales/en/trade.json @@ -130,6 +130,7 @@ "tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled", "tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled", "tooltip-size-base-quote": "Show size in {{token}}", "tooltip-private-counterparty": "Counterparty has Private Account enabled", diff --git a/public/locales/es/trade.json b/public/locales/es/trade.json index 3c945b67..23381a31 100644 --- a/public/locales/es/trade.json +++ b/public/locales/es/trade.json @@ -130,6 +130,7 @@ "tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled", "tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled", "tooltip-size-base-quote": "Show size in {{token}}", "tooltip-private-counterparty": "Counterparty has Private Account enabled", diff --git a/public/locales/pt/trade.json b/public/locales/pt/trade.json index 2947051f..f3d67d56 100644 --- a/public/locales/pt/trade.json +++ b/public/locales/pt/trade.json @@ -130,6 +130,7 @@ "tooltip-ioc": "Ordens Immediate-Or-Cancel (IOC) são garantidas para serem taker e devem ser executadas imediatamente. Qualquer parte da ordem que não possa ser preenchida imediatamente será cancelada", "tooltip-insured": "Se as perdas de {{tokenOrMarket}} podem ser recuperadas do fundo de seguro em caso de falências.", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Ordens post são garantidas para serem maker ou serão canceladas", "tooltip-size-base-quote": "Mostrar tamanho em {{token}}", "tooltip-private-counterparty": "Contraparte tem Conta Privada ativada", diff --git a/public/locales/ru/trade.json b/public/locales/ru/trade.json index b653bdd9..1cca1dcc 100644 --- a/public/locales/ru/trade.json +++ b/public/locales/ru/trade.json @@ -130,6 +130,7 @@ "tooltip-ioc": "Immediate-Or-Cancel (IOC) orders are guaranteed to be the taker and must be executed immediately. Any portion of the order that can't be filled immediately will be cancelled", "tooltip-insured": "Whether or not {{tokenOrMarket}} losses can be recovered from the insurance fund in the event of bankruptcies.", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Post orders are guaranteed to be the maker or they will be canceled", "tooltip-size-base-quote": "Show size in {{token}}", "tooltip-private-counterparty": "Counterparty has Private Account enabled", diff --git a/public/locales/zh/trade.json b/public/locales/zh/trade.json index 20ec33ba..3adcbaf2 100644 --- a/public/locales/zh/trade.json +++ b/public/locales/zh/trade.json @@ -130,6 +130,7 @@ "tooltip-insured": "如果发生破产,{{tokenOrMarket}}损失是否可以从保险基金中归还", "tooltip-ioc": "IOC交易若不吃单就会被取消。任何无法立刻成交的部分将被取消", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Post交易若不挂单就会被取消。", "tooltip-size-base-quote": "以{{token}}显示数量", "tooltip-private-counterparty": "交易对手已启用私人帐户", diff --git a/public/locales/zh_tw/trade.json b/public/locales/zh_tw/trade.json index 0b223d20..ee18bc65 100644 --- a/public/locales/zh_tw/trade.json +++ b/public/locales/zh_tw/trade.json @@ -130,6 +130,7 @@ "tooltip-insured": "如果發生破產,{{tokenOrMarket}}損失是否可以從保險基金中歸還", "tooltip-ioc": "IOC交易若不吃單就會被取消。任何無法立刻成交的部分將被取消", "tooltip-lifetime-funding": "Total funding earned or paid in this market for your account. This value does not reset when you close and re-enter a position.", + "tooltip-limit-price-difference": "Percentage difference from the oracle price", "tooltip-post": "Post交易若不掛單就會被取消。", "tooltip-size-base-quote": "以{{token}}顯示數量", "tooltip-private-counterparty": "交易對手已啟用私人帳戶", diff --git a/yarn.lock b/yarn.lock index a85531b5..654f6c25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2566,7 +2566,7 @@ dependencies: "@solana/wallet-adapter-base" "^0.9.23" -"@solana/wallet-adapter-solflare@0.6.27", "@solana/wallet-adapter-solflare@^0.6.28": +"@solana/wallet-adapter-solflare@0.6.27": version "0.6.27" resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-solflare/-/wallet-adapter-solflare-0.6.27.tgz#49ba2dfecca4bee048e65d302216d1b732d7e39e" integrity sha512-MBBx9B1pI8ChCT70sgxrmeib1S7G9tRQzfMHqJPdGQ2jGtukY0Puzma2OBsIAsH5Aw9rUUUFZUK+8pzaE+mgAg== @@ -2577,7 +2577,7 @@ "@solflare-wallet/sdk" "^1.3.0" "@wallet-standard/wallet" "^1.0.1" -"@solana/wallet-adapter-solflare@0.6.28": +"@solana/wallet-adapter-solflare@0.6.28", "@solana/wallet-adapter-solflare@^0.6.28": version "0.6.28" resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-solflare/-/wallet-adapter-solflare-0.6.28.tgz#3de42a43220cca361050ebd1755078012a5b0fe2" integrity sha512-iiUQtuXp8p4OdruDawsm1dRRnzUCcsu+lKo8OezESskHtbmZw2Ifej0P99AbJbBAcBw7q4GPI6987Vh05Si5rw==