Repository navigation
Expand file tree
/
Copy pathSectionLogo.js
More file actions
66 lines (58 loc) · 1.48 KB
/
Copy pathSectionLogo.js
File metadata and controls
66 lines (58 loc) · 1.48 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
58
59
60
61
62
63
64
65
66
import "./sectionLogo.css";
import React from "react";
import { useStaticQuery, graphql } from "gatsby";
import Img from "gatsby-image";
import anim150 from "../../static/section/anim150.gif"
import time150 from "../../static/section/time150.gif"
// This component displays a logo representing a chart type of the gallery. Example: bar chart
// Logo has a different size depending on the window size.
export default function SectionLogo({ chartType }) {
if (chartType === "anim150") {
return (
<img src={anim150} alt="Animation with python" style={{ width: "100%" }} />)
}
if (chartType === "time150") {
return (
<img src={time150} alt="Timeseries with python" style={{ width: "100%" }} />)
}
const data = useStaticQuery(graphql`
query ChartFiles {
allFile(
filter: {
relativeDirectory: { eq: "section" }
extension: {eq: "png"}
}
) {
edges {
node {
id
name
childImageSharp {
fluid {
aspectRatio
base64
sizes
src
srcWebp
srcSet
}
}
}
}
}
}
`);
const image = data.allFile.edges.find((n) => {
return n.node.name === chartType;
});
if (!image) {
return null;
}
return (
<Img
alt={"todo"}
fluid={image.node.childImageSharp.fluid}
className="sectionLogoImg"
/>
);
}