index.tsx
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import Header from "components/Header";
import Image from "components/Image";
import styled from "styled-components";
import dynamic from "next/dynamic";
import { useState } from "react";
import GifEditor from "components/GifEditor";
const ToastEditor = dynamic(() => import("components/ToastEditor"), {
ssr: false,
});
const Index = () => {
const [isEditorOpened, setIsEditorOpened] = useState(false);
const [previewURL, setPreviewURL] = useState<string | ArrayBuffer>("");
const [isImgAdded, setIsImgAdded] = useState(false);
return (
<Container>
<Header />
{!isImgAdded ? (
<div
style={{
height: "80vh",
width: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<button
className="open-button"
onClick={() => setIsEditorOpened(true)}
>
Open Image Editor
</button>
</div>
) : (
!isEditorOpened && <GifEditor {...{ previewURL }} />
)}
{isEditorOpened && (
<ToastEditor {...{ setPreviewURL, setIsImgAdded, setIsEditorOpened }} />
)}
</Container>
);
};
const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
.open-button {
margin-top: 3rem;
padding: 0.5rem 2rem;
display: flex;
align-items: center;
transition: 0.3s;
:hover {
font-size: 1.1rem;
transition: 0.3s;
}
::before {
width: 2.315rem;
content: "+";
font-size: 2rem;
margin-right: 1rem;
box-shadow: ${({ theme }) => theme.boxShadow.normal};
border-radius: 50%;
}
}
`;
export default Index;