Skip to content

Commit

Permalink
fix: 🐛 Add tooltip for voting power
Browse files Browse the repository at this point in the history
  • Loading branch information
chef-ryan committed Jan 7, 2025
1 parent d908b6e commit 304a5a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Tag,
Text,
WarningIcon,
useTooltip,
} from '@pancakeswap/uikit'
import { formatBigInt, formatNumber, getBalanceAmount, getBalanceNumber } from '@pancakeswap/utils/formatBalance'
import dayjs from 'dayjs'
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/views/Voting/CreateProposal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import {
ScanLink,
Spinner,
Text,
TooltipText,
useModal,
useToast,
useTooltip,
} from '@pancakeswap/uikit'
import truncateHash from '@pancakeswap/utils/truncateHash'
import snapshot from '@snapshot-labs/snapshot.js'
Expand Down Expand Up @@ -125,6 +127,17 @@ const CreateProposal = () => {

const [onPresentVoteDetailsModal] = useModal(<VoteDetailsModal block={watch('snapshot')} />)

const votingPowerTooltipContent = t(
'Your voting power is determined by your veCAKE balance at the snapshot block, which represents how much weight your vote carries.',
)
const {
targetRef: votingPowerTargetRef,
tooltip: votingPowerTooltip,
tooltipVisible: votingPowerTooltipVisible,
} = useTooltip(<Text>{votingPowerTooltipContent}</Text>, {
placement: 'top',
})

const onSubmit = async (data: any) => {
if (!account) return

Expand Down Expand Up @@ -348,6 +361,10 @@ const CreateProposal = () => {
{t('Voting Power')}
</Text>
<Text>{isLoading ? '-' : total ?? 0}</Text>
<Box ml="8px">
<TooltipText ref={votingPowerTargetRef}>{isLoading ? '-' : total ?? 0}</TooltipText>
{votingPowerTooltipVisible && votingPowerTooltip}
</Box>
</Flex>

{/* Snapshot */}
Expand Down
3 changes: 2 additions & 1 deletion packages/localization/src/config/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3673,5 +3673,6 @@
"Existing Orders": "Existing Orders",
"Swap %token% to win a share of": "Swap %token% to win a share of",
"with daily prizes and leaderboard rewards!": "with daily prizes and leaderboard rewards!",
"Network unstable. Please refresh to continue.": "Network unstable. Please refresh to continue."
"Network unstable. Please refresh to continue.": "Network unstable. Please refresh to continue.",
"Your voting power is determined by your veCAKE balance at the snapshot block, which represents how much weight your vote carries.": "Your voting power is determined by your veCAKE balance at the snapshot block, which represents how much weight your vote carries."
}

0 comments on commit 304a5a7

Please sign in to comment.