forked from holtzy/The-Python-Graph-Gallery
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBannerImage.js
More file actions
57 lines (51 loc) · 1.21 KB
/
BannerImage.js
File metadata and controls
57 lines (51 loc) · 1.21 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
import "./chartImage.css";
import React from "react";
import { useStaticQuery, graphql } from "gatsby";
import Img from "gatsby-image";
// This component displays a logo representing a sponsor of the gallery.
export default function BannerImage({ imgName, caption }) {
const data = useStaticQuery(graphql`
query MyQuery3 {
allFile(filter: { relativeDirectory: { eq: "banner" } }) {
edges {
node {
id
name
childImageSharp {
fluid {
aspectRatio
base64
sizes
src
srcWebp
srcSet
}
}
}
}
}
}
`);
const image = data.allFile.edges.find((n) => {
return n.node.name.includes(imgName);
});
if (!image) {
return null;
}
return (
<>
<div className="chartImageContainer">
<Img
alt={imgName}
fluid={image.node.childImageSharp.fluid}
className="chartImageImg"
/>
<div className="chartImageOverlay">
<div className="chartImageOverlayText">
<p>{caption}</p>
</div>
</div>
</div>
</>
);
}