Hide header (#67)

This commit is contained in:
Maria Rushkova 2021-09-14 15:30:26 +02:00 committed by GitHub
parent 7d97abdf82
commit 283edd8613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 21 deletions

View File

@ -1,21 +1,37 @@
import React from 'react' import React, { useEffect, useState } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { ProposalHeader } from './ProposalHeader' import { ProposalHeader } from './ProposalHeader'
import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes' import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes'
import { ProposalList } from './ProposalList' import { ProposalList } from './ProposalList'
import { NotificationItem } from './NotificationItem' import { NotificationItem } from './NotificationItem'
import { WakuVoting } from '@status-waku-voting/core' import { WakuVoting } from '@status-waku-voting/core'
import { VotingEmpty } from './VotingEmpty'
type ProposalProps = { type ProposalProps = {
wakuVoting: WakuVoting wakuVoting: WakuVoting
} }
export function Proposal({ wakuVoting }: ProposalProps) { export function Proposal({ wakuVoting }: ProposalProps) {
const [votes, setVotes] = useState<any[]>([])
useEffect(() => {
const interval = setInterval(async () => {
setVotes(await wakuVoting.getVotes())
}, 10000)
return () => clearInterval(interval)
}, [])
return ( return (
<ProposalWrapper> <ProposalWrapper>
<ProposalHeader theme={blueTheme} wakuVoting={wakuVoting} /> {votes && votes?.length === 0 ? (
<ProposalList theme={blueTheme} wakuVoting={wakuVoting} /> <VotingEmpty wakuVoting={wakuVoting} theme={blueTheme} />
{/* <VotingEmpty theme={blueTheme} /> */} ) : (
<ProposalVotesWrapper>
<ProposalHeader theme={blueTheme} wakuVoting={wakuVoting} />
<ProposalList theme={blueTheme} wakuVoting={wakuVoting} votes={votes} />
</ProposalVotesWrapper>
)}
<NotificationItem text={'Proposal you finalized will be settled after 10 confirmations.'} address={'#'} /> <NotificationItem text={'Proposal you finalized will be settled after 10 confirmations.'} address={'#'} />
</ProposalWrapper> </ProposalWrapper>
) )
@ -31,3 +47,7 @@ const ProposalWrapper = styled.div`
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
` `
export const ProposalVotesWrapper = styled(ProposalWrapper)`
width: 100%;
padding: 0;
`

View File

@ -1,30 +1,20 @@
import React, { useEffect, useState } from 'react' import React from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { Theme } from '@status-waku-voting/react-components' import { Theme } from '@status-waku-voting/react-components'
import { ProposalCard } from './ProposalCard' import { ProposalCard } from './ProposalCard'
import { WakuVoting } from '@status-waku-voting/core' import { WakuVoting } from '@status-waku-voting/core'
import { VotingEmpty } from './VotingEmpty'
type ProposalListProps = { type ProposalListProps = {
theme: Theme theme: Theme
wakuVoting: WakuVoting wakuVoting: WakuVoting
votes: any[]
} }
export function ProposalList({ theme, wakuVoting }: ProposalListProps) { export function ProposalList({ theme, wakuVoting, votes }: ProposalListProps) {
const [votes, setVotes] = useState<any[]>([])
useEffect(() => {
const interval = setInterval(async () => {
setVotes(await wakuVoting.getVotes())
}, 10000)
return () => clearInterval(interval)
}, [])
return ( return (
<List> <List>
{votes.map((vote, idx) => { {votes.map((vote, idx) => {
return <ProposalCard heading={vote[2]} text={vote[3]} address={'#'} theme={theme} key={idx} id={idx} /> return <ProposalCard heading={vote[2]} text={vote[3]} address={'#'} theme={theme} key={idx} id={idx} />
})} })}
{votes && votes?.length === 0 && <VotingEmpty wakuVoting={wakuVoting} theme={theme} />}
</List> </List>
) )
} }

View File

@ -60,6 +60,7 @@ const Header = styled.div`
padding: 12px 16px 0; padding: 12px 16px 0;
width: 100%; width: 100%;
background: #f8faff; background: #f8faff;
z-index: 10;
} }
` `

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { useEffect, useState } from 'react'
import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes' import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes'
import { ProposalList } from '../ProposalList' import { ProposalList } from '../ProposalList'
import { VotingEmpty } from '../VotingEmpty' import { VotingEmpty } from '../VotingEmpty'
@ -6,17 +6,32 @@ import { NotificationItem } from '../NotificationItem'
import { ProposalHeaderMobile } from './ProposalHeaderMobile' import { ProposalHeaderMobile } from './ProposalHeaderMobile'
import styled from 'styled-components' import styled from 'styled-components'
import { WakuVoting } from '@status-waku-voting/core' import { WakuVoting } from '@status-waku-voting/core'
import { ProposalVotesWrapper } from '../Proposal'
type ProposalMainMobileProps = { type ProposalMainMobileProps = {
wakuVoting: WakuVoting wakuVoting: WakuVoting
} }
export function ProposalMainMobile({ wakuVoting }: ProposalMainMobileProps) { export function ProposalMainMobile({ wakuVoting }: ProposalMainMobileProps) {
const [votes, setVotes] = useState<any[]>([])
useEffect(() => {
const interval = setInterval(async () => {
setVotes(await wakuVoting.getVotes())
}, 10000)
return () => clearInterval(interval)
}, [])
return ( return (
<ProposalWrapper> <ProposalWrapper>
<ProposalHeaderMobile theme={blueTheme} /> {votes && votes?.length === 0 ? (
<ProposalList theme={blueTheme} wakuVoting={wakuVoting} /> <VotingEmpty wakuVoting={wakuVoting} theme={blueTheme} />
{/* <VotingEmpty theme={blueTheme} /> */} ) : (
<ProposalVotesWrapper>
<ProposalHeaderMobile theme={blueTheme} />
<ProposalList theme={blueTheme} wakuVoting={wakuVoting} votes={votes} />
</ProposalVotesWrapper>
)}
<NotificationItem text={'Proposal you finalized will be settled after 10 confirmations.'} address={'#'} /> <NotificationItem text={'Proposal you finalized will be settled after 10 confirmations.'} address={'#'} />
</ProposalWrapper> </ProposalWrapper>
) )