SearchBar.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import React from 'react';
  2. import clsx from 'clsx';
  3. import { makeStyles, useTheme } from '@material-ui/core/styles';
  4. import Drawer from '@material-ui/core/Drawer';
  5. import AppBar from '@material-ui/core/AppBar';
  6. import Toolbar from '@material-ui/core/Toolbar';
  7. import List from '@material-ui/core/List';
  8. import CssBaseline from '@material-ui/core/CssBaseline';
  9. import Typography from '@material-ui/core/Typography';
  10. import Divider from '@material-ui/core/Divider';
  11. import IconButton from '@material-ui/core/IconButton';
  12. import MenuIcon from '@material-ui/icons/Menu';
  13. import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
  14. import ChevronRightIcon from '@material-ui/icons/ChevronRight';
  15. import ListItem from '@material-ui/core/ListItem';
  16. import ListItemIcon from '@material-ui/core/ListItemIcon';
  17. import ListItemText from '@material-ui/core/ListItemText';
  18. import InboxIcon from '@material-ui/icons/MoveToInbox';
  19. import MailIcon from '@material-ui/icons/Mail';
  20. import ImageList from './ImageList';
  21. import PhotoIcon from '@material-ui/icons/Photo';
  22. import ShareIcon from '@material-ui/icons/Share';
  23. import PhotoAlbumIcon from '@material-ui/icons/PhotoAlbum';
  24. import LibraryAddCheckIcon from '@material-ui/icons/LibraryAddCheck';
  25. import Grid from '@material-ui/core/Grid';
  26. import Button from '@material-ui/core/Button';
  27. const drawerWidth = 240;
  28. const useStyles = makeStyles((theme) => ({
  29. root: {
  30. display: 'flex',
  31. },
  32. appBar: {
  33. zIndex: theme.zIndex.drawer + 1,
  34. transition: theme.transitions.create(['width', 'margin'], {
  35. easing: theme.transitions.easing.sharp,
  36. duration: theme.transitions.duration.leavingScreen,
  37. }),
  38. },
  39. appBarShift: {
  40. marginLeft: drawerWidth,
  41. width: `calc(100% - ${drawerWidth}px)`,
  42. transition: theme.transitions.create(['width', 'margin'], {
  43. easing: theme.transitions.easing.sharp,
  44. duration: theme.transitions.duration.enteringScreen,
  45. }),
  46. },
  47. menuButton: {
  48. marginRight: 36,
  49. },
  50. hide: {
  51. display: 'none',
  52. },
  53. drawer: {
  54. width: drawerWidth,
  55. flexShrink: 0,
  56. whiteSpace: 'nowrap',
  57. },
  58. drawerOpen: {
  59. width: drawerWidth,
  60. transition: theme.transitions.create('width', {
  61. easing: theme.transitions.easing.sharp,
  62. duration: theme.transitions.duration.enteringScreen,
  63. }),
  64. },
  65. drawerClose: {
  66. transition: theme.transitions.create('width', {
  67. easing: theme.transitions.easing.sharp,
  68. duration: theme.transitions.duration.leavingScreen,
  69. }),
  70. overflowX: 'hidden',
  71. width: theme.spacing(7) + 1,
  72. [theme.breakpoints.up('sm')]: {
  73. width: theme.spacing(9) + 1,
  74. },
  75. },
  76. toolbar: {
  77. display: 'flex',
  78. alignItems: 'center',
  79. justifyContent: 'flex-end',
  80. padding: theme.spacing(0, 1),
  81. // necessary for content to be below app bar
  82. ...theme.mixins.toolbar,
  83. },
  84. content: {
  85. flexGrow: 1,
  86. padding: theme.spacing(3),
  87. },
  88. }));
  89. export default function MiniDrawer() {
  90. const classes = useStyles();
  91. const theme = useTheme();
  92. const [open, setOpen] = React.useState(false);
  93. const handleDrawerOpen = () => {
  94. setOpen(true);
  95. };
  96. const handleDrawerClose = () => {
  97. setOpen(false);
  98. };
  99. return ( <
  100. div className = { classes.root } >
  101. <
  102. CssBaseline / >
  103. <
  104. AppBar position = "fixed"
  105. className = {
  106. clsx(classes.appBar, {
  107. [classes.appBarShift]: open,
  108. })
  109. } >
  110. <
  111. Toolbar >
  112. <
  113. IconButton color = "inherit"
  114. onClick = { handleDrawerOpen }
  115. edge = "start"
  116. className = {
  117. clsx(classes.menuButton, {
  118. [classes.hide]: open,
  119. })
  120. } >
  121. <
  122. MenuIcon / >
  123. <
  124. /IconButton> <
  125. Typography variant = "h6"
  126. noWrap >
  127. 谷狗相薄 <
  128. /Typography> < /
  129. Toolbar > <
  130. /AppBar> <
  131. Drawer variant = "permanent"
  132. className = {
  133. clsx(classes.drawer, {
  134. [classes.drawerOpen]: open,
  135. [classes.drawerClose]: !open,
  136. })
  137. }
  138. classes = {
  139. {
  140. paper: clsx({
  141. [classes.drawerOpen]: open,
  142. [classes.drawerClose]: !open,
  143. }),
  144. }
  145. } >
  146. <
  147. div className = { classes.toolbar } >
  148. <
  149. IconButton onClick = { handleDrawerClose } > { theme.direction === 'rtl' ? < ChevronRightIcon / > : < ChevronLeftIcon / > } <
  150. /IconButton> < /
  151. div > <
  152. Divider / >
  153. <
  154. List > {
  155. ['相片', '共享', '相簿', '實用工具'].map((text, index) => ( <
  156. ListItem button key = { text } >
  157. <
  158. ListItemIcon > { index == 0 ? < PhotoIcon / > : index == 1 ? < ShareIcon / > : index == 2 ? < PhotoAlbumIcon / > : < LibraryAddCheckIcon / > } < /ListItemIcon> <
  159. ListItemText primary = { text }
  160. /> < /
  161. ListItem >
  162. ))
  163. } <
  164. /List> < /
  165. Drawer > <
  166. main className = { classes.content } >
  167. <
  168. div className = { classes.toolbar }
  169. /> <
  170. ImageList / > < /
  171. main > <
  172. /div>
  173. );
  174. }