folder.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React from 'react';
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import GridList from '@material-ui/core/GridList';
  4. import GridListTile from '@material-ui/core/GridListTile';
  5. import GridListTileBar from '@material-ui/core/GridListTileBar';
  6. import ListSubheader from '@material-ui/core/ListSubheader';
  7. import IconButton from '@material-ui/core/IconButton';
  8. import InfoIcon from '@material-ui/icons/Info';
  9. import tileData from './tileData';
  10. const useStyles = makeStyles((theme) => ({
  11. root: {
  12. display: 'flex',
  13. flexWrap: 'wrap',
  14. justifyContent: 'space-around',
  15. overflow: 'hidden',
  16. backgroundColor: theme.palette.background.paper,
  17. },
  18. gridList: {
  19. width: '100%',
  20. height: '100%',
  21. },
  22. icon: {
  23. color: 'rgba(255, 255, 255, 0.54)',
  24. },
  25. }));
  26. /**
  27. * The example data is structured as follows:
  28. *
  29. * import image from 'path/to/image.jpg';
  30. * [etc...]
  31. *
  32. * const tileData = [
  33. * {
  34. * img: image,
  35. * title: 'Image',
  36. * author: 'author',
  37. * },
  38. * {
  39. * [etc...]
  40. * },
  41. * ];
  42. */
  43. export default function TitlebarGridList() {
  44. const classes = useStyles();
  45. return ( <
  46. div className = { classes.root } >
  47. <
  48. GridList cellHeight = { 180 }
  49. cols = { 5 }
  50. className = { classes.gridList } > {
  51. tileData.map((tile) => ( <
  52. GridListTile key = { tile.img } >
  53. <
  54. img src = { tile.img }
  55. alt = { tile.title }
  56. /> <
  57. GridListTileBar title = { tile.title }
  58. subtitle = { < span > by: { tile.author } < /span>}
  59. actionIcon = { <
  60. IconButton
  61. className = { classes.icon } >
  62. <
  63. InfoIcon / >
  64. <
  65. /IconButton>
  66. }
  67. /> < /
  68. GridListTile >
  69. ))
  70. } <
  71. /GridList> < /
  72. div >
  73. );
  74. }