-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPages.tsx
74 lines (72 loc) · 2.06 KB
/
Pages.tsx
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
74
// @ts-nocheck
import React from "react"
import { LightTheme, ThemeProvider } from "baseui"
import { Drawer, SIZE } from "baseui/drawer"
import { Button, KIND } from "baseui/button"
import { useSelector } from "react-redux"
import { selectPages } from "./store/slices/design-editor/selectors"
import { nanoid } from "nanoid"
import { useAppDispatch } from "./store/store"
import { addPage } from "./store/slices/design-editor/actions"
export default function Pages() {
const [isOpen, setIsOpen] = React.useState(false)
const pages = useSelector(selectPages)
const dispach = useAppDispatch()
const handleAddPage = () => {
dispach(
addPage({
id: nanoid(),
name: "New page",
})
)
}
return (
<ThemeProvider theme={LightTheme}>
<Button
onClick={() => setIsOpen(true)}
kind={KIND.secondary}
$style={{
position: "absolute",
bottom: "20px",
right: "20px",
zIndex: 1,
display: isOpen ? "none" : "block",
}}
>
Pages
</Button>
<Drawer size={SIZE.auto} isOpen={isOpen} autoFocus onClose={() => setIsOpen(false)}>
<div
style={{
height: "100%",
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
}}
>
<div style={{ display: "grid", gap: "1rem", padding: "1rem 0" }}>
{pages.map((page, index) => {
return (
<div
style={{
width: "180px",
height: "60px",
border: "1px solid gray",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
key={page.id}
>
Page {index}
</div>
)
})}
</div>
<Button onClick={handleAddPage}>Add Page</Button>
</div>
</Drawer>
</ThemeProvider>
)
}