From de63fe1355cbecf67ef66d4b3556cc56eba9cba4 Mon Sep 17 00:00:00 2001 From: Sergey Zhuravlev Date: Wed, 12 Feb 2025 15:09:35 +0100 Subject: [PATCH] fix: layout of voting history modal (#3120) --- .../VotingHistory/VotingHistoryDialog.tsx | 114 ++++++++---------- .../VotingHistory/VotingHistoryList.tsx | 81 ++++++------- .../shared/ui-kit/ScrollArea/ScrollArea.css | 1 + src/renderer/shared/ui-kit/Tabs/Tabs.tsx | 2 +- 4 files changed, 94 insertions(+), 104 deletions(-) diff --git a/src/renderer/features/governance/components/VotingHistory/VotingHistoryDialog.tsx b/src/renderer/features/governance/components/VotingHistory/VotingHistoryDialog.tsx index 98a80f2591..6dbb281067 100644 --- a/src/renderer/features/governance/components/VotingHistory/VotingHistoryDialog.tsx +++ b/src/renderer/features/governance/components/VotingHistory/VotingHistoryDialog.tsx @@ -5,9 +5,8 @@ import { type Referendum } from '@/shared/core'; import { useI18n } from '@/shared/i18n'; import { useModalClose } from '@/shared/lib/hooks'; import { cnTw } from '@/shared/lib/utils'; -import { Button, FootnoteText, Icon, SmallTitleText, Tabs } from '@/shared/ui'; -import { type TabItem } from '@/shared/ui/Tabs/common/types'; -import { Modal } from '@/shared/ui-kit'; +import { Button, FootnoteText, Icon, SmallTitleText } from '@/shared/ui'; +import { Box, Modal, Tabs } from '@/shared/ui-kit'; import { voteHistoryAggregate } from '../../aggregates/voteHistory'; import { VoteCount } from './VoteCount'; @@ -23,7 +22,7 @@ export const VotingHistoryDialog = ({ referendum, onClose }: Props) => { const { t } = useI18n(); const [showModal, closeModal] = useModalClose(true, onClose); - const [selectedTab, setSelectedTab] = useState(0); + const [selectedTab, setSelectedTab] = useState('aye'); const chain = useUnit(voteHistoryAggregate.$chain); @@ -41,66 +40,57 @@ export const VotingHistoryDialog = ({ referendum, onClose }: Props) => { const nays = useMemo(() => voteHistory.filter((history) => history.decision === 'nay'), [voteHistory]); const abstain = useMemo(() => voteHistory.filter((history) => history.decision === 'abstain'), [voteHistory]); - const tabs: TabItem[] = [ - { - id: 'ayes', - title: ( - - - {t('governance.referendum.ayes')} - - - ), - panel: , - }, - { - id: 'nays', - title: ( - - - {t('governance.referendum.nays')} - - - ), - panel: , - }, - { - id: 'abstain', - title: ( - - - {t('governance.referendum.abstain')} - - - ), - panel: , - }, - ]; - return ( - + {t('governance.voteHistory.title')} - -
- {hasError ? ( -
- - {t('governance.voteHistory.notAvailable')} - - {t('governance.voteHistory.notAvailableDescription')} - - -
- ) : ( - - )} -
+ + {hasError ? ( +
+ + {t('governance.voteHistory.notAvailable')} + + {t('governance.voteHistory.notAvailableDescription')} + + +
+ ) : ( + + + + + + {t('governance.referendum.ayes')} + + + + + {t('governance.referendum.nays')} + + + + + {t('governance.referendum.abstain')} + + + + + + + + + + + + + + + )}
); diff --git a/src/renderer/features/governance/components/VotingHistory/VotingHistoryList.tsx b/src/renderer/features/governance/components/VotingHistory/VotingHistoryList.tsx index 05701bf5c0..eabdbefff6 100644 --- a/src/renderer/features/governance/components/VotingHistory/VotingHistoryList.tsx +++ b/src/renderer/features/governance/components/VotingHistory/VotingHistoryList.tsx @@ -6,7 +6,7 @@ import { useDeferredList } from '@/shared/lib/hooks'; import { formatAsset, formatBalance, performSearch, toAccountId } from '@/shared/lib/utils'; import { BodyText, FootnoteText } from '@/shared/ui'; import { AccountExplorers, Address } from '@/shared/ui-entities'; -import { SearchInput } from '@/shared/ui-kit'; +import { Box, ScrollArea, SearchInput } from '@/shared/ui-kit'; import { type AggregatedVoteHistory } from '../../types/structs'; import { VotingHistoryListEmptyState } from './VotingHistoryListEmptyState'; @@ -38,46 +38,45 @@ export const VotingHistoryList = memo(({ items, asset, chain, loading }: Props) const shouldRenderList = !shouldRenderLoader && deferredItems.length > 0; return ( -
- -
-
-
- {t('governance.voteHistory.listColumnAccount')} - - {t('governance.voteHistory.listColumnVotingPower')} - -
-
- {shouldRenderLoader && } - {shouldRenderEmptyState && } - {shouldRenderList && - deferredItems.map(({ voter, balance, votingPower, conviction, name }) => { - return ( -
-
-
- -
-
- - {t('governance.voteHistory.totalVotesCount', { - value: formatBalance(votingPower, asset.precision).formatted, - })} - - - {t('general.actions.multiply', { - value: formatAsset(balance, asset), - multiplier: conviction, - })} - -
+ + + + + + + {t('governance.voteHistory.listColumnAccount')} + {t('governance.voteHistory.listColumnVotingPower')} + + + + {shouldRenderLoader && } + {shouldRenderEmptyState && } + {shouldRenderList && + deferredItems.map(({ voter, balance, votingPower, conviction, name }) => { + return ( +
+
+
+ +
+
+ + {t('governance.voteHistory.totalVotesCount', { + value: formatBalance(votingPower, asset.precision).formatted, + })} + + + {t('general.actions.multiply', { + value: formatAsset(balance, asset), + multiplier: conviction, + })} +
- ); - })} -
-
-
-
+
+ ); + })} + + + ); }); diff --git a/src/renderer/shared/ui-kit/ScrollArea/ScrollArea.css b/src/renderer/shared/ui-kit/ScrollArea/ScrollArea.css index eed06ea0d8..328aff12f5 100644 --- a/src/renderer/shared/ui-kit/ScrollArea/ScrollArea.css +++ b/src/renderer/shared/ui-kit/ScrollArea/ScrollArea.css @@ -4,6 +4,7 @@ --scroll-area-top-fade: 0px; --scroll-area-bottom-fade: 0px; + contain: layout; mask-image: linear-gradient( to bottom, transparent 0px, diff --git a/src/renderer/shared/ui-kit/Tabs/Tabs.tsx b/src/renderer/shared/ui-kit/Tabs/Tabs.tsx index 566a420826..817e120a6f 100644 --- a/src/renderer/shared/ui-kit/Tabs/Tabs.tsx +++ b/src/renderer/shared/ui-kit/Tabs/Tabs.tsx @@ -44,7 +44,7 @@ const Trigger = ({ value, disabled, children }: TriggerProps) => {