-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #792 from alleslabs/fix/expedited
fix: expedited with params
- Loading branch information
Showing
7 changed files
with
95 additions
and
46 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,38 +1,82 @@ | ||
import { Flex, Text, Highlight } from "@chakra-ui/react"; | ||
import { Flex, SkeletonText, Text } from "@chakra-ui/react"; | ||
|
||
import { useProposalParams } from "lib/services/proposalService"; | ||
import type { Option } from "lib/types"; | ||
import { formatPrettyPercent, formatSeconds } from "lib/utils"; | ||
|
||
import { CustomIcon } from "./icon"; | ||
import { Tooltip } from "./Tooltip"; | ||
|
||
const ExpeditedText = ( | ||
<Text variant="body3"> | ||
<Highlight | ||
query="pass a high quorum threshold of 66.6% within the first 24 hours of voting" | ||
styles={{ fontWeight: 700, whiteSpace: "wrap", color: "text.main" }} | ||
> | ||
An expedited governance proposal is required to pass a high quorum | ||
threshold of 66.6% within the first 24 hours of voting in order to pass. | ||
</Highlight> | ||
</Text> | ||
); | ||
const ExpeditedText = ({ | ||
quorum, | ||
threshold, | ||
votingPeriod, | ||
isLoading, | ||
}: { | ||
quorum: Option<number>; | ||
threshold: Option<number>; | ||
votingPeriod: Option<string>; | ||
isLoading: boolean; | ||
}) => { | ||
if (isLoading) | ||
<SkeletonText | ||
color="white" | ||
noOfLines={4} | ||
spacing={2.5} | ||
skeletonHeight={2} | ||
w="250px" | ||
/>; | ||
|
||
return ( | ||
<Text variant="body3"> | ||
An expedited governance proposal is required to{" "} | ||
<span style={{ fontWeight: 700, color: "text.main" }}> | ||
pass a quorum of {quorum ? formatPrettyPercent(quorum, 1, true) : "N/A"}{" "} | ||
and a high threshold of{" "} | ||
{threshold ? formatPrettyPercent(threshold, 1, true) : "N/A"} within{" "} | ||
{formatSeconds(votingPeriod)} voting period | ||
</span>{" "} | ||
in order to pass. | ||
</Text> | ||
); | ||
}; | ||
|
||
interface ExpeditedProps { | ||
isActiveExpedited: boolean; | ||
} | ||
export const Expedited = ({ isActiveExpedited }: ExpeditedProps) => ( | ||
<Tooltip label={ExpeditedText}> | ||
<Flex align="center"> | ||
<CustomIcon | ||
name="expedited" | ||
boxSize={4} | ||
ml={0} | ||
color={isActiveExpedited ? "accent.main" : "gray.400"} | ||
/> | ||
<Text | ||
variant="body3" | ||
color={isActiveExpedited ? "accent.main" : "text.dark"} | ||
> | ||
Expedited | ||
</Text> | ||
</Flex> | ||
</Tooltip> | ||
); | ||
|
||
export const Expedited = ({ isActiveExpedited }: ExpeditedProps) => { | ||
const { data: params, isLoading } = useProposalParams(); | ||
const quorum = params?.expeditedQuorum || params?.quorum; | ||
const threshold = params?.expeditedThreshold || params?.threshold; | ||
const votingPeriod = params?.expeditedVotingPeriod || params?.votingPeriod; | ||
|
||
return ( | ||
<Tooltip | ||
label={ | ||
<ExpeditedText | ||
quorum={quorum} | ||
threshold={threshold} | ||
votingPeriod={votingPeriod} | ||
isLoading={isLoading} | ||
/> | ||
} | ||
> | ||
<Flex as="span" align="center"> | ||
<CustomIcon | ||
name="expedited" | ||
boxSize={4} | ||
ml={0} | ||
color={isActiveExpedited ? "accent.main" : "gray.400"} | ||
/> | ||
<Text | ||
as="span" | ||
variant="body3" | ||
color={isActiveExpedited ? "accent.main" : "text.dark"} | ||
> | ||
Expedited | ||
</Text> | ||
</Flex> | ||
</Tooltip> | ||
); | ||
}; |
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
4 changes: 2 additions & 2 deletions
4
src/lib/pages/proposal-details/components/VoteThresholdBar.tsx
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
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