From 2a2882a599855e6e756b685b330ac26f77627bd1 Mon Sep 17 00:00:00 2001 From: Ramiro Vazquez Date: Thu, 23 Apr 2020 15:34:15 -0300 Subject: [PATCH] add copy link button to home screen --- src/components/Home/HomeDetail.tsx | 203 ++++++++++-------- .../common/StrippedTableWrapper/index.tsx | 8 + 2 files changed, 123 insertions(+), 88 deletions(-) diff --git a/src/components/Home/HomeDetail.tsx b/src/components/Home/HomeDetail.tsx index 3783d8d..211df28 100644 --- a/src/components/Home/HomeDetail.tsx +++ b/src/components/Home/HomeDetail.tsx @@ -52,6 +52,7 @@ import { getRecentPolls, } from './helpers' import styled from 'styled-components' +import LinkableComponent from '../common/LinkableComponent' const CardStyled = styled(Card)` height: ${props => props.theme.defaultCardHeight}; @@ -547,20 +548,28 @@ function HomeDetail(props: Props) { <> System Statistics - - {stakedMkr.length === 0 ? : } - - - - + + + {stakedMkr.length === 0 ? : } + + + + + + + - - {polls.length === 0 ? : } - - - - + + + {polls.length === 0 ? : } + + + + + + + Voter Behaviour {/* @@ -582,94 +591,112 @@ function HomeDetail(props: Props) { */} - - {executivesResponsiveness.length === 0 ? ( - - ) : ( - - )} - - - - {pollsResponsiveness.length === 0 ? ( + + + {executivesResponsiveness.length === 0 ? ( ) : ( - + )} - - {topVoters.length === 0 ? ( - - ) : ( - - )} - + + + + + {pollsResponsiveness.length === 0 ? ( + + ) : ( + + )} + + + + + {topVoters.length === 0 ? ( + + ) : ( + + )} + + Executives - - - - - - + + + + + + + + + + - - - - - - + + + + + + + + + + Polls - - {polls.length === 0 || !polls[0].participation ? ( - - ) : ( - - )} - - - {polls.length === 0 ? ( - - ) : ( - - )} - + + + {polls.length === 0 || !polls[0].participation ? ( + + ) : ( + + )} + + + + + {polls.length === 0 ? ( + + ) : ( + + )} + + {isModalOpen && ( setModalOpen(false)}> diff --git a/src/components/common/StrippedTableWrapper/index.tsx b/src/components/common/StrippedTableWrapper/index.tsx index 8d9e6e1..f03ba12 100644 --- a/src/components/common/StrippedTableWrapper/index.tsx +++ b/src/components/common/StrippedTableWrapper/index.tsx @@ -6,6 +6,7 @@ import { StrippedRowsContainer, CardTitle, ViewAll, Modal, InfoIcon, CloseIcon, import { getIconContainer } from '../../../utils' import { IconContainer } from '../styled' import CopyLink from '../LinkableComponent/CopyLink' +import { LinkableContext } from '../LinkableComponent' const TitleWrapper = styled.div` flex-shrink: 0; @@ -58,6 +59,13 @@ type Props = { function StrippedTableWrapper(props: Props) { const { handleModal, children, content, isModalOpen, info, links, markdown } = props const [isInfoModalOpen, setInfoModalOpen] = useState(false) + const linkable = React.useContext(LinkableContext) + + React.useEffect(() => { + if (linkable.active) { + linkable.onInitCallback(handleModal) + } + }, [linkable, handleModal]) return ( <>