|
1 | 1 | import "./App.css";
|
2 |
| -import { useState } from "react"; |
| 2 | +import { useState, useRef, useEffect, useMemo } from "react"; |
3 | 3 | import { Dropdown } from "flowbite-react";
|
| 4 | +import { CadtLogo } from "./components/CadtLogo"; |
| 5 | +import { ExplorerLogo } from "./components/ExplorerLogo"; |
| 6 | +import { TokenizationLogo } from "./components/TokenizationLogo"; |
| 7 | +import { Flowbite } from "flowbite-react"; |
| 8 | +import flowbiteThemeSettings from "./flowbite.theme"; |
4 | 9 |
|
5 | 10 | const appLinks = {
|
6 | 11 | cadt: {
|
7 | 12 | link: "/apps/cadt/index.html",
|
8 | 13 | name: "CADT",
|
| 14 | + logo: CadtLogo, |
9 | 15 | },
|
10 | 16 | climateExplorer: {
|
11 | 17 | link: "/apps/climate_explorer/index.html",
|
12 | 18 | name: "Climate Explorer",
|
| 19 | + logo: ExplorerLogo, |
13 | 20 | },
|
14 | 21 | climateTokenization: {
|
15 | 22 | link: "/apps/climate_tokenization_engine/index.html",
|
16 | 23 | name: "Climate Tokenization Engine",
|
| 24 | + logo: TokenizationLogo, |
17 | 25 | },
|
18 | 26 | };
|
19 | 27 |
|
20 | 28 | const App = () => {
|
21 | 29 | const [activeApp, setActiveApp] = useState(appLinks["cadt"]);
|
| 30 | + const cadtRef = useRef(null); |
| 31 | + const climateExplorerRef = useRef(null); |
| 32 | + const climateTokenizationRef = useRef(null); |
| 33 | + |
| 34 | + useEffect(() => { |
| 35 | + if (cadtRef.current) { |
| 36 | + window.cadt = cadtRef.current.contentWindow; |
| 37 | + } |
| 38 | + }, [cadtRef.current]); |
| 39 | + |
| 40 | + const themeSettings = useMemo(() => { |
| 41 | + return flowbiteThemeSettings(); |
| 42 | + }, [flowbiteThemeSettings]); |
| 43 | + |
| 44 | + const ActiveLogo = activeApp.logo; |
| 45 | + const TokenizationLogo = appLinks["climateTokenization"].logo; |
| 46 | + const ExplorerLogo = appLinks["climateExplorer"].logo; |
| 47 | + const CadtLogo = appLinks["cadt"].logo; |
22 | 48 |
|
23 | 49 | return (
|
24 |
| - <div className="App"> |
25 |
| - <header className="App-header"> |
26 |
| - <Dropdown label={activeApp.name}> |
27 |
| - <Dropdown.Item onClick={() => setActiveApp(appLinks["cadt"])}> |
28 |
| - CADT |
29 |
| - </Dropdown.Item> |
30 |
| - <Dropdown.Item |
31 |
| - onClick={() => setActiveApp(appLinks["climateTokenization"])} |
32 |
| - > |
33 |
| - Climate Tokenization Engine |
34 |
| - </Dropdown.Item> |
35 |
| - <Dropdown.Item |
36 |
| - onClick={() => setActiveApp(appLinks["climateExplorer"])} |
37 |
| - > |
38 |
| - Climate Explorer |
39 |
| - </Dropdown.Item> |
40 |
| - </Dropdown> |
41 |
| - </header> |
42 |
| - <div |
43 |
| - className="app-window" |
44 |
| - style={{ |
45 |
| - display: activeApp.name === appLinks["cadt"].name ? "block" : "none", |
46 |
| - }} |
47 |
| - > |
48 |
| - <iframe src={appLinks["cadt"].link} width="100%" height="100%"></iframe> |
49 |
| - </div> |
50 |
| - <div |
51 |
| - className="app-window" |
52 |
| - style={{ |
53 |
| - display: |
54 |
| - activeApp.name === appLinks["climateTokenization"].name |
55 |
| - ? "block" |
56 |
| - : "none", |
57 |
| - }} |
58 |
| - > |
59 |
| - <iframe |
60 |
| - src={appLinks["climateTokenization"].link} |
61 |
| - width="100%" |
62 |
| - height="100%" |
63 |
| - ></iframe> |
64 |
| - </div> |
65 |
| - <div |
66 |
| - className="app-window" |
67 |
| - style={{ |
68 |
| - display: |
69 |
| - activeApp.name === appLinks["climateExplorer"].name |
70 |
| - ? "block" |
71 |
| - : "none", |
72 |
| - }} |
73 |
| - > |
74 |
| - <iframe |
75 |
| - src={appLinks["climateExplorer"].link} |
76 |
| - width="100%" |
77 |
| - height="100%" |
78 |
| - ></iframe> |
| 50 | + <Flowbite theme={themeSettings}> |
| 51 | + <div className="App"> |
| 52 | + <header className="App-header"> |
| 53 | + <Dropdown label={<ActiveLogo />} size="lg"> |
| 54 | + <Dropdown.Item onClick={() => setActiveApp(appLinks["cadt"])}> |
| 55 | + <CadtLogo /> |
| 56 | + </Dropdown.Item> |
| 57 | + <Dropdown.Item |
| 58 | + onClick={() => setActiveApp(appLinks["climateTokenization"])} |
| 59 | + > |
| 60 | + <TokenizationLogo /> |
| 61 | + </Dropdown.Item> |
| 62 | + <Dropdown.Item |
| 63 | + onClick={() => setActiveApp(appLinks["climateExplorer"])} |
| 64 | + > |
| 65 | + <ExplorerLogo /> |
| 66 | + </Dropdown.Item> |
| 67 | + </Dropdown> |
| 68 | + </header> |
| 69 | + <div |
| 70 | + className="app-window" |
| 71 | + style={{ |
| 72 | + display: |
| 73 | + activeApp.name === appLinks["cadt"].name ? "block" : "none", |
| 74 | + }} |
| 75 | + > |
| 76 | + <iframe |
| 77 | + ref={cadtRef} |
| 78 | + src={appLinks["cadt"].link} |
| 79 | + width="100%" |
| 80 | + height="100%" |
| 81 | + ></iframe> |
| 82 | + </div> |
| 83 | + <div |
| 84 | + className="app-window" |
| 85 | + style={{ |
| 86 | + display: |
| 87 | + activeApp.name === appLinks["climateTokenization"].name |
| 88 | + ? "block" |
| 89 | + : "none", |
| 90 | + }} |
| 91 | + > |
| 92 | + <iframe |
| 93 | + ref={climateTokenizationRef} |
| 94 | + src={appLinks["climateTokenization"].link} |
| 95 | + width="100%" |
| 96 | + height="100%" |
| 97 | + ></iframe> |
| 98 | + </div> |
| 99 | + <div |
| 100 | + className="app-window" |
| 101 | + style={{ |
| 102 | + display: |
| 103 | + activeApp.name === appLinks["climateExplorer"].name |
| 104 | + ? "block" |
| 105 | + : "none", |
| 106 | + }} |
| 107 | + > |
| 108 | + <iframe |
| 109 | + ref={climateExplorerRef} |
| 110 | + src={appLinks["climateExplorer"].link} |
| 111 | + width="100%" |
| 112 | + height="100%" |
| 113 | + ></iframe> |
| 114 | + </div> |
79 | 115 | </div>
|
80 |
| - </div> |
| 116 | + </Flowbite> |
81 | 117 | );
|
82 | 118 | };
|
83 | 119 |
|
|
0 commit comments