-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update trading rewards table styling, pr followups (#602)
- Loading branch information
1 parent
548bb2a
commit 4596f24
Showing
6 changed files
with
360 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,73 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { | ||
HISTORICAL_TRADING_REWARDS_PERIODS, | ||
HistoricalTradingRewardsPeriod, | ||
HistoricalTradingRewardsPeriods, | ||
} from '@/constants/abacus'; | ||
import { HistoricalTradingRewardsPeriod } from '@/constants/abacus'; | ||
import { STRING_KEYS } from '@/constants/localization'; | ||
|
||
import { useEnvConfig } from '@/hooks/useEnvConfig'; | ||
import { useStringGetter } from '@/hooks/useStringGetter'; | ||
|
||
import breakpoints from '@/styles/breakpoints'; | ||
import { layoutMixins } from '@/styles/layoutMixins'; | ||
|
||
import { Output, OutputType } from '@/components/Output'; | ||
import { Panel } from '@/components/Panel'; | ||
import { ToggleGroup } from '@/components/ToggleGroup'; | ||
import { WithTooltip } from '@/components/WithTooltip'; | ||
import { TradingRewardHistoryTable } from '@/views/tables/TradingRewardHistoryTable'; | ||
|
||
import abacusStateManager from '@/lib/abacus'; | ||
|
||
export const RewardHistoryPanel = () => { | ||
const stringGetter = useStringGetter(); | ||
const rewardsHistoryStartDate = useEnvConfig('rewardsHistoryStartDateMs'); | ||
|
||
const [selectedPeriod, setSelectedPeriod] = useState<HistoricalTradingRewardsPeriods>( | ||
abacusStateManager.getHistoricalTradingRewardPeriod() || HistoricalTradingRewardsPeriod.WEEKLY | ||
); | ||
|
||
const onSelectPeriod = useCallback((periodName: string) => { | ||
const thisSelectedPeriod = | ||
HISTORICAL_TRADING_REWARDS_PERIODS[ | ||
periodName as keyof typeof HISTORICAL_TRADING_REWARDS_PERIODS | ||
]; | ||
setSelectedPeriod(thisSelectedPeriod); | ||
abacusStateManager.setHistoricalTradingRewardPeriod(thisSelectedPeriod); | ||
}, []); | ||
|
||
return ( | ||
<Panel | ||
slotHeader={ | ||
<$Header> | ||
<$Title> | ||
<WithTooltip tooltip="reward-history"> | ||
<h3>{stringGetter({ key: STRING_KEYS.REWARD_HISTORY })}</h3> | ||
</WithTooltip> | ||
<span> | ||
{stringGetter({ | ||
key: STRING_KEYS.REWARD_HISTORY_DESCRIPTION, | ||
params: { | ||
REWARDS_HISTORY_START_DATE: ( | ||
<$Output | ||
type={OutputType.Date} | ||
value={Number(rewardsHistoryStartDate)} | ||
timeOptions={{ useUTC: true }} | ||
/> | ||
), | ||
}, | ||
})} | ||
</span> | ||
</$Title> | ||
<ToggleGroup | ||
items={[ | ||
{ | ||
value: HistoricalTradingRewardsPeriod.MONTHLY.name, | ||
label: stringGetter({ key: STRING_KEYS.MONTHLY }), | ||
}, | ||
{ | ||
value: HistoricalTradingRewardsPeriod.WEEKLY.name, | ||
label: stringGetter({ key: STRING_KEYS.WEEKLY }), | ||
}, | ||
{ | ||
value: HistoricalTradingRewardsPeriod.DAILY.name, | ||
label: stringGetter({ key: STRING_KEYS.DAILY }), | ||
}, | ||
]} | ||
value={selectedPeriod.name} | ||
onValueChange={onSelectPeriod} | ||
/> | ||
</$Header> | ||
} | ||
> | ||
<TradingRewardHistoryTable period={selectedPeriod} /> | ||
</Panel> | ||
<$RewardHistoryContainer> | ||
<$Header> | ||
<$Title>{stringGetter({ key: STRING_KEYS.TRADING_REWARD_HISTORY })}</$Title> | ||
</$Header> | ||
<$TradingRewardHistoryTable period={HistoricalTradingRewardsPeriod.DAILY} /> | ||
<$Description> | ||
{stringGetter({ | ||
key: STRING_KEYS.REWARD_HISTORY_DESCRIPTION, | ||
params: { | ||
REWARDS_HISTORY_START_DATE: ( | ||
<$Output | ||
type={OutputType.Date} | ||
value={Number(rewardsHistoryStartDate)} | ||
timeOptions={{ useUTC: true }} | ||
/> | ||
), | ||
}, | ||
})} | ||
</$Description> | ||
</$RewardHistoryContainer> | ||
); | ||
}; | ||
const $Header = styled.div` | ||
${layoutMixins.spacedRow} | ||
|
||
padding: 1rem 1rem 0; | ||
margin-bottom: -0.5rem; | ||
const $RewardHistoryContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--gap); | ||
`; | ||
|
||
const $Header = styled.div` | ||
@media ${breakpoints.notTablet} { | ||
padding: 1.25rem 1.5rem 0; | ||
margin-bottom: -0.5rem; | ||
} | ||
`; | ||
|
||
const $Title = styled.div` | ||
${layoutMixins.column} | ||
color: var(--color-text-0); | ||
font: var(--font-small-book); | ||
font: var(--font-large-book); | ||
color: var(--color-text-2); | ||
`; | ||
|
||
h3 { | ||
font: var(--font-medium-book); | ||
color: var(--color-text-2); | ||
} | ||
const $TradingRewardHistoryTable = styled(TradingRewardHistoryTable)` | ||
--computed-radius: 0.875rem; | ||
`; | ||
|
||
const $Output = styled(Output)` | ||
display: inline; | ||
`; | ||
|
||
const $Description = styled.span` | ||
font: var(--font-mini-book); | ||
color: var(--color-text-0); | ||
padding: 0 8rem; | ||
text-align: center; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.