Skip to content

Commit ab1079e

Browse files
authored
Merge pull request #39 from mapcomponents/Add-MultiTab
Changing Router and Fixing Button which opens the table
2 parents 0241525 + 697cdc2 commit ab1079e

File tree

3 files changed

+31
-58
lines changed

3 files changed

+31
-58
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ jobs:
4040
CI=false yarn build
4141
cd ..
4242
cp -r multi_tab/dist docs-build/multi_tab
43-
- name: Install and build test_app🔧
44-
run: |
45-
cd test_app
46-
yarn
47-
CI=false yarn build
48-
cd ..
49-
cp -r test_app/dist docs-build/test_app
5043
- name: copy catalogue metadata
5144
run: |
5245
cp mc_meta.json docs-build/mc_meta.json

multi_tab/src/App.tsx

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
11
import "./App.css";
2-
import { MapLibreMap } from "@mapcomponents/react-maplibre";
2+
import {MapLibreMap} from "@mapcomponents/react-maplibre";
33
import LayerManager from "./components/LayerManager.jsx";
4-
import { useState } from "react";
5-
import { Button } from "@mui/material";
4+
import {Button} from "@mui/material";
65

76
function App() {
8-
const [tableOpen, setTableOpen] = useState(false);
97

10-
11-
const openTable = () => {
12-
if (!tableOpen) {
13-
const newUrl = `${window.location.href}table`;
14-
window.open(newUrl, "_blank", "popup");
15-
setTableOpen(true);
8+
const openTable = () => {
9+
const newUrl = `${window.location.href}table`;
10+
window.open(newUrl, "_blank", "popup");
1611
}
17-
}
18-
return (
19-
<>
20-
<MapLibreMap
21-
options={{
22-
style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
23-
zoom: 12.75,
24-
center: [7.1, 50.73],
25-
}}
26-
style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }}
27-
/>
28-
<LayerManager />
29-
<Button
30-
sx={{
31-
left: '93%'
32-
}}
33-
variant='contained'
34-
color="primary"
35-
onClick={() => openTable()}
36-
>show table</Button>
37-
</>
38-
);
12+
return (
13+
<>
14+
<MapLibreMap
15+
options={{
16+
style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
17+
zoom: 12.75,
18+
center: [7.1, 50.73],
19+
}}
20+
style={{position: "absolute", top: 0, bottom: 0, left: 0, right: 0}}
21+
/>
22+
<LayerManager/>
23+
<Button
24+
sx={{
25+
left: '93%'
26+
}}
27+
variant='contained'
28+
color="primary"
29+
onClick={() => openTable()}
30+
>show table</Button>
31+
</>
32+
);
3933
}
4034

4135
export default App;

multi_tab/src/main.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import {MapComponentsProvider} from "@mapcomponents/react-maplibre";
44
import App from './App';
55
import DataTableManager from './components/DataTableManager.jsx';
66
import './index.css';
7-
import {
8-
createBrowserRouter,
9-
RouterProvider,
10-
} from "react-router-dom";
7+
import { Route, Routes } from "react-router-dom";
118
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
129
import {DataContextProvider} from "./contexts/DataContext";
1310
import pwaUrl from "./lib/pwaUrl";
@@ -25,27 +22,16 @@ if ('serviceWorker' in navigator) {
2522
}
2623
const pathname = window.location.pathname;
2724

28-
const router = createBrowserRouter([
29-
{
30-
path: pathname + '/',
31-
element: (
32-
<App/>
33-
),
34-
},
35-
{
36-
path: pathname + '/table',
37-
element: (
38-
<DataTableManager />
39-
)
40-
}
41-
])
4225

4326
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
4427
<React.StrictMode>
4528
<QueryClientProvider client={queryClient}>
4629
<MapComponentsProvider>
4730
<DataContextProvider>
48-
<RouterProvider router={router}></RouterProvider>
31+
<Routes>
32+
<Route path={pathname + "/table"} element={<DataTableManager />} />
33+
<Route path={pathname + "/"} element={<App />} />
34+
</Routes>
4935
</DataContextProvider>
5036
</MapComponentsProvider>
5137
</QueryClientProvider>

0 commit comments

Comments
 (0)