-
Notifications
You must be signed in to change notification settings - Fork 15
feat(staking): [LW-8877] Add activity tab to staking, show rewards list #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mrcnk
merged 4 commits into
feat/lw-8877-activity-tab
from
feat/lw-8877-staking-activity-rewards
Nov 6, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
be2b44b
feat(staking): add rewards list to Staking Activity tab
refi93 483284e
feat(staking): expose activity detail drawer in staking section to be…
refi93 b18b9a6
feat(staking): add "no staking activity yet" screen
refi93 fc496c2
fix(staking): align "no staking activity" component to center vertically
refi93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 +1,23 @@ | ||
| export const Activity = () => <>Activity placeholder</>; | ||
| import { StateStatus, useOutsideHandles } from 'features/outside-handles-provider'; | ||
| import { getGroupedRewardsActivities } from './helpers/getGroupedRewardsHistory'; | ||
| import { NoStakingActivity } from './NoStakingActivity'; | ||
| import { RewardsHistory } from './RewardsHistory'; | ||
|
|
||
| export const Activity = () => { | ||
| const { walletStoreWalletActivitiesStatus: walletActivitiesStatus, walletStoreWalletActivities: walletActivities } = | ||
| useOutsideHandles(); | ||
| const groupedRewardsActivities = getGroupedRewardsActivities(walletActivities); | ||
|
|
||
| return ( | ||
| <> | ||
| {walletActivitiesStatus === StateStatus.LOADED && groupedRewardsActivities.length === 0 ? ( | ||
| <NoStakingActivity /> | ||
| ) : ( | ||
| <RewardsHistory | ||
| walletActivitiesStatus={walletActivitiesStatus} | ||
| groupedRewardsActivities={groupedRewardsActivities} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; |
13 changes: 13 additions & 0 deletions
13
packages/staking/src/features/activity/NoStakingActivity.css.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { style } from '@lace/ui'; | ||
| import { theme } from 'features/theme'; | ||
|
|
||
| export const sadFaceIcon = style({ | ||
| height: theme.spacing.$112, | ||
| width: theme.spacing.$112, | ||
| }); | ||
|
|
||
| export const noActivityText = style({ | ||
| color: theme.colors.$activityNoActivityTextColor, | ||
| fontSize: theme.fontSizes.$14, | ||
| fontWeight: theme.fontWeights.$semibold, | ||
| }); |
17 changes: 17 additions & 0 deletions
17
packages/staking/src/features/activity/NoStakingActivity.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import SadFaceIcon from '@lace/core/src/ui/assets/icons/sad-face.component.svg'; | ||
| import { Flex } from '@lace/ui'; | ||
| import { Typography } from 'antd'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import * as styles from './NoStakingActivity.css'; | ||
|
|
||
| export const NoStakingActivity = () => { | ||
| const { t } = useTranslation(); | ||
| return ( | ||
| <Flex h="$fill" flexDirection="column" alignItems="center" justifyContent="center" gap="$8"> | ||
| <SadFaceIcon className={styles.sadFaceIcon} /> | ||
| <Typography.Text className={styles.noActivityText}> | ||
| {t('activity.rewardsHistory.noStakingActivityYet')} | ||
| </Typography.Text> | ||
| </Flex> | ||
| ); | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { AssetActivityListProps, GroupedAssetActivityList } from '@lace/core'; | ||
| import { Box, Text } from '@lace/ui'; | ||
| import { Skeleton } from 'antd'; | ||
| import { StateStatus } from 'features/outside-handles-provider'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| const LACE_APP_ID = 'lace-app'; | ||
|
|
||
| type RewardsHistoryProps = { | ||
| groupedRewardsActivities: AssetActivityListProps[]; | ||
| walletActivitiesStatus: StateStatus; | ||
| }; | ||
| export const RewardsHistory = ({ groupedRewardsActivities, walletActivitiesStatus }: RewardsHistoryProps) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <> | ||
| <Box mb="$16"> | ||
| <Text.SubHeading>{t('activity.rewardsHistory.title')}</Text.SubHeading> | ||
| </Box> | ||
| <Skeleton loading={walletActivitiesStatus !== StateStatus.LOADED}> | ||
| <GroupedAssetActivityList | ||
| lists={groupedRewardsActivities} | ||
| infiniteScrollProps={{ scrollableTarget: LACE_APP_ID }} | ||
| /> | ||
| </Skeleton> | ||
| </> | ||
| ); | ||
| }; |
9 changes: 9 additions & 0 deletions
9
packages/staking/src/features/activity/helpers/getGroupedRewardsHistory.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { AssetActivityListProps } from '@lace/core'; | ||
|
|
||
| export const getGroupedRewardsActivities = (walletActivities: AssetActivityListProps[]) => | ||
| walletActivities | ||
| .map((group) => ({ | ||
| ...group, | ||
| items: group.items.filter((item) => item.type === 'rewards'), | ||
| })) | ||
| .filter((group) => group.items.length > 0); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the "Activity" page (and any other "Staking" tab) container fill the available vertical space, which in turns allows me to align vertically to the center the "No staking activity yet" component. TBH I find this a bit fragile as the code lacks any clear connection and therefore it's easy to break. Do you perhaps have some nicer solution on your mind @mrcnk ?