Add proposing skeleton (#69)

This commit is contained in:
Maria Rushkova 2021-06-29 12:21:38 +02:00 committed by GitHub
parent 6f240edf0d
commit 7982f3d890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 15 deletions

View File

@ -22,8 +22,9 @@ export const ButtonPrimary = styled(Button)`
} }
&:disabled { &:disabled {
background: ${Colors.GrayDisabledDark}; background: ${Colors.GrayDisabledLight};
color: ${Colors.GreyTextDisabled}; color: ${Colors.GreyTextDisabled};
filter: grayscale(1);
} }
` `
export const ButtonSecondary = styled(Button)` export const ButtonSecondary = styled(Button)`

View File

@ -223,7 +223,7 @@ export const CardVoteWrap = styled.div`
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1); box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
border-radius: 6px 0px 0px 6px; border-radius: 6px 0px 0px 6px;
` `
const CardInfoBlock = styled.div` export const CardInfoBlock = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;

View File

@ -12,6 +12,7 @@ import { useContractFunction } from '@usedapp/core'
import { useContracts } from '../../hooks/useContracts' import { useContracts } from '../../hooks/useContracts'
import { CommunityDetail } from '../../models/community' import { CommunityDetail } from '../../models/community'
import { CommunitySkeleton } from '../skeleton/CommunitySkeleton'
interface ProposeModalProps { interface ProposeModalProps {
availableAmount: number availableAmount: number
@ -26,7 +27,7 @@ export function ProposeModal({
setCommunityFound, setCommunityFound,
communityFound, communityFound,
}: ProposeModalProps) { }: ProposeModalProps) {
const [proposingAmount, setProposingAmount] = useState(availableAmount) const [proposingAmount, setProposingAmount] = useState(0)
const [publicKey, setPublicKey] = useState('') const [publicKey, setPublicKey] = useState('')
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const disabled = proposingAmount === 0 const disabled = proposingAmount === 0
@ -58,7 +59,7 @@ export function ProposeModal({
</CommunityKeyLabel> </CommunityKeyLabel>
{publicKey && communityFound && ( {publicKey && communityFound && (
<div> <ProposingData>
<CardCommunity community={communityFound} /> <CardCommunity community={communityFound} />
{communityFound.validForAddition ? ( {communityFound.validForAddition ? (
<VoteProposeWrap> <VoteProposeWrap>
@ -77,16 +78,30 @@ export function ProposeModal({
/> />
</WarningWrap> </WarningWrap>
)} )}
</div> </ProposingData>
)} )}
{!communityFound && ( {!communityFound && !publicKey && (
<ProposingInfo> <ProposingInfo>
<span></span> <span></span>
<InfoText>To propose a community, it must have at least 42 members and have a ENS domain.</InfoText> <InfoText>To propose a community, it must have at least 42 members and have a ENS domain.</InfoText>
</ProposingInfo> </ProposingInfo>
)} )}
{loading && publicKey && <div>LOADING</div>}
{loading && publicKey && (
<ProposingData>
<CommunitySkeleton />
<VoteProposeWrap>
<VotePropose
availableAmount={availableAmount}
setProposingAmount={setProposingAmount}
proposingAmount={proposingAmount}
disabled={disabled}
/>
</VoteProposeWrap>
</ProposingData>
)}
{communityFound && !communityFound.validForAddition ? ( {communityFound && !communityFound.validForAddition ? (
<ConfirmBtn <ConfirmBtn
onClick={() => { onClick={() => {
@ -98,7 +113,7 @@ export function ProposeModal({
</ConfirmBtn> </ConfirmBtn>
) : ( ) : (
<ProposingBtn <ProposingBtn
disabled={!communityFound} disabled={!communityFound || disabled}
onClick={() => { onClick={() => {
send(1, publicKey) send(1, publicKey)
setShowConfirmModal(true) setShowConfirmModal(true)
@ -134,6 +149,10 @@ const VoteProposeWrap = styled.div`
margin-top: 32px; margin-top: 32px;
` `
const ProposingData = styled.div`
width: 100%;
`
const ProposingInfo = styled.div` const ProposingInfo = styled.div`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -1,13 +1,15 @@
import React from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { Card, CardVoteBlock, CardVoteWrap } from '../Card' import { Card, CardCommunityWrap, CardVoteBlock, CardVoteWrap } from '../Card'
import { CommunitySkeleton } from '../skeleton/CommunitySkeleton' import { CommunitySkeleton } from '../skeleton/CommunitySkeleton'
import { Skeleton } from '../skeleton/Skeleton' import { Skeleton } from '../skeleton/Skeleton'
export const DirectoryCardSkeleton = () => { export const DirectoryCardSkeleton = () => {
return ( return (
<Card> <Card>
<CommunitySkeleton /> <CardCommunityWrap>
<CommunitySkeleton />
</CardCommunityWrap>
<CardVoteWrap> <CardVoteWrap>
<CardVoteBlock> <CardVoteBlock>
<CardHeader> <CardHeader>

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { CardCommunityWrap, CardLinks } from '../Card' import { CardInfoBlock, CardLinks } from '../Card'
import { LinkExternal, LinkInternal } from '../Link' import { LinkExternal, LinkInternal } from '../Link'
import { Skeleton } from '../skeleton/Skeleton' import { Skeleton } from '../skeleton/Skeleton'
import { TagsSkeletonList } from '../skeleton/TagSkeleton' import { TagsSkeletonList } from '../skeleton/TagSkeleton'
@ -8,7 +8,8 @@ import { TextBlock } from '../skeleton/TextSkeleton'
export const CommunitySkeleton = () => { export const CommunitySkeleton = () => {
return ( return (
<CardCommunityWrap> <CardInfoBlock>
{' '}
<CardRow> <CardRow>
<AvatarSkeleton /> <AvatarSkeleton />
<CardContent> <CardContent>
@ -22,12 +23,13 @@ export const CommunitySkeleton = () => {
<StyledExternalLink>Etherscan</StyledExternalLink> <StyledExternalLink>Etherscan</StyledExternalLink>
<StyledInternalink>Voting history </StyledInternalink> <StyledInternalink>Voting history </StyledInternalink>
</CardLinks> </CardLinks>
</CardCommunityWrap> </CardInfoBlock>
) )
} }
const CardRow = styled.div` const CardRow = styled.div`
display: flex; display: flex;
width: 100%;
margin-bottom: 48px; margin-bottom: 48px;
` `

View File

@ -1,13 +1,16 @@
import React from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { Card, CardVoteBlock, CardVoteWrap } from '../Card' import { Card, CardCommunityWrap, CardVoteBlock, CardVoteWrap } from '../Card'
import { CommunitySkeleton } from '../skeleton/CommunitySkeleton' import { CommunitySkeleton } from '../skeleton/CommunitySkeleton'
import { Skeleton } from '../skeleton/Skeleton' import { Skeleton } from '../skeleton/Skeleton'
export const VotingCardSkeleton = () => { export const VotingCardSkeleton = () => {
return ( return (
<Card> <Card>
<CommunitySkeleton /> <CardCommunityWrap>
<CommunitySkeleton />
</CardCommunityWrap>
<CardVoteWrap> <CardVoteWrap>
<CardVoteBlock> <CardVoteBlock>
<CardHeader> <CardHeader>