testIL.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. import StarBorderIcon from '@material-ui/icons/StarBorderOutlined';
  11. import clsx from 'clsx';
  12. const useStyles = makeStyles((theme) => ({
  13. root: {
  14. display: 'flex',
  15. flexWrap: 'wrap',
  16. justifyContent: 'space-around',
  17. overflow: 'hidden',
  18. backgroundColor: theme.palette.background.paper,
  19. },
  20. gridList: {
  21. width: '100%',
  22. height: '100%',
  23. },
  24. icon: {
  25. color: 'rgba(255, 255, 255, 0.54)',
  26. },
  27. titleBar: {
  28. background: 'linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, ' +
  29. 'rgba(0,0,0,0.3) 70%, rgba(0,0,0,0) 100%)',
  30. },
  31. titleGrid: {},
  32. titleGridOpen: {
  33. transition: theme.transitions.create('height', {
  34. easing: theme.transitions.easing.sharp,
  35. duration: theme.transitions.duration.enteringScreen,
  36. }),
  37. },
  38. titleGridClose: {
  39. transition: theme.transitions.create('height', {
  40. easing: theme.transitions.easing.sharp,
  41. duration: theme.transitions.duration.leavingScreen,
  42. }),
  43. },
  44. }));
  45. /**
  46. * The example data is structured as follows:
  47. *
  48. * import image from 'path/to/image.jpg';
  49. * [etc...]
  50. *
  51. * const tileData = [
  52. * {
  53. * img: image,
  54. * title: 'Image',
  55. * author: 'author',
  56. * },
  57. * {
  58. * [etc...]
  59. * },
  60. * ];
  61. */
  62. export default function TitlebarGridList() {
  63. const classes = useStyles();
  64. const [Hovering, isHovering] = React.useState(false);
  65. const handleMouseHover = value => () => {
  66. //isHovering(value);
  67. //disable first, not understand how to do easing
  68. isHovering(false);
  69. }
  70. return ( <
  71. div className = { classes.root } >
  72. <
  73. GridList cellHeight = { 180 }
  74. cols = { 5 }
  75. className = { classes.gridList } >
  76. <
  77. GridListTile key = "Subheader"
  78. cols = { 5 }
  79. style = {
  80. { height: 'auto' }
  81. } >
  82. <
  83. ListSubheader component = "div" > December < /ListSubheader> < /
  84. GridListTile > {
  85. tileData.map((tile) => ( <
  86. GridListTile key = { tile.img } >
  87. <
  88. img src = { tile.img }
  89. alt = { tile.title }
  90. onMouseEnter = { handleMouseHover(true) }
  91. onMouseLeave = { handleMouseHover(false) }
  92. />{Hovering && <GridListTileBar
  93. title = { tile.title }
  94. titlePosition = "top"
  95. onMouseEnter = { handleMouseHover(true) }
  96. onMouseLeave = { handleMouseHover(false) }
  97. className = {
  98. clsx(classes.titleGrid, {
  99. [classes.titleGridOpen]: Hovering,
  100. [classes.titleGridClose]: !Hovering,
  101. })
  102. }
  103. actionIcon = { <
  104. IconButton
  105. className = { classes.icon } >
  106. <
  107. StarBorderIcon / >
  108. <
  109. /IconButton>
  110. }
  111. actionPosition = "left"
  112. className = { classes.titleBar }
  113. />}< /
  114. GridListTile >
  115. ))
  116. } <
  117. /GridList> < /
  118. div >
  119. );
  120. }