|
| 1 | +import React, { ReactNode, useEffect } from 'react'; |
| 2 | +import { observer } from 'mobx-react-lite'; |
| 3 | +import styled from '@emotion/styled'; |
| 4 | +import { ArrowLeft, Button, Column, Container, Row, Close } from 'components/base'; |
| 5 | +import { DisplayLarge, Header } from './v2/Text'; |
| 6 | + |
| 7 | +const Styled = { |
| 8 | + Wrapper: styled.div` |
| 9 | + h4 { |
| 10 | + color: ${props => props.theme.colors.offWhite}; |
| 11 | + } |
| 12 | + `, |
| 13 | + BackLink: styled(Button)` |
| 14 | + display: inline-block; |
| 15 | + position: absolute; |
| 16 | + top: 30px; |
| 17 | + right: 0px; |
| 18 | + left: auto; |
| 19 | + z-index: 10; |
| 20 | +
|
| 21 | + @media (${props => props.theme.breakpoints.m}) { |
| 22 | + top: 30px; |
| 23 | + right: 0px; |
| 24 | + } |
| 25 | + `, |
| 26 | + Title: styled(DisplayLarge)` |
| 27 | + font-weight: ${props => props.theme.fonts.open.bold}; |
| 28 | + margin-bottom: 16px; |
| 29 | + `, |
| 30 | + Content: styled.div``, |
| 31 | +}; |
| 32 | + |
| 33 | +interface Props { |
| 34 | + title: string; |
| 35 | + description: ReactNode; |
| 36 | + onBackClick?: () => void; |
| 37 | +} |
| 38 | + |
| 39 | +const OverlayFormWrap: React.FC<Props> = ({ |
| 40 | + title, |
| 41 | + description, |
| 42 | + onBackClick, |
| 43 | + children, |
| 44 | +}) => { |
| 45 | + // scroll to the top of the screen when this comp is mounted |
| 46 | + useEffect(() => window.scrollTo(0, 0), []); |
| 47 | + |
| 48 | + const { Wrapper, BackLink, Title, Content } = Styled; |
| 49 | + return ( |
| 50 | + <Wrapper> |
| 51 | + {onBackClick && ( |
| 52 | + <BackLink onClick={onBackClick} ghost borderless> |
| 53 | + <Close /> |
| 54 | + </BackLink> |
| 55 | + )} |
| 56 | + <Container> |
| 57 | + <Row> |
| 58 | + <Column className="col-md-8 offset-md-2"> |
| 59 | + <Title bold>{title}</Title> |
| 60 | + <Header muted space={32}> |
| 61 | + {description} |
| 62 | + </Header> |
| 63 | + <Content>{children}</Content> |
| 64 | + </Column> |
| 65 | + </Row> |
| 66 | + </Container> |
| 67 | + </Wrapper> |
| 68 | + ); |
| 69 | +}; |
| 70 | + |
| 71 | +export default observer(OverlayFormWrap); |
0 commit comments