dialogs sorta work now
This commit is contained in:
+36
-13
@@ -1,16 +1,24 @@
|
||||
import React from 'react';
|
||||
import React, {useContext, useLayoutEffect} from 'react';
|
||||
import {HookRouter, navigate, usePath, useRoutes} from "hookrouter";
|
||||
import {Tabs} from "./primitives/Layout";
|
||||
import {HSColorPicker} from "./primitives/Forms";
|
||||
import {Dialog, Page, Tabs} from "./primitives/Layout";
|
||||
import {IconElement} from "./primitives/Elements";
|
||||
import SettingsPage from "./pages/SettingsPage";
|
||||
import {LuciferIcon} from "./models/Icons";
|
||||
import ReactModal from "react-modal";
|
||||
import DialogContext, {DialogContextProvider, makeDialog} from "./contexts/DialogContext";
|
||||
|
||||
const routeObj: HookRouter.RouteObject = {
|
||||
"/": () => (
|
||||
<div>
|
||||
<HSColorPicker h={30} s={1} onChange={() => void (0)}/>
|
||||
</div>
|
||||
<Page>
|
||||
<Dialog title="Testdialog" buttons={[
|
||||
{icon: LuciferIcon.Check, text: "Lagre"},
|
||||
{icon: LuciferIcon.Cross, text: "Avbryt"},
|
||||
]}>
|
||||
Test
|
||||
</Dialog>
|
||||
<h1> </h1>
|
||||
<h1>Enheter</h1>
|
||||
</Page>
|
||||
),
|
||||
"/devices": () => (
|
||||
<div>
|
||||
@@ -19,12 +27,13 @@ const routeObj: HookRouter.RouteObject = {
|
||||
<IconElement icon={LuciferIcon.Bulb} caption="Kelvin 2k" color={{kelvin: 2000}}/>
|
||||
<IconElement icon={LuciferIcon.BulbGroup} caption="Kelvin 3k" color={{kelvin: 3000}}/>
|
||||
<IconElement icon={LuciferIcon.Bridge} caption="Kelvin 4k" color={{kelvin: 4000}}/>
|
||||
<IconElement caption="Kelvin 5k" color={{kelvin: 5000}}/>
|
||||
<IconElement caption="Kelvin 6k" color={{kelvin: 6000}}/>
|
||||
<IconElement caption="Kelvin 7k" color={{kelvin: 7000}}/>
|
||||
<IconElement caption="Kelvin 8k" color={{kelvin: 8000}}/>
|
||||
<IconElement caption="Kelvin 9k" color={{kelvin: 9000}}/>
|
||||
<IconElement caption="Kelvin 10k" color={{kelvin: 10000}}/>
|
||||
<IconElement icon={LuciferIcon.Cog} caption="Kelvin 5k" color={{kelvin: 5000}}/>
|
||||
<IconElement icon={LuciferIcon.Switch} caption="Kelvin 6k" color={{kelvin: 6000}}/>
|
||||
<IconElement icon={LuciferIcon.Triangle} caption="Kelvin 7k" color={{kelvin: 7000}}/>
|
||||
<IconElement icon={LuciferIcon.HexagonGroup} caption="Kelvin 8k" color={{kelvin: 8000}}/>
|
||||
<IconElement icon={LuciferIcon.Router} caption="Kelvin 9k" color={{kelvin: 9000}}/>
|
||||
<IconElement icon={LuciferIcon.Check} caption="Kelvin 10k" color={{kelvin: 10000}}/>
|
||||
<IconElement icon={LuciferIcon.Cross} caption="Kelvin 10k" color={{kelvin: 10000}}/>
|
||||
<IconElement caption="Mer" color="hs-gradient"/>
|
||||
<IconElement caption="Mer" color="k-gradient"/>
|
||||
</div>
|
||||
@@ -37,8 +46,21 @@ const routeList = ["/", "/devices", "/settings"];
|
||||
const tabNames = ["Lucifer", "Enheter", "Oppsett"];
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<DialogContextProvider>
|
||||
<AppInContext/>
|
||||
</DialogContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function AppInContext() {
|
||||
const route = useRoutes(routeObj);
|
||||
const path = usePath();
|
||||
const {dialog} = useContext(DialogContext);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
ReactModal.setAppElement("#root");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
@@ -47,7 +69,8 @@ function App() {
|
||||
onChange={i => navigate(routeList[i])}
|
||||
large boldIndex={0}
|
||||
/>
|
||||
{route || <div>B</div>}
|
||||
{route || <Page>404</Page>}
|
||||
{makeDialog(dialog)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user