summaryrefslogtreecommitdiffstats
path: root/src/components/Content
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2022-01-23 19:25:56 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2022-01-25 22:06:58 +0100
commit2f27e222add9bf10b55971ab915ac411e81d24f0 (patch)
tree6ed9ea87932809d57d5db9d3c638a88a954ab8e2 /src/components/Content
parent51a2ac628822e96459b3d570eada953ac8927d43 (diff)
downloadclient-2f27e222add9bf10b55971ab915ac411e81d24f0.tar.gz
client-2f27e222add9bf10b55971ab915ac411e81d24f0.tar.bz2
client-2f27e222add9bf10b55971ab915ac411e81d24f0.zip
Rewritten ui to use boostrap
Diffstat (limited to 'src/components/Content')
-rw-r--r--src/components/Content/Content.module.scss29
-rw-r--r--src/components/Content/Content.tsx50
2 files changed, 13 insertions, 66 deletions
diff --git a/src/components/Content/Content.module.scss b/src/components/Content/Content.module.scss
index 8908516..4720afd 100644
--- a/src/components/Content/Content.module.scss
+++ b/src/components/Content/Content.module.scss
@@ -6,33 +6,10 @@
6 overflow: hidden; 6 overflow: hidden;
7} 7}
8 8
9.header {
10 flex-shrink: 0;
11 flex-grow: 0;
12 width: 100%;
13 display: flex;
14 padding: 0.5em;
15 background-color: black;
16 color: white;
17}
18
19.body { 9.body {
20 flex-grow: 1; 10 flex-grow: 1;
21 flex-shrink: 1; 11 flex-shrink: 1;
22 overflow-y: auto; 12 overflow-y: auto;
23
24 pre {
25 width: 100%;
26 height: 100%;
27 padding: 1em;
28 font-family: monospace;
29 overflow: auto;
30 }
31
32 iframe {
33 height: 100%;
34 width: 100%;
35 }
36} 13}
37 14
38.renderError { 15.renderError {
@@ -42,10 +19,4 @@
42 flex-flow: column nowrap; 19 flex-flow: column nowrap;
43 justify-content: center; 20 justify-content: center;
44 align-items: center; 21 align-items: center;
45
46 a {
47 margin-top: 1em;
48 text-decoration: underline;
49 color: blue;
50 }
51} 22}
diff --git a/src/components/Content/Content.tsx b/src/components/Content/Content.tsx
index cb5e6bc..0e63f30 100644
--- a/src/components/Content/Content.tsx
+++ b/src/components/Content/Content.tsx
@@ -1,19 +1,9 @@
1import styles from "~components/Details/Details.module.scss";
2import * as React from "react"; 1import * as React from "react";
3import classNames from "classnames"; 2import {Dispatch, SetStateAction, useMemo} from "react";
4import {RequestPayload, ResponsePayload} from "~hooks/useRequests"; 3import {RequestPayload, ResponsePayload} from "~hooks/useRequests";
5import {
6 Dispatch,
7 forwardRef, SetStateAction,
8 useEffect,
9 useImperativeHandle,
10 useMemo,
11 useRef,
12 useState
13} from "react";
14import ReactJson from 'react-json-view'; 4import ReactJson from 'react-json-view';
15import styles from './Content.module.scss'; 5import styles from './Content.module.scss';
16import {Col, Container, Row} from "react-bootstrap"; 6import {Button, Col, Container, Row} from "react-bootstrap";
17 7
18function getHeader(headers: { [key: string]: string }, key: string, unit?: string): string | null { 8function getHeader(headers: { [key: string]: string }, key: string, unit?: string): string | null {
19 console.log(headers, key) 9 console.log(headers, key)
@@ -37,7 +27,7 @@ interface ContentProps {
37 27
38export default function Content({ raw, setRaw, data }: ContentProps): JSX.Element { 28export default function Content({ raw, setRaw, data }: ContentProps): JSX.Element {
39 return ( 29 return (
40 <> 30 <div className={styles.content}>
41 <Container fluid className="border-bottom"> 31 <Container fluid className="border-bottom">
42 <Row className="py-3"> 32 <Row className="py-3">
43 <Col> 33 <Col>
@@ -54,7 +44,7 @@ export default function Content({ raw, setRaw, data }: ContentProps): JSX.Elemen
54 </Col> 44 </Col>
55 </Row> 45 </Row>
56 </Container> 46 </Container>
57 <Row> 47 <Row className={styles.body}>
58 {(() => { 48 {(() => {
59 try { 49 try {
60 return ContentBody({ data, raw }) 50 return ContentBody({ data, raw })
@@ -62,33 +52,13 @@ export default function Content({ raw, setRaw, data }: ContentProps): JSX.Elemen
62 return ( 52 return (
63 <div className={styles.renderError}> 53 <div className={styles.renderError}>
64 <p>Body could not be rendered</p> 54 <p>Body could not be rendered</p>
65 <a onClick={() => setRaw(true)}>View raw</a> 55 <Button variant="link" onClick={() => setRaw(true)}>View raw</Button>
66 </div> 56 </div>
67 ) 57 )
68 } 58 }
69 })()} 59 })()}
70 </Row> 60 </Row>
71 </> 61 </div >
72 // <div className={styles.content}>
73 // <div className={styles.header}>
74 // <input id='raw' type='checkbox' checked={raw} onChange={() => setRaw(!raw)}/>
75 // <label htmlFor='raw'>Raw</label>
76 // </div>
77 // <div className={styles.body}>
78 // {(() => {
79 // try {
80 // return ContentBody({ ...props, raw })
81 // } catch {
82 // return (
83 // <div className={styles.renderError}>
84 // <p>Body could not be rendered</p>
85 // <a onClick={() => setRaw(true)}>View raw</a>
86 // </div>
87 // )
88 // }
89 // })()}
90 // </div>
91 // </div>
92 ) 62 )
93}; 63};
94 64
@@ -103,7 +73,13 @@ function ContentBody({ data, raw = false }: Omit<ContentProps, 'setRaw'>) {
103 }, [data, raw]); 73 }, [data, raw]);
104 74
105 if (raw) { 75 if (raw) {
106 return <pre>{atob(data.body)}</pre> 76 return (
77 <pre className="mb-0">
78 <code>
79 {atob(data.body)}
80 </code>
81 </pre>
82 )
107 } 83 }
108 84
109 if (['application/pdf', 'text/html'].includes(contentType)) { 85 if (['application/pdf', 'text/html'].includes(contentType)) {