MCPcopy Create free account
hub / github.com/LinkedInLearning/javascript-essential-training-2832077 / Photo

Function Photo

01_01/Photo.js:14–43  ·  view source on GitHub ↗
({
  index,
  onClick,
  photo,
  margin,
  direction,
  top,
  left,
  key,
})

Source from the content-addressed store, hash-verified

12const imgWithClick = { cursor: "pointer" };
13
14const Photo = ({
15 index,
16 onClick,
17 photo,
18 margin,
19 direction,
20 top,
21 left,
22 key,
23}) => {
24 const imgStyle = { margin: margin, display: "block" };
25 if (direction === "column") {
26 imgStyle.position = "absolute";
27 imgStyle.left = left;
28 imgStyle.top = top;
29 }
30
31 const handleClick = (event) => {
32 onClick(event, { photo, index });
33 };
34
35 return (
36 <img
37 key={key}
38 style={onClick ? { ...imgStyle, ...imgWithClick } : imgStyle}
39 {...photo}
40 onClick={onClick ? handleClick : null}
41 />
42 );
43};
44
45export const photoPropType = PropTypes.shape({
46 key: PropTypes.string,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected