forked from bareynol/mui-theme-creator
-
Notifications
You must be signed in to change notification settings - Fork 42
/
PreviewWindow.tsx
102 lines (91 loc) · 3.12 KB
/
PreviewWindow.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React from "react"
import { AppBar, Tabs, Tab, Tooltip } from "@mui/material"
import AppBarExample from "src/components/MuiComponentSamples/Samples/AppBar"
import DefaultExample from "./Samples/DefaultExample"
import SignUpExample from "./Samples/SignUpExample"
import DashboardExample from "./Samples/DashboardExample"
import BlogExample from "./Samples/BlogExample"
import PricingExample from "./Samples/PricingExample"
import CheckoutExample from "./Samples/CheckoutExample"
import PreviewWrapper from "./PreviewWrapper"
import DrawerExample from "./Samples/DrawerExample"
interface TabPanelProps {
children?: React.ReactNode
index: any
value: any
}
function TabPanel(props: TabPanelProps) {
const { children, value, index, ...other } = props
return (
<div
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && <div>{children}</div>}
</div>
)
}
export const previewNavTabsId = "preview-nav-tabs"
const tabStyle = {
minWidth: { sm: 160 },
}
const PreviewWindow = () => {
const [tabIndex, setTabIndex] = React.useState(0)
const [drawerOpen, setDrawerOpen] = React.useState(false)
const handleChange = (event: React.ChangeEvent<{}>, newTabIndex: number) => {
setTabIndex(newTabIndex)
}
const toggleDrawer = () => setDrawerOpen(prev => !prev)
const handleCloseDrawer = () => setDrawerOpen(false)
return (
<PreviewWrapper>
<AppBarExample onDrawerButtonClick={toggleDrawer} />
<Tooltip title={`<AppBar color="primary">`} placement="left" arrow>
<AppBar position="static" id={previewNavTabsId}>
<Tabs
value={tabIndex}
onChange={handleChange}
variant="scrollable"
textColor="inherit"
indicatorColor="secondary"
scrollButtons
aria-label="preview-window-tabs"
allowScrollButtonsMobile
>
<Tab label="Instructions" sx={tabStyle} />
<Tab label="Sign Up" sx={tabStyle} />
<Tab label="Dashboard" sx={tabStyle} />
<Tab label="Blog" sx={tabStyle} />
<Tab label="Pricing" sx={tabStyle} />
<Tab label="Checkout" sx={tabStyle} />
</Tabs>
</AppBar>
</Tooltip>
<div>
<DrawerExample open={drawerOpen} onClose={handleCloseDrawer} />
<TabPanel value={tabIndex} index={0}>
<DefaultExample />
</TabPanel>
<TabPanel value={tabIndex} index={1}>
<SignUpExample />
</TabPanel>
<TabPanel value={tabIndex} index={2}>
<DashboardExample />
</TabPanel>
<TabPanel value={tabIndex} index={3}>
<BlogExample />
</TabPanel>
<TabPanel value={tabIndex} index={4}>
<PricingExample />
</TabPanel>
<TabPanel value={tabIndex} index={5}>
<CheckoutExample />
</TabPanel>
</div>
</PreviewWrapper>
)
}
export default PreviewWindow