-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExamplesLayout.jsx
56 lines (53 loc) · 1.43 KB
/
ExamplesLayout.jsx
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
import React from "react";
import { ImageLayout } from "./ImageLayout";
export function ExamplesLayout({
children,
backgroundSrc,
backgroundSize,
backgroundOpacity = 0.1
}) {
console.log(children);
let childrenn = Array.isArray(children) ? children : [children];
console.log(childrenn);
return (
<ImageLayout
style={{ textAlign: "left", justifyContent: "flex-end", height: "90vh" }}
className="definition-layout"
src={backgroundSrc}
opacity={backgroundOpacity}
size={backgroundSize}
appear
>
<div style={{ textAlign: "center" }}>
{childrenn.map(child => {
function format(str) {
if (str && str.props && str.props.children) {
return {
...str,
props: {
...str.props,
children: format(str.props.children)
}
};
}
if (typeof str === "string") {
return str.split("VS").reduce((acc, x) => {
if (!acc.length) {
return [x];
}
return [...acc, <br />, "←→", <br />, x];
}, []);
}
return str;
}
return (
<>
<br style={{ marginTop: "-24px", display: "block" }} />
{format(child)}
</>
);
})}
</div>
</ImageLayout>
);
}