]> Untitled Git - lemmy-ui.git/blob - src/shared/components/app/app.tsx
Re-organized components folder. (#339)
[lemmy-ui.git] / src / shared / components / app / app.tsx
1 import { Component } from "inferno";
2 import { Helmet } from "inferno-helmet";
3 import { Provider } from "inferno-i18next";
4 import { Route, Switch } from "inferno-router";
5 import { GetSiteResponse } from "lemmy-js-client";
6 import { i18n } from "../../i18next";
7 import { routes } from "../../routes";
8 import { favIconPngUrl, favIconUrl } from "../../utils";
9 import { Footer } from "./footer";
10 import { Navbar } from "./navbar";
11 import { NoMatch } from "./no-match";
12 import "./styles.scss";
13 import { Theme } from "./theme";
14
15 export interface AppProps {
16   siteRes: GetSiteResponse;
17 }
18
19 export class App extends Component<AppProps, any> {
20   constructor(props: any, context: any) {
21     super(props, context);
22   }
23   render() {
24     let siteRes = this.props.siteRes;
25     return (
26       <>
27         <Provider i18next={i18n}>
28           <div>
29             <Theme localUserView={siteRes.my_user} />
30             {siteRes &&
31               siteRes.site_view &&
32               this.props.siteRes.site_view.site.icon && (
33                 <Helmet>
34                   <link
35                     id="favicon"
36                     rel="shortcut icon"
37                     type="image/x-icon"
38                     href={this.props.siteRes.site_view.site.icon || favIconUrl}
39                   />
40                   <link
41                     rel="apple-touch-icon"
42                     href={
43                       this.props.siteRes.site_view.site.icon || favIconPngUrl
44                     }
45                   />
46                 </Helmet>
47               )}
48             <Navbar site_res={this.props.siteRes} />
49             <div class="mt-4 p-0 fl-1">
50               <Switch>
51                 {routes.map(({ path, exact, component: C, ...rest }) => (
52                   <Route
53                     key={path}
54                     path={path}
55                     exact={exact}
56                     render={props => <C {...props} {...rest} />}
57                   />
58                 ))}
59                 <Route render={props => <NoMatch {...props} />} />
60               </Switch>
61             </div>
62             <Footer site={this.props.siteRes} />
63           </div>
64         </Provider>
65       </>
66     );
67   }
68 }