-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlayout.tsx
More file actions
60 lines (52 loc) · 1.8 KB
/
Copy pathlayout.tsx
File metadata and controls
60 lines (52 loc) · 1.8 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
"use client"
import { useParams, usePathname } from "next/navigation"
import * as React from "react"
import { useEffect, useState } from "react"
import Col from "react-bootstrap/Col"
import Row from "react-bootstrap/Row"
import { useMeasure } from "react-use"
import { ErddapMap } from "../../src/Features/ERDDAP/Map"
export default function Layout({
sidebar,
belowMap,
bottom,
}: {
sidebar: React.ReactNode
bottom: React.ReactNode
belowMap: React.ReactNode
}) {
const path = usePathname()
const isPlatformView = path.startsWith("/platform")
const params: { regionId?: string; platformId?: string } = useParams()
let [ref, { height }] = useMeasure<HTMLDivElement>()
const platformId = params.platformId
const [isClient, setIsClient] = useState(false)
useEffect(() => {
setIsClient(true)
}, [])
if (height < 420) {
height = 420
}
//Removing warning in console re:Highcharts library defaultProps. Not an active warning for us--until this issues is solved on Highcharts' end, keep this to remove huge console error
const error = console.error
console.error = (...args: any) => {
if (/defaultProps/.test(args[0])) return
error(...args)
}
return (
<React.Fragment>
<Row>
<Col xs={{ span: "12", order: "2" }} md={{ span: "6", order: "2" }}>
<div ref={ref} style={{ marginBottom: ".5rem" }}>
{sidebar}
</div>
</Col>
<Col xs={{ span: "12", order: `${isPlatformView ? "2" : "1"}` }} md={{ span: "6", order: "1" }}>
<ErddapMap height={params.regionId ? "80vh" : height} {...(isPlatformView && { platformId })} />
{belowMap ?? <React.Fragment>{belowMap}</React.Fragment>}
</Col>
</Row>
{(isPlatformView && isClient && bottom) ?? <Row>{bottom}</Row>}
</React.Fragment>
)
}