From 340e1240168b8d4ff3c826eb55e15e17a6a49f08 Mon Sep 17 00:00:00 2001 From: Aleka Cheung Date: Thu, 4 Jan 2024 16:40:27 -0500 Subject: [PATCH] add period --- src/components/Output.tsx | 12 ++- .../rewards/TradingRewardsSummaryPanel.tsx | 81 ++++++++++++++----- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/components/Output.tsx b/src/components/Output.tsx index f475bc1..984a828 100644 --- a/src/components/Output.tsx +++ b/src/components/Output.tsx @@ -65,6 +65,10 @@ type ElementProps = { resolution?: number; stripRelativeWords?: boolean; }; + timeOptions?: { + format?: 'long' | 'short' | 'narrow' | 'singleCharacter'; + useUTC?: boolean; + }; tag?: React.ReactNode; withParentheses?: boolean; locale?: string; @@ -89,6 +93,7 @@ export const Output = ({ relativeTimeFormatOptions = { format: 'singleCharacter', }, + timeOptions, tag, withParentheses, locale = navigator.language || 'en-US', @@ -165,16 +170,21 @@ export const Output = ({ if ((typeof value !== 'string' && typeof value !== 'number') || !value) return null; const date = new Date(value); const dateString = { - [OutputType.Date]: date.toLocaleString(selectedLocale, { dateStyle: 'medium' }), + [OutputType.Date]: date.toLocaleString(selectedLocale, { + dateStyle: 'medium', + timeZone: timeOptions?.useUTC ? 'UTC' : undefined, + }), [OutputType.DateTime]: date.toLocaleString(selectedLocale, { dateStyle: 'short', timeStyle: 'short', + timeZone: timeOptions?.useUTC ? 'UTC' : undefined, }), [OutputType.Time]: date.toLocaleString(selectedLocale, { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit', + timeZone: timeOptions?.useUTC ? 'UTC' : undefined, }), }[type]; diff --git a/src/pages/rewards/TradingRewardsSummaryPanel.tsx b/src/pages/rewards/TradingRewardsSummaryPanel.tsx index 236d183..493c319 100644 --- a/src/pages/rewards/TradingRewardsSummaryPanel.tsx +++ b/src/pages/rewards/TradingRewardsSummaryPanel.tsx @@ -12,11 +12,12 @@ import { Output, OutputType } from '@/components/Output'; import { Panel } from '@/components/Panel'; import { getHistoricalTradingRewards } from '@/state/accountSelectors'; +import { HistoricalTradingReward } from '@/constants/abacus'; export const TradingRewardsSummaryPanel = () => { const stringGetter = useStringGetter(); const historicalTradingRewards = useSelector(getHistoricalTradingRewards, shallowEqual); - const currentWeekTradingReward = historicalTradingRewards?.get('WEEKLY')?.firstOrNull()?.amount; + const currentWeekTradingReward = historicalTradingRewards?.get('WEEKLY')?.firstOrNull(); const { chainTokenLabel } = useTokenConfigs(); return ( @@ -28,27 +29,45 @@ export const TradingRewardsSummaryPanel = () => { } > - -

{stringGetter({ key: STRING_KEYS.THIS_WEEK })}

- - ), - value: ( - } - type={OutputType.Asset} - value={currentWeekTradingReward} - /> - ), - }, - // TODO(@aforaleka): add all-time when supported - ]} - /> + {stringGetter({ key: STRING_KEYS.COMING_SOON })} + { + +

{stringGetter({ key: STRING_KEYS.THIS_WEEK })}

+ + ), + value: ( + + } + type={OutputType.Asset} + value={currentWeekTradingReward?.amount} + /> + + + → + + + + ), + }, + // TODO(@aforaleka): add all-time when supported + ]} + /> + }
); @@ -117,3 +136,21 @@ Styled.Label = styled.div` font: var(--font-base-book); color: var(--color-text-1); `; + +Styled.ComingSoon = styled.div` + color: var(--color-text-0); +`; + +Styled.TimePeriod = styled.div` + ${layoutMixins.inlineRow} + + &, output { + color: var(--color-text-0); + font: var(--font-small-book); + } +`; + +Styled.Column = styled.div` + ${layoutMixins.flexColumn} + gap: 0.5rem; +`;