-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDiagram.tsx
More file actions
60 lines (55 loc) · 1.36 KB
/
Diagram.tsx
File metadata and controls
60 lines (55 loc) · 1.36 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
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import Image from 'next/image';
interface DiagramProps {
name: string;
alt: string;
height: number;
width: number;
children: string;
captionPosition: 'top' | 'bottom' | null;
}
function Caption({text}: {text: string}) {
return (
<div className="w-full flex justify-center">
<figcaption className="p-1 sm:p-2 mt-0 sm:mt-0 text-gray-40 text-base lg:text-lg text-center leading-tight table-caption max-w-lg">
{text}
</figcaption>
</div>
);
}
export function Diagram({
name,
alt,
height,
width,
children,
captionPosition,
}: DiagramProps) {
return (
<figure className="flex flex-col px-0 p-0 sm:p-10 first:mt-0 mt-10 sm:mt-0 justify-center items-center">
{captionPosition === 'top' && <Caption text={children} />}
<div className="dark-image">
<Image
src={`/images/docs/diagrams/${name}.dark.png`}
alt={alt}
height={height}
width={width}
/>
</div>
<div className="light-image">
<Image
src={`/images/docs/diagrams/${name}.png`}
alt={alt}
height={height}
width={width}
/>
</div>
{(!captionPosition || captionPosition === 'bottom') && (
<Caption text={children} />
)}
</figure>
);
}
export default Diagram;