diff --git a/src/components/MainView.js b/src/components/MainView.js index bc2db9d..ea03985 100644 --- a/src/components/MainView.js +++ b/src/components/MainView.js @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ import React from 'react' import { animated, useTransition } from 'react-spring' import { GU, useTheme, useViewport } from '@aragon/ui' @@ -30,7 +29,6 @@ function MainView({ children }) { position: relative; z-index: 1; width: 100%; - min-height: 100vh; background: ${theme.background}; `} > @@ -47,7 +45,6 @@ function MainView({ children }) {
{children} diff --git a/src/components/ProposalsView.js b/src/components/ProposalsView.js index cc7ea5f..4bed2c0 100644 --- a/src/components/ProposalsView.js +++ b/src/components/ProposalsView.js @@ -1,5 +1,6 @@ import React, { useState, useCallback, useMemo } from 'react' import { useHistory } from 'react-router-dom' +import { useTransition, animated } from 'react-spring' import styled from 'styled-components' import { useViewport } from 'use-viewport' import { @@ -13,9 +14,13 @@ import { GU, RADIUS, } from '@aragon/ui' + import { ConvictionBar } from './ConvictionVisuals' import IdentityBadge from './IdentityBadge' import { Amount } from '../screens/ProposalDetail' + +import { useAppState } from '../providers/AppState' + import { ZERO_ADDR } from '../constants' const PROPOSALS_PER_PAGE = 10 @@ -25,9 +30,21 @@ function ProposalsView({ proposals, requestToken }) { const theme = useTheme() const history = useHistory() const { below } = useViewport() + const { isLoading } = useAppState() const compactMode = below(1400) + const loadingSwapTransitions = useTransition(isLoading, null, { + config: { mass: 1, tension: 200, friction: 20 }, + from: { opacity: 0, transform: `translate3d(0, ${0.5 * GU}px, 0)` }, + enter: { opacity: 1, transform: `translate3d(0, 0, 0)` }, + leave: { + opacity: 0, + position: 'absolute', + transform: `translate3d(0, -${0.5 * GU}px, 0)`, + }, + }) + const handleSelectProposal = useCallback( id => { history.push(`/proposal/${id}`) @@ -51,98 +68,109 @@ function ProposalsView({ proposals, requestToken }) { return (
- {shownProposals.map(proposal => ( - handleSelectProposal(proposal.id)} - focusRingRadius={RADIUS} - css={` - text-align: left; - word-wrap: break-word; - text-overflow: ellipsis; - `} - > -
+ !loading && ( + + {shownProposals.map(proposal => ( + handleSelectProposal(proposal.id)} + focusRingRadius={RADIUS} + css={` + text-align: left; + word-wrap: break-word; + text-overflow: ellipsis; + `} + > +
- - - - {proposal.beneficiary === ZERO_ADDR ? ( - - ) : ( - - )} -
- {proposal.status.toLowerCase() === 'executed' ? ( - - ) : proposal.status.toLowerCase() !== 'cancelled' ? ( - -

+ + + + {proposal.beneficiary === ZERO_ADDR ? ( + + ) : ( + + )} +

+ {proposal.status.toLowerCase() === 'executed' ? ( + + ) : proposal.status.toLowerCase() !== 'cancelled' ? ( + +

+ +

+
+ ) : ( + + )} +
+
+

- -

- - ) : ( - - )} -

-
-

- Conviction Progress -

- -
- ))} + Conviction Progress + + + + ))} + + ) + )}
) diff --git a/src/components/ScrollTop.js b/src/components/ScrollTop.js index e4970ca..dcc447d 100644 --- a/src/components/ScrollTop.js +++ b/src/components/ScrollTop.js @@ -5,8 +5,7 @@ export default function ScrollToTop() { const { pathname } = useLocation() useEffect(() => { - document.querySelector('body').scrollY = 0 - window.scrollY = 0 + window.scrollTo(0, 0) }, [pathname]) return null diff --git a/src/screens/ProposalDetail.js b/src/screens/ProposalDetail.js index 40d8fa9..659ecb8 100644 --- a/src/screens/ProposalDetail.js +++ b/src/screens/ProposalDetail.js @@ -1,4 +1,5 @@ import React, { useCallback, useMemo } from 'react' +import { useTransition, animated } from 'react-spring' import { useViewport } from 'use-viewport' import { BackButton, @@ -78,6 +79,16 @@ function ProposalDetail({ const { below } = useViewport() const compactMode = below(1400) + const loadingSwapTransitions = useTransition(proposal, null, { + config: { mass: 1, tension: 200, friction: 20 }, + from: { opacity: 0, transform: `translate3d(0, ${0.5 * GU}px, 0)` }, + enter: { opacity: 1, transform: `translate3d(0, 0, 0)` }, + leave: { + opacity: 0, + position: 'absolute', + transform: `translate3d(0, -${0.5 * GU}px, 0)`, + }, + }) const { currentConviction, @@ -143,7 +154,11 @@ function ProposalDetail({ const signalingProposal = addressesEqual(beneficiary, ZERO_ADDR) return ( -
+
- -
-
+ loading && ( + + +
+
-

- {name} -

-
- {!signalingProposal && status.toLowerCase() !== 'cancelled' && ( - - )} -
- {!signalingProposal && proposalState !== EXECUTED && ( -

+

+ {name} +

+
+ {!signalingProposal && + status.toLowerCase() !== 'cancelled' && ( + + )} +
+ {!signalingProposal && proposalState !== EXECUTED && ( +

- This proposal{' '} - {status.toLowerCase() === 'cancelled' || - status.toLowerCase() === 'executed' - ? 'was' - : 'is'}{' '} - requesting{' '} - {formatTokenAmount(requestedAmount, requestToken.decimals)} ANT - out of {formatTokenAmount(vaultBalance, requestToken.decimals)}{' '} - ANT currently in the common pool. -

- )} -
+ This proposal{' '} + {status.toLowerCase() === 'cancelled' || + status.toLowerCase() === 'executed' + ? 'was' + : 'is'}{' '} + requesting{' '} + {formatTokenAmount( + requestedAmount, + requestToken.decimals + )}{' '} + ANT out of{' '} + {formatTokenAmount(vaultBalance, requestToken.decimals)}{' '} + ANT currently in the common pool. +

+ )} +
- {beneficiary === ZERO_ADDR && }{' '} - {status !== 'Cancelled' ? ( - requestToken && ( - - ) - ) : ( - - )} - - } - /> - {requestToken && !signalingProposal && ( - - } - /> - )} - {!signalingProposal && - proposalState !== UNABLE_TO_PASS && - proposalState !== EXECUTED && ( -
- -
- )} - - Read more - - ) : ( - - No link provided - - ) - } - /> -
- {status.toLowerCase() !== 'executed' && ( - <> - }{' '} + {status !== 'Cancelled' ? ( + requestToken && ( + + ) + ) : ( + + )} + + } + /> + {requestToken && !signalingProposal && ( + + } + /> + )} + {!signalingProposal && + proposalState !== UNABLE_TO_PASS && + proposalState !== EXECUTED && ( +
+ +
+ )} + + Read more + + ) : ( + + No link provided + + ) + } + /> +
+ {status.toLowerCase() !== 'executed' && ( + <> + + } + /> + + )} + - } - /> - - )} - -
-
+
+
+ + ) + )}