Skip to content

Commit 1558ed3

Browse files
committed
fix routing on data visualizer
1 parent 9777a9b commit 1558ed3

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

firebase.json

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"firebase.json",
99
"**/.*",
1010
"**/node_modules/**"
11+
],
12+
"rewrites": [
13+
{
14+
"source": "**",
15+
"destination": "/index.html"
16+
}
1117
]
1218
},
1319
"emulators": {

packages/data-visualizer/src/components/common/Modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
const Modal: FunctionalComponent<Props> = ({ close, children }) => {
88
return (
99
<div
10-
className="fixed top-0 left-0 w-screen h-screen flex items-center justify-center backdrop-filter backdrop-blur-sm"
10+
className="fixed top-0 left-0 w-screen h-screen flex items-center justify-center backdrop-filter backdrop-blur-sm z-50"
1111
onClick={close}>
1212
<div className="bg-white p-4 pt-10 rounded-lg text-black relative">
1313
<button

packages/data-visualizer/src/router/Layout.tsx

+17-10
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,33 @@ import { UserContext } from '../contexts/User/UserContext'
99

1010
import { routeComponents } from './Router'
1111

12+
const className = (activated: boolean) =>
13+
activated ? 'text-primary' : 'text-black hover:text-primary cursor-pointer'
14+
1215
const Layout: FunctionComponent = ({ children }) => {
1316
const { userState } = useContext(UserContext)
1417
const { usageState } = useContext(UsageContext)
1518

1619
return (
1720
<div className="flex justify-start">
18-
<div className="hidden md:block w-40 min-w-40 bg-secondary text-center h-screen pt-10">
21+
<div className="hidden md:block w-40 min-w-40 bg-white text-center h-screen pt-10">
1922
{Object.entries(routeComponents).map(([key, value]) => {
2023
if (!value.label) return null
2124
return (
2225
<div className="pt-5 text-sm" key={key}>
23-
<Link
24-
className={
25-
window.location.pathname === key
26-
? 'text-primary'
27-
: 'text-black hover:text-primary cursor-pointer'
28-
}
29-
href={key}>
30-
{value.label}
31-
</Link>
26+
{value.external ? (
27+
<div
28+
className={className(false)}
29+
onClick={() => window.open(value.external, '_blank')}>
30+
{value.label}
31+
</div>
32+
) : (
33+
<Link
34+
className={className(window.location.pathname === key)}
35+
href={key}>
36+
{value.label}
37+
</Link>
38+
)}
3239
</div>
3340
)
3441
})}

packages/data-visualizer/src/router/Router.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const routeComponents: {
2626
requireAuth?: boolean
2727
component: FunctionComponent
2828
label?: string
29+
external?: string
2930
}
3031
} = {
3132
[ROUTES.DASHBOARD]: {
@@ -47,10 +48,8 @@ export const routeComponents: {
4748
[ROUTES.ABOUT]: {
4849
requireAuth: true,
4950
label: 'About',
50-
component: () => {
51-
window.open('https://climate.jesper.no/about', '_blank')
52-
return null
53-
}
51+
external: 'https://climate.jesper.no/about',
52+
component: () => null
5453
},
5554
[ROUTES.SIGN_OUT]: {
5655
requireAuth: false,

0 commit comments

Comments
 (0)