From bcb77d979d817e1e609adb4d007bbbcc3f61efbd Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 30 Dec 2021 09:51:00 +0100 Subject: Prepare for github --- src/components/App/App.module.scss | 55 ++++++++++++++++++++++++++++++ src/components/App/App.tsx | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/components/App/App.module.scss create mode 100644 src/components/App/App.tsx (limited to 'src/components/App') diff --git a/src/components/App/App.module.scss b/src/components/App/App.module.scss new file mode 100644 index 0000000..2036eb9 --- /dev/null +++ b/src/components/App/App.module.scss @@ -0,0 +1,55 @@ +.app { + display: flex; + flex-flow: column nowrap; + grid-template-rows: auto 1fr; + height: 100vh; + overflow: hidden; +} + +.main { + display: flex; + flex-flow: row nowrap; + flex-grow: 1; + overflow: hidden; +} + +.header { + font-size: 1.2em; + display: flex; + flex-flow: row nowrap; + align-items: center; + justify-content: space-between; + background: black; + color: white; + padding: 1em; + + a { + color: white; + } +} + +.sidebar { + width: calc((6 / 16) * 100%); + height: 100%; + grid-area: sidebar; + border-right: 1px solid black; + overflow-y: auto; + + li { + border-bottom: 1px solid gray; + } +} + +.details { + width: calc((10 / 16) * 100%); + overflow: hidden; + height: 100%; +} + +.noRequest, .noRequestSelected { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx new file mode 100644 index 0000000..3a7fe9b --- /dev/null +++ b/src/components/App/App.tsx @@ -0,0 +1,68 @@ +import * as React from "react"; +import useRequests, {RequestResponse} from "../../hooks/useRequests"; +import {useEffect, useMemo, useState} from "react"; + +import styles from './App.module.scss'; +import Details from "../Details/Details"; +import RequestSummary from "../RequestSummary/RequestSummary"; +import {getHost} from "../../utils"; + +interface Config { + url: string +} + +export default function App() { + const [config, setConfig]= useState(null) + useEffect(() => { + fetch(`http://${getHost()}/config/`) + .then(response => response.json() as Promise) + .then(setConfig) + }, []) + + const requests = useRequests(); + const [selectedRequestIndex, setSelectedRequestIndex] = useState(null); + const selectedRequest = useMemo(() => ( + selectedRequestIndex === null + ? null + : requests[selectedRequestIndex] + ), [selectedRequestIndex, requests]); + + return config && ( +
+
+ TTUN + {config.url} +
+
+
    + { + requests.length > 0 + ? requests.slice(0).reverse().map((requestResponse, index) => ( +
  • setSelectedRequestIndex(requests.length - index - 1)} key={`request-${index}`}> + +
  • + )) + : ( +
    +

    No requests

    +
    + ) + } +
+ +
+ { + selectedRequest !== null + ? ( +
+ ) : ( +
+

Select a request to inspect it

+
+ ) + } +
+
+
+ ); +} -- cgit v1.2.3