-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRouter.tsx
More file actions
83 lines (76 loc) · 2.01 KB
/
Copy pathRouter.tsx
File metadata and controls
83 lines (76 loc) · 2.01 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { useBookmarkNavigate } from '@equinor/fusion-framework-react-module-bookmark/portal';
import { Router as FusionRouter, Outlet, useParams } from '@equinor/fusion-framework-react-router';
import AppLoader from './AppLoader';
import { Header } from './Header';
import { styled } from 'styled-components';
const Styled = {
ContentContainer: styled.div`
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 48px 1fr;
height: 100vh;
overflow: hidden;
grid-template-areas: 'head' 'main';
`,
Head: styled.section`
grid-area: head;
z-index: 2;
`,
Main: styled.section`
grid-area: main;
--header-height: 48px;
overflow: auto;
position: relative;
z-index: 1;
max-width: 100%;
display: grid;
`,
};
/**
* Root layout component for the dev portal.
*
* Renders the header and a scrollable main area via `Outlet`. Activates
* bookmark-to-navigation linking through `useBookmarkNavigate`.
*/
const Root = () => {
useBookmarkNavigate({ resolveAppPath: (appKey: string) => `/apps/${appKey}` });
return (
<Styled.ContentContainer>
<Styled.Head>
<Header />
</Styled.Head>
<Styled.Main>
<Outlet />
</Styled.Main>
</Styled.ContentContainer>
);
};
/**
* Route component that extracts the `appKey` parameter and delegates to {@link AppLoader}.
*/
const AppRoute = () => {
const { appKey } = useParams();
return appKey ? <AppLoader appKey={appKey} /> : null;
};
/** Route definitions for the dev portal. */
const routes = [
{
path: '/',
element: <Root />,
children: [
{
path: 'apps/:appKey/*',
element: <AppRoute />,
},
],
},
];
/**
* Top-level router for the Fusion Dev Portal.
*
* Uses `@equinor/fusion-framework-react-router` which automatically connects
* to the framework's navigation module for history and basename.
*/
export const Router = () => {
return <FusionRouter routes={routes} />;
};