Skip to content

Commit

Permalink
feat: add disclaimer
Browse files Browse the repository at this point in the history
  • Loading branch information
omnajjar committed Apr 24, 2023
1 parent 6a2ba8e commit d74907b
Showing 1 changed file with 113 additions and 21 deletions.
134 changes: 113 additions & 21 deletions src/desginer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { useEditor } from '@craftjs/core';
import { Layers } from '@craftjs/layers';
import { useRouter } from 'next/router';
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { FaGithub } from 'react-icons/fa';
import { FiExternalLink } from 'react-icons/fi';
import {
Button,
Content,
Divider,
Modal,
Panel,
PanelGroup,
Stack,
Tooltip,
Whisper,
} from 'rsuite';
import { Container } from 'rsuite';
import styled from 'styled-components';

import { Drawer, ExamplesList, Logo, MenuButton } from '@/desginer/Components';
import { ComponentsBar } from '@/desginer/ComponentsBox';
Expand All @@ -27,16 +29,108 @@ import {
HistoryComponent,
} from '@/desginer/topbarComponents';

export function WebRepubApp() {
return (
<GlobalSettingsProvider
settings={{
isInDesignMode: true,
}}
>
<EditorContext enabled={true}>
<Designer />
</EditorContext>
</GlobalSettingsProvider>
);
}

const DevelopmentBadge = styled.span`
position: absolute;
left: 20px;
bottom: -20px;
z-index: 100;
width: 160px;
padding: 4px;
text-align: center;
color: #fff;
font-size: 12px;
font-weight: bold;
border-radius: 20px;
background-image: linear-gradient(
to right,
#ff8008 0%,
#ffc837 51%,
#ff8008 100%
);
background-size: 200% auto;
transition: 0.5s;
cursor: pointer;
&:hover {
background-position: right center;
}
`;

function DisclaimerModal({
open,
onClose,
}: {
open: boolean;
onClose: () => void;
}) {
return (
<Modal size='md' open={open} onClose={onClose}>
<Modal.Header>
<Modal.Title>
<h4> 🛠️ Disclaimer - Work In Progress 🏗️</h4>
</Modal.Title>
</Modal.Header>
<Modal.Body>
<p>
Welcome to Webrepub! <br />
<br /> As we're still in the process of developing this app, we can't
guarantee that everything will be perfect, but we promise to do our
best to make it awesome.
<br />
<br />
Please bear with us as we work to improve Webrepub and bring you new
and exciting features. We're confident that you'll love what we have
in store for the future.
<br />
<br />
Thank you for your support and for being a part of the Webrepub
community! ❤️
</p>
</Modal.Body>
<Modal.Footer>
<Button onClick={onClose} appearance='primary'>
Ok
</Button>
</Modal.Footer>
</Modal>
);
}

function Designer() {
const { actions } = useEditor();
const {
actions: { clearEvents },
} = useEditor();
const [propsBoxHeight, setPropsBoxHeight] = useState('100%');
const [isExamplesDrawerOpen, setIsExamplesDrawerOpen] = useState(false);

const openExamplesDrawer = () => {
actions.clearEvents();
const [isDisclaimerOpen, setDisclaimerOpen] = useState(false);

const openDisclaimer = useCallback(() => {
clearEvents();
setDisclaimerOpen(true);
}, [setDisclaimerOpen, clearEvents]);

const openExamplesDrawer = useCallback(() => {
clearEvents();
setIsExamplesDrawerOpen(true);
};
const closeExamplesDrawer = () => setIsExamplesDrawerOpen(false);
}, [setIsExamplesDrawerOpen, clearEvents]);

const closeExamplesDrawer = useCallback(() => {
setIsExamplesDrawerOpen(false);
}, [setIsExamplesDrawerOpen]);

const router = useRouter();

Expand All @@ -46,6 +140,7 @@ function Designer() {

useEffect(() => {
setPropsBoxHeight(`${window.innerHeight - 56 - 300}px`); // 56 topbar, 300 layers.
setDisclaimerOpen(true);
}, []);

return (
Expand All @@ -60,11 +155,18 @@ function Designer() {
alignItems='center'
>
<Stack.Item basis='200px'>
<Stack justifyContent='center' alignItems='center'>
<Stack
justifyContent='center'
alignItems='center'
style={{ position: 'relative' }}
>
<Logo
scale={1}
onClick={() => router.push('https://webrepub.com')}
></Logo>
<DevelopmentBadge onClick={openDisclaimer}>
Under Development 🛠️
</DevelopmentBadge>
</Stack>
</Stack.Item>

Expand Down Expand Up @@ -194,20 +296,10 @@ function Designer() {
>
<ExamplesList onItemClick={closeExamplesDrawer} />
</Drawer>
<DisclaimerModal
open={isDisclaimerOpen}
onClose={() => setDisclaimerOpen(false)}
/>
</>
);
}

export function WebRepubApp() {
return (
<GlobalSettingsProvider
settings={{
isInDesignMode: true,
}}
>
<EditorContext enabled={true}>
<Designer />
</EditorContext>
</GlobalSettingsProvider>
);
}

1 comment on commit d74907b

@vercel
Copy link

@vercel vercel bot commented on d74907b Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.