|
| 1 | +import React, { Dispatch, SetStateAction } from "react"; |
| 2 | +import styled, { css } from "styled-components"; |
| 3 | +import { landscapeStyle } from "styles/landscapeStyle"; |
| 4 | +import { CompactPagination } from "@kleros/ui-components-library"; |
| 5 | +import { Overlay } from "components/Overlay"; |
| 6 | +import BookOpenIcon from "tsx:assets/svgs/icons/book-open.svg"; |
| 7 | + |
| 8 | +const Container = styled.div` |
| 9 | + display: flex; |
| 10 | + margin: 0 auto; |
| 11 | + width: auto; |
| 12 | + z-index: 10; |
| 13 | + position: fixed; |
| 14 | + width: 82vw; |
| 15 | + flex-direction: column; |
| 16 | +
|
| 17 | + top: 50%; |
| 18 | + left: 50%; |
| 19 | + transform: translate(-50%, -50%); |
| 20 | + max-height: 80vh; |
| 21 | + overflow-y: auto; |
| 22 | +
|
| 23 | + ${landscapeStyle( |
| 24 | + () => css` |
| 25 | + overflow-y: hidden; |
| 26 | + width: calc(700px + (900 - 700) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 27 | + flex-direction: row; |
| 28 | + height: 500px; |
| 29 | + ` |
| 30 | + )} |
| 31 | +`; |
| 32 | + |
| 33 | +const LeftContainer = styled.div` |
| 34 | + display: grid; |
| 35 | + grid-template-rows: auto 1fr auto; |
| 36 | + width: 82vw; |
| 37 | + min-height: 356px; |
| 38 | + padding: calc(24px + (32 - 24) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 39 | + background-color: ${({ theme }) => theme.whiteBackground}; |
| 40 | + border-top-left-radius: 3px; |
| 41 | + border-bottom-left-radius: 3px; |
| 42 | +
|
| 43 | + ${landscapeStyle( |
| 44 | + () => css` |
| 45 | + overflow-y: hidden; |
| 46 | + width: calc(350px + (450 - 350) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 47 | + height: 500px; |
| 48 | + min-height: auto; |
| 49 | + ` |
| 50 | + )} |
| 51 | +`; |
| 52 | + |
| 53 | +const HowItWorks = styled.div` |
| 54 | + display: flex; |
| 55 | + align-items: center; |
| 56 | + gap: 8px; |
| 57 | + margin-bottom: calc(32px + (64 - 32) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 58 | +
|
| 59 | + label { |
| 60 | + color: ${({ theme }) => theme.secondaryPurple}; |
| 61 | + } |
| 62 | +`; |
| 63 | + |
| 64 | +const StyledCompactPagination = styled(CompactPagination)` |
| 65 | + align-self: end; |
| 66 | + justify-self: end; |
| 67 | +`; |
| 68 | + |
| 69 | +const Close = styled.label` |
| 70 | + position: absolute; |
| 71 | + top: calc(24px + (32 - 24) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 72 | + right: 17px; |
| 73 | + display: flex; |
| 74 | + align-items: flex-end; |
| 75 | + justify-content: flex-end; |
| 76 | + cursor: pointer; |
| 77 | +
|
| 78 | + color: ${({ theme }) => theme.primaryBlue}; |
| 79 | +
|
| 80 | + ${landscapeStyle( |
| 81 | + () => css` |
| 82 | + z-index: 11; |
| 83 | + ` |
| 84 | + )} |
| 85 | +`; |
| 86 | + |
| 87 | +const RightContainer = styled.div` |
| 88 | + width: 82vw; |
| 89 | + position: relative; |
| 90 | + display: flex; |
| 91 | + flex-direction: column; |
| 92 | + align-items: center; |
| 93 | + justify-content: center; |
| 94 | + padding: calc(24px + (32 - 24) * (min(max(100vw, 375px), 1250px) - 375px) / 875) 17px; |
| 95 | + background-color: ${({ theme }) => theme.mediumBlue}; |
| 96 | + border-top-right-radius: 3px; |
| 97 | + border-bottom-right-radius: 3px; |
| 98 | + height: 800px; |
| 99 | +
|
| 100 | + ${landscapeStyle( |
| 101 | + () => css` |
| 102 | + overflow-y: hidden; |
| 103 | + width: calc(350px + (450 - 350) * (min(max(100vw, 375px), 1250px) - 375px) / 875); |
| 104 | + height: 500px; |
| 105 | + ` |
| 106 | + )} |
| 107 | +`; |
| 108 | + |
| 109 | +interface ITemplate { |
| 110 | + onClose: () => void; |
| 111 | + LeftContent: React.ReactNode; |
| 112 | + RightContent: React.ReactNode; |
| 113 | + currentPage: number; |
| 114 | + setCurrentPage: Dispatch<SetStateAction<number>>; |
| 115 | + numPages: number; |
| 116 | +} |
| 117 | + |
| 118 | +const Template: React.FC<ITemplate> = ({ |
| 119 | + onClose, |
| 120 | + LeftContent, |
| 121 | + RightContent, |
| 122 | + currentPage, |
| 123 | + setCurrentPage, |
| 124 | + numPages, |
| 125 | +}) => { |
| 126 | + return ( |
| 127 | + <> |
| 128 | + <Overlay /> |
| 129 | + <Container> |
| 130 | + <LeftContainer> |
| 131 | + <HowItWorks> |
| 132 | + <BookOpenIcon /> |
| 133 | + <label> How it works </label> |
| 134 | + </HowItWorks> |
| 135 | + <Close onClick={onClose}>Close</Close> |
| 136 | + {LeftContent} |
| 137 | + <StyledCompactPagination |
| 138 | + currentPage={currentPage} |
| 139 | + callback={setCurrentPage} |
| 140 | + numPages={numPages} |
| 141 | + label={`${currentPage}/${numPages}`} |
| 142 | + /> |
| 143 | + </LeftContainer> |
| 144 | + <RightContainer>{RightContent}</RightContainer> |
| 145 | + </Container> |
| 146 | + </> |
| 147 | + ); |
| 148 | +}; |
| 149 | + |
| 150 | +export default Template; |
0 commit comments