forked from wednesday-solutions/react-graphql-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
71 lines (68 loc) · 2 KB
/
index.tsx
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
/**
*
* App.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/
import React from 'react';
import GlobalStyle from '@app/global-styles';
import { routeConfig } from '@app/routeConfig';
import { Layout } from 'antd';
import map from 'lodash-es/map';
import { withRouter } from 'react-router';
import { Route, Switch } from 'react-router-dom';
import { compose } from 'redux';
import styled, { ThemeProvider } from 'styled-components';
import For from '@components/For';
import Header from '@components/Header';
import { colors } from '@themes/index';
import Sidebar from '@app/components/Siderbar';
import { HEADER_HEIGHT, MIN_SIDEBAR_WIDTH } from '@app/utils/constants';
const theme = {
fg: colors.primary,
bg: colors.secondaryText,
headerHeight: HEADER_HEIGHT,
sidebarWidth: MIN_SIDEBAR_WIDTH
};
const CustomLayout = styled(Layout)`
&& {
flex-direction: row;
}
`;
export function App() {
return (
<ThemeProvider theme={theme}>
<Header />
<CustomLayout>
<Sidebar />
<Layout.Content>
<For
ParentComponent={(props) => <Switch {...props} />}
of={map(Object.keys(routeConfig))}
renderItem={(routeKey, index) => {
const Component = routeConfig[routeKey].component;
return (
<Route
exact={routeConfig[routeKey].exact}
key={index}
path={routeConfig[routeKey].route}
render={(props) => {
const updatedProps = {
...props,
...routeConfig[routeKey].props
};
return <Component {...updatedProps} />;
}}
/>
);
}}
/>
<GlobalStyle />
</Layout.Content>
</CustomLayout>
</ThemeProvider>
);
}
export default compose(withRouter)(App);