-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathGrapherWithFallback.tsx
46 lines (45 loc) · 1.27 KB
/
GrapherWithFallback.tsx
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
import { Grapher } from "@ourworldindata/grapher"
import { GrapherFigureView } from "./GrapherFigureView.js"
import cx from "classnames"
import { GRAPHER_PREVIEW_CLASS } from "./SiteConstants.js"
import GrapherImage from "./GrapherImage.js"
export const GrapherWithFallback = ({
grapher,
slug,
className,
id,
}: {
grapher?: Grapher | undefined
slug?: string
className?: string
id?: string
}) => {
return (
<div
className={cx(
"GrapherWithFallback",
"full-width-on-mobile",
className
)}
id={id}
>
<>
{grapher ? (
<GrapherFigureView grapher={grapher} />
) : (
// Render fallback svg when javascript disabled or while
// grapher is loading
<figure
data-grapher-src
className={cx(
GRAPHER_PREVIEW_CLASS,
"GrapherWithFallback__fallback"
)}
>
{slug && <GrapherImage slug={slug} />}
</figure>
)}
</>
</div>
)
}