-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathindex.jsx
More file actions
218 lines (203 loc) · 5.73 KB
/
index.jsx
File metadata and controls
218 lines (203 loc) · 5.73 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import React from "react";
import PropTypes from "prop-types";
import AppBar from "@material-ui/core/AppBar";
import CssBaseline from "@material-ui/core/CssBaseline";
import Drawer from "@material-ui/core/Drawer";
import Hidden from "@material-ui/core/Hidden";
import IconButton from "@material-ui/core/IconButton";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import { GitHub } from "@material-ui/icons";
import ListItemText from "@material-ui/core/ListItemText";
import MenuIcon from "@material-ui/icons/Menu";
import Toolbar from "@material-ui/core/Toolbar";
import Typography from "@material-ui/core/Typography";
import { Button, Container } from "@material-ui/core";
import { makeStyles, useTheme } from "@material-ui/core/styles";
import Navigation from "../Navigation";
import { Link } from "react-router-dom";
import { Components_Index } from "../Navigation";
const drawerWidth = 200;
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
},
drawer: {
[theme.breakpoints.up("sm")]: {
width: drawerWidth,
flexShrink: 0,
},
},
appBar: {
[theme.breakpoints.up("sm")]: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: drawerWidth,
},
zIndex: theme.zIndex.drawer + 1,
},
menuButton: {
marginRight: theme.spacing(2),
[theme.breakpoints.up("sm")]: {
display: "none",
},
},
// necessary for content to be below app bar
toolbar: theme.mixins.toolbar,
drawerPaper: {
width: drawerWidth,
},
content: {
flexGrow: 1,
paddingTop: "1.5rem",
minHeight: "100vh",
},
sideListItem: {
transition: "0.1s all ease-in",
"&:hover": {
borderRight: "5px solid #2089dc",
},
"&:focus": {
borderRight: "5px solid #2089dc",
},
},
playgroundTitle:{
position: "fixed",
zIndex: "1",
backgroundColor: "white",
top: "0",
left:"0",
padding: "10px 10px",
width: "200px",
},
list:{
marginTop: "20px"
},
}));
function ResponsiveDrawer(props) {
const { window } = props;
const classes = useStyles();
const theme = useTheme();
const [mobileOpen, setMobileOpen] = React.useState(false);
const [selectedIndex, setSelectedIndex] = React.useState(-1);
const handleDrawerToggle = (value) => {
if(value === false){
setMobileOpen(false);
} else {
setMobileOpen(true);
}
};
const handleListItemClick = (event, index) => {
setSelectedIndex(index);
};
const drawer = (
<div>
<div style={{ padding: "0.5rem" }}>
<Link to="/">
<Typography className={classes.playgroundTitle} variant="h5">Playground 🚀</Typography>
</Link>
</div>
<List className={classes.list}>
{Components_Index.map((elm, index) => (
<Link
key={elm.name}
to={elm.path}
onClick={() => handleDrawerToggle(false)}
>
<ListItem
button
key={elm.name}
selected={selectedIndex === index}
onClick={(event) => handleListItemClick(event, index)}
className={classes.sideListItem}
>
<ListItemText primary={elm.name} />
</ListItem>
</Link>
))}
</List>
</div>
);
const container =
window !== undefined ? () => window().document.body : undefined;
return (
<div className={classes.root}>
<CssBaseline />
<AppBar position="fixed" className={classes.appBar}>
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
className={classes.menuButton}
>
<MenuIcon />
</IconButton>
<Link to="/">
<Typography variant="h6" noWrap>
React Native Elements
</Typography>
</Link>
<div style={{ marginLeft: "auto" }}>
<a href="https://reactnativeelements.com/" target="_blank">
<Button color="inherit">Docs</Button>
</a>
<IconButton
color="inherit"
rel="noopener noreferrer"
href="https://github.com/react-native-elements/react-native-elements"
target="_blank"
>
<GitHub />
</IconButton>
</div>
</Toolbar>
</AppBar>
<nav className={classes.drawer} aria-label="mailbox folders">
{/* The implementation can be swapped with js to avoid SEO duplication of links. */}
<Hidden smUp implementation="css">
<Drawer
container={container}
variant="temporary"
anchor={theme.direction === "rtl" ? "right" : "left"}
open={mobileOpen}
onClose={() => handleDrawerToggle(false)}
classes={{
paper: classes.drawerPaper,
}}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
>
{drawer}
</Drawer>
</Hidden>
<Hidden xsDown implementation="css">
<Drawer
classes={{
paper: classes.drawerPaper,
}}
variant="permanent"
open
>
{drawer}
</Drawer>
</Hidden>
</nav>
<main className={classes.content}>
<div className={classes.toolbar} />
<Container maxWidth="lg">
<Navigation />
</Container>
</main>
</div>
);
}
ResponsiveDrawer.propTypes = {
/**
* Injected by the documentation to work in an iframe.
* You won't need it on your project.
*/
window: PropTypes.func,
};
export default ResponsiveDrawer;