Add notification (#60)

This commit is contained in:
Maria Rushkova 2021-09-13 12:52:49 +02:00 committed by GitHub
parent f0d8d6b74e
commit e492997c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,63 @@
import React, { useState } from 'react'
import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes'
import { CloseButton } from '@status-waku-voting/react-components/dist/esm/src/components/misc/Buttons'
import styled from 'styled-components'
import { NotificationLink } from './ViewLink'
interface NotificationItemProps {
text: string
address: string
}
export function NotificationItem({ address, text }: NotificationItemProps) {
const [show, setShow] = useState(true)
if (show) {
return (
<NotificationBlock>
<NotificationContent>
<NotificationText>{text}</NotificationText>
<NotificationLink address={address} />
</NotificationContent>
<CloseButton theme={blueTheme} onClick={() => setShow(false)} />
</NotificationBlock>
)
}
return null
}
const NotificationBlock = styled.div`
display: flex;
align-items: center;
background: #fff;
padding: 16px;
width: 252px;
border-radius: 16px;
filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.15));
position: absolute;
top: 120px;
right: 24px;
z-index: 9999;
@media (max-width: 768px) {
right: 32px;
}
@media (max-width: 600px) {
top: 74px;
right: 16px;
}
`
const NotificationContent = styled.div`
display: flex;
flex-direction: column;
align-items: flex-end;
`
const NotificationText = styled.p`
font-size: 12px;
line-height: 16px;
letter-spacing: 0.1px;
margin: 0;
margin-bottom: 16px;
`

View File

@ -4,6 +4,7 @@ import { ProposalHeader } from './ProposalHeader'
import { blueTheme } from '@status-waku-voting/react-components/dist/esm/src/style/themes'
import { ProposalList } from './ProposalList'
import { VotingEmpty } from './VotingEmpty'
import { NotificationItem } from './NotificationItem'
export function Proposal() {
return (
@ -12,6 +13,7 @@ export function Proposal() {
<ProposalHeader theme={blueTheme} />
<ProposalList theme={blueTheme} />
{/* <VotingEmpty theme={blueTheme} /> */}
<NotificationItem text={'Proposal you finalized will be settled after 10 confirmations.'} address={'#'} />
</ProposalWrapper>
)
}

View File

@ -38,3 +38,15 @@ export const Link = styled.a`
background-size: contain;
}
`
interface NotificationLinkProps {
address: string
}
export function NotificationLink({ address }: NotificationLinkProps) {
return <LinkNotification href={address}>View on Etherscan</LinkNotification>
}
const LinkNotification = styled(Link)`
margin-right: 32px;
font-size: 12px;
`

View File

@ -13,6 +13,7 @@ export interface VoteProposingProps {
export function VotePropose({ availableAmount, proposingAmount, setProposingAmount }: VoteProposingProps) {
const [displayAmount, setDisplayAmount] = useState(addCommas(proposingAmount) + ' ABC')
const disabled = availableAmount === 0
let step = 10 ** (Math.floor(Math.log10(availableAmount)) - 2)
if (availableAmount < 100) {

View File

@ -166,4 +166,5 @@ export const CloseButton = styled.button<CloseProps>`
background-image: url(${({ theme }) => (theme === orangeTheme ? closeButton : blueCloseButton)});
background-color: transparent;
border: none;
flex-shrink: 0;
`