|
| 1 | +import { useMemo, useState } from 'react'; |
| 2 | + |
| 3 | +import { makeStyles } from '../styles'; |
| 4 | +import { alpha, darken, Theme } from '@mui/material'; |
| 5 | + |
| 6 | +import { Center, PortalView, RevealView, Countdown, openBlank, createLsManager, Subject, useOnce, copyToClipboard, useSnack } from 'react-declarative'; |
| 7 | + |
| 8 | +import Typography from '@mui/material/Typography'; |
| 9 | +import Button from '@mui/material/Button'; |
| 10 | +import Paper from '@mui/material/Paper'; |
| 11 | +import Stack from '@mui/material/Stack'; |
| 12 | +import Box from '@mui/material/Box'; |
| 13 | + |
| 14 | +const LOGO_HEIGHT = 225; |
| 15 | + |
| 16 | +const useStyles = makeStyles()((theme) => ({ |
| 17 | + root: { |
| 18 | + position: 'fixed', |
| 19 | + top: 0, |
| 20 | + left: 0, |
| 21 | + right: 0, |
| 22 | + bottom: 0, |
| 23 | + zIndex: 9999, |
| 24 | + background: alpha('#999999', 0.2), |
| 25 | + backdropFilter: 'saturate(180%) blur(20px)', |
| 26 | + height: '100%', |
| 27 | + width: '100%', |
| 28 | + display: 'flex', |
| 29 | + alignItems: 'center', |
| 30 | + justifyContent: 'center', |
| 31 | + flexDirection: 'column', |
| 32 | + gap: 20, |
| 33 | + padding: 15, |
| 34 | + }, |
| 35 | + container: { |
| 36 | + position: "relative", |
| 37 | + marginBottom: '3.5vw', |
| 38 | + overflow: "hidden", |
| 39 | + maxWidth: 375, |
| 40 | + padding: 15, |
| 41 | + }, |
| 42 | + reveal: { |
| 43 | + width: 'unset !important', |
| 44 | + }, |
| 45 | + avatarRoot: { |
| 46 | + position: "absolute", |
| 47 | + overflow: "hidden", |
| 48 | + display: "flex", |
| 49 | + alignItems: "center", |
| 50 | + justifyContent: "center", |
| 51 | + top: 0, |
| 52 | + left: 0, |
| 53 | + right: 0, |
| 54 | + width: "100%", |
| 55 | + height: LOGO_HEIGHT, |
| 56 | + background: darken(theme.palette.background.paper, 0.12), |
| 57 | + }, |
| 58 | + avatarAdjust: { |
| 59 | + paddingBottom: LOGO_HEIGHT, |
| 60 | + }, |
| 61 | +})); |
| 62 | + |
| 63 | +const openSubject = new Subject<void>(); |
| 64 | + |
| 65 | +export const CommercialModal = () => { |
| 66 | + const { classes } = useStyles(); |
| 67 | + |
| 68 | + const [opened, setOpened] = useState(false); |
| 69 | + const notify = useSnack(); |
| 70 | + |
| 71 | + useOnce(() => openSubject.subscribe(() => setOpened(true))); |
| 72 | + |
| 73 | + const handleSubmit = () => { |
| 74 | + copyToClipboard("[email protected]"); |
| 75 | + notify("Email copied to clipboard"); |
| 76 | + openBlank("mailto:[email protected]"); |
| 77 | + setOpened(false); |
| 78 | + }; |
| 79 | + |
| 80 | + const renderLogo = () => ( |
| 81 | + <> |
| 82 | + <Box className={classes.avatarRoot}> |
| 83 | + <Stack alignItems="center" gap={1}> |
| 84 | + <Center> |
| 85 | + <Box |
| 86 | + component="img" |
| 87 | + src="/peter.png" |
| 88 | + loading='lazy' |
| 89 | + sx={{ width: 128, height: 128, borderRadius: '50%' }} |
| 90 | + /> |
| 91 | + </Center> |
| 92 | + <Typography variant="h6">Peter Tripolsky</Typography> |
| 93 | + <Typography |
| 94 | + variant="body2" |
| 95 | + textAlign="center" |
| 96 | + sx={{ color: (theme: Theme) => theme.palette.text.secondary }} |
| 97 | + > |
| 98 | + The Creator of <b>react-declarative</b> |
| 99 | + </Typography> |
| 100 | + </Stack> |
| 101 | + </Box> |
| 102 | + <div className={classes.avatarAdjust} /> |
| 103 | + </> |
| 104 | + ); |
| 105 | + |
| 106 | + if (!opened) { |
| 107 | + return null; |
| 108 | + } |
| 109 | + |
| 110 | + return ( |
| 111 | + <PortalView> |
| 112 | + <Box className={classes.root} onClick={() => setOpened(false)}> |
| 113 | + <RevealView className={classes.reveal}> |
| 114 | + <Paper className={classes.container}> |
| 115 | + <Stack direction='column' gap="15px"> |
| 116 | + {renderLogo()} |
| 117 | + <span style={{ marginTop: -10 }}> |
| 118 | + Move faster by hiring Outsource Company 👷. We have developed 💻 a lot IT of projects<br /><br /> |
| 119 | + This includes AI and enterprise software development 😃<br /><br /> |
| 120 | + </span> |
| 121 | + <Button |
| 122 | + variant="contained" |
| 123 | + onClick={handleSubmit} |
| 124 | + > |
| 125 | + Schedule the meeting |
| 126 | + </Button> |
| 127 | + </Stack> |
| 128 | + </Paper> |
| 129 | + </RevealView> |
| 130 | + </Box> |
| 131 | + </PortalView> |
| 132 | + ); |
| 133 | +}; |
| 134 | + |
| 135 | +CommercialModal.open = () => openSubject.next(); |
| 136 | + |
| 137 | +export default CommercialModal; |
0 commit comments