Change disabled btns (#59)
This commit is contained in:
parent
87e0f8b49b
commit
f0d8d6b74e
|
@ -110,3 +110,11 @@ export const ProposingBtn = styled(Btn)`
|
||||||
filter: grayscale(1);
|
filter: grayscale(1);
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const DisabledButton = styled(Btn)`
|
||||||
|
width: 100%;
|
||||||
|
background-color: #f3f3f3;
|
||||||
|
color: #676868;
|
||||||
|
font-size: 15px;
|
||||||
|
margin-top: 32px;
|
||||||
|
`
|
||||||
|
|
|
@ -50,7 +50,7 @@ export function VoteChart({
|
||||||
|
|
||||||
let balanceWidth = graphWidth
|
let balanceWidth = graphWidth
|
||||||
|
|
||||||
if (proposingAmount && selectedVote) {
|
if (proposingAmount) {
|
||||||
balanceWidth =
|
balanceWidth =
|
||||||
selectedVote === 0
|
selectedVote === 0
|
||||||
? (100 * (votesAgainst + proposingAmount)) / (voteSum + proposingAmount)
|
? (100 * (votesAgainst + proposingAmount)) / (voteSum + proposingAmount)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { ProposingBtn } from './Buttons'
|
import { ProposingBtn } from './Buttons'
|
||||||
import { Card, CardHeading, CardText } from './ProposalInfo'
|
import { CardHeading, CardText } from './ProposalInfo'
|
||||||
import { ProposingData } from './ProposeModal'
|
import { ProposingData } from './ProposeModal'
|
||||||
import { VotePropose } from './VotePropose'
|
import { VotePropose } from './VotePropose'
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ export function VoteAnimatedModal({
|
||||||
}: VoteAnimatedModalProps) {
|
}: VoteAnimatedModalProps) {
|
||||||
return (
|
return (
|
||||||
<VoteConfirm>
|
<VoteConfirm>
|
||||||
<ConfirmText>Your vote for this proposal has been cast!</ConfirmText>
|
<ConfirmText>Your vote {selectedVote === 0 ? 'against' : 'for'} this proposal has been cast!</ConfirmText>
|
||||||
|
|
||||||
<VoteChart
|
<VoteChart
|
||||||
votesFor={votesFor}
|
votesFor={votesFor}
|
||||||
votesAgainst={votesAgainst}
|
votesAgainst={votesAgainst}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { VoteChart } from './ProposalVoteCard/VoteChart'
|
import { VoteChart } from './ProposalVoteCard/VoteChart'
|
||||||
import { VoteBtnAgainst, VoteBtnFor } from './Buttons'
|
import { DisabledButton, VoteBtnAgainst, VoteBtnFor } from './Buttons'
|
||||||
import { VotePropose } from './VotePropose'
|
import { VotePropose } from './VotePropose'
|
||||||
|
|
||||||
export interface VoteModalProps {
|
export interface VoteModalProps {
|
||||||
|
@ -28,6 +28,7 @@ export function VoteModal({
|
||||||
setProposingAmount,
|
setProposingAmount,
|
||||||
}: VoteModalProps) {
|
}: VoteModalProps) {
|
||||||
const disabled = proposingAmount === 0
|
const disabled = proposingAmount === 0
|
||||||
|
const funds = availableAmount > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column>
|
<Column>
|
||||||
|
@ -45,15 +46,18 @@ export function VoteModal({
|
||||||
proposingAmount={proposingAmount}
|
proposingAmount={proposingAmount}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{selectedVote === 0 ? (
|
{!funds && <DisabledButton>Not enought ABC to vote</DisabledButton>}
|
||||||
<ModalVoteBtnAgainst disabled={disabled} onClick={() => setShowConfirmModal(true)}>
|
|
||||||
Vote Against
|
{funds &&
|
||||||
</ModalVoteBtnAgainst>
|
(selectedVote === 0 ? (
|
||||||
) : (
|
<ModalVoteBtnAgainst disabled={disabled} onClick={() => setShowConfirmModal(true)}>
|
||||||
<ModalVoteBtnFor disabled={disabled} onClick={() => setShowConfirmModal(true)}>
|
Vote Against
|
||||||
Vote For
|
</ModalVoteBtnAgainst>
|
||||||
</ModalVoteBtnFor>
|
) : (
|
||||||
)}
|
<ModalVoteBtnFor disabled={disabled} onClick={() => setShowConfirmModal(true)}>
|
||||||
|
Vote For
|
||||||
|
</ModalVoteBtnFor>
|
||||||
|
))}
|
||||||
</Column>
|
</Column>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,20 @@ export interface VoteProposingProps {
|
||||||
availableAmount: number
|
availableAmount: number
|
||||||
setProposingAmount: (show: number) => void
|
setProposingAmount: (show: number) => void
|
||||||
proposingAmount: number
|
proposingAmount: number
|
||||||
disabled?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function VotePropose({ availableAmount, proposingAmount, setProposingAmount }: VoteProposingProps) {
|
export function VotePropose({ availableAmount, proposingAmount, setProposingAmount }: VoteProposingProps) {
|
||||||
const [displayAmount, setDisplayAmount] = useState(addCommas(proposingAmount) + ' SNT')
|
const [displayAmount, setDisplayAmount] = useState(addCommas(proposingAmount) + ' ABC')
|
||||||
|
const disabled = availableAmount === 0
|
||||||
let step = 10 ** (Math.floor(Math.log10(availableAmount)) - 2)
|
let step = 10 ** (Math.floor(Math.log10(availableAmount)) - 2)
|
||||||
|
|
||||||
if (availableAmount < 100) {
|
if (availableAmount < 100) {
|
||||||
step = 1
|
step = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const setAvailableAmount = () => {
|
const setAvailableAmount = () => {
|
||||||
setProposingAmount(availableAmount)
|
setProposingAmount(availableAmount)
|
||||||
setDisplayAmount(addCommas(availableAmount) + ' SNT')
|
setDisplayAmount(addCommas(availableAmount) + ' ABC')
|
||||||
}
|
}
|
||||||
|
|
||||||
const sliderChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const sliderChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
@ -29,7 +29,7 @@ export function VotePropose({ availableAmount, proposingAmount, setProposingAmou
|
||||||
setAvailableAmount()
|
setAvailableAmount()
|
||||||
} else {
|
} else {
|
||||||
setProposingAmount(Number(e.target.value))
|
setProposingAmount(Number(e.target.value))
|
||||||
setDisplayAmount(addCommas(Number(e.target.value)) + ' SNT')
|
setDisplayAmount(addCommas(Number(e.target.value)) + ' ABC')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ export function VotePropose({ availableAmount, proposingAmount, setProposingAmou
|
||||||
if (proposingAmount > availableAmount) {
|
if (proposingAmount > availableAmount) {
|
||||||
setAvailableAmount()
|
setAvailableAmount()
|
||||||
} else {
|
} else {
|
||||||
setDisplayAmount(addCommas(proposingAmount) + ' SNT')
|
setDisplayAmount(addCommas(proposingAmount) + ' ABC')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ export function VotePropose({ availableAmount, proposingAmount, setProposingAmou
|
||||||
value={proposingAmount}
|
value={proposingAmount}
|
||||||
onChange={sliderChange}
|
onChange={sliderChange}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(90deg, #0F3595 0% ${progress}, #EDF1FF ${progress} 100%)`,
|
background: disabled
|
||||||
|
? '#EDF1FF'
|
||||||
|
: `linear-gradient(90deg, #0F3595 0% ${progress}, #EDF1FF ${progress} 100%)`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</VoteProposingRangeWrap>
|
</VoteProposingRangeWrap>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { useEthers } from '@usedapp/core'
|
import { useEthers } from '@usedapp/core'
|
||||||
|
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { CreateButton, Modal, Networks, Theme } from '@status-waku-voting/react-components'
|
import { CreateButton, Modal, Networks, Theme } from '@status-waku-voting/react-components'
|
||||||
import { ProposeModal } from './ProposeModal'
|
import { ProposeModal } from './ProposeModal'
|
||||||
|
|
Loading…
Reference in New Issue