Skip to content

Commit 0d7ed8a

Browse files
committed
fix sandbox
1 parent 273952e commit 0d7ed8a

29 files changed

+835
-1877
lines changed

packages/tdb-documents-ui/sandbox/src/.env_example

Whitespace-only changes.

packages/tdb-documents-ui/sandbox/src/App.css

Lines changed: 0 additions & 1338 deletions
This file was deleted.

packages/tdb-documents-ui/sandbox/src/App.js

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React, {useState} from 'react'
2+
import SyntaxHighlighter from 'react-syntax-highlighter'
3+
import { vs2015 } from 'react-syntax-highlighter/dist/esm/styles/hljs'
4+
5+
export const DisplayCode = ({ codeString }) => {
6+
return <SyntaxHighlighter language="javascript" style={vs2015} wrapLines={true}>
7+
{codeString}
8+
</SyntaxHighlighter>
9+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React, { useState } from "react"
2+
import { FrameObj } from "./frameInit"
3+
import Nav from 'react-bootstrap/Nav';
4+
5+
export const DocumentTypes = () => {
6+
const [activeKey, setActiveKey] = useState("Theme")
7+
const {
8+
frames,
9+
setType
10+
} = FrameObj()
11+
12+
if(!frames) return <div/>
13+
let docTypes = []
14+
15+
function handleNavClick(selectedKey) {
16+
setActiveKey(selectedKey)
17+
setType(selectedKey)
18+
}
19+
20+
for(let docs in frames) {
21+
// display on classes
22+
if(frames[docs].hasOwnProperty("@type") &&
23+
frames[docs]["@type"] === "Class" &&
24+
!frames[docs].hasOwnProperty("@subdocument")) {
25+
docTypes.push(<Nav.Item>
26+
<Nav.Link eventKey={docs}>{docs}</Nav.Link>
27+
</Nav.Item>)
28+
}
29+
}
30+
31+
return <Nav
32+
activeKey={activeKey}
33+
variant="pills"
34+
className="mb-4"
35+
onSelect={(selectedKey) => handleNavClick(selectedKey)}
36+
>
37+
{docTypes}
38+
</Nav>
39+
40+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { useEffect, useState } from "react"
2+
import Accordion from 'react-bootstrap/Accordion'
3+
import { SubmittedData } from "./SubmittedData"
4+
import { FrameEditor } from "./FrameEditor"
5+
6+
7+
export const Editor = () => {
8+
const [activeKey, setActiveKey]=useState("Frames")
9+
10+
function handleSelect(key) {
11+
setActiveKey(key)
12+
}
13+
14+
return <Accordion onSelect={handleSelect}>
15+
<Accordion.Item eventKey={"Frames"}>
16+
<Accordion.Header className='bg-secondary'>{"Frames"}</Accordion.Header>
17+
<Accordion.Body className='bg-secondary'>
18+
<FrameEditor/>
19+
</Accordion.Body>
20+
</Accordion.Item>
21+
<Accordion.Item eventKey={"Submitted Data"}>
22+
<Accordion.Header className='bg-secondary'>{"Submitted Data"}</Accordion.Header>
23+
<Accordion.Body className='bg-secondary'>
24+
<SubmittedData/>
25+
</Accordion.Body>
26+
</Accordion.Item>
27+
</Accordion>
28+
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from "react"
2+
import { FrameObj } from "./frameInit"
3+
import JSONInput from 'react-json-editor-ajrm'
4+
import locale from 'react-json-editor-ajrm/locale/en'
5+
6+
export const FrameEditor = () => {
7+
const {
8+
frames,
9+
setFrames
10+
} = FrameObj()
11+
12+
if(!frames) return <Loading/>
13+
14+
function handleInput (data) {
15+
setFrames(data.jsObject)
16+
}
17+
if(!frames) return <div/>
18+
//JSON Editor dimensions
19+
return <JSONInput
20+
id='json_type_field'
21+
locale={ locale }
22+
placeholder={frames}
23+
height= {"550px"}
24+
width= {"380px"}
25+
onBlur={handleInput}
26+
/>
27+
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import { Container, Row, Col, Stack } from 'react-bootstrap';
3+
import { View } from "./View"
4+
import { ModeBar } from "./ModeBar"
5+
import { DocumentTypes } from "./DocumentTypes"
6+
import { Editor } from './Editors';
7+
import { MoreInfo } from "./MoreInfoCanvas"
8+
9+
const App= (props) =>{
10+
11+
12+
return <Container fluid="xxl" className='mt-5'>
13+
<h3 className='text-success'>{`Parts & Components Inventory`}</h3>
14+
<h5 className='mb-4 text-muted'>{`This data product features Lego sets and their individual components and the relationships between them.
15+
It is an excellent example of organizations that have interconnected components and parts within their product offerings.`}
16+
</h5>
17+
<DocumentTypes/>
18+
<MoreInfo/>
19+
<Row>
20+
<Col md={4}>
21+
<ModeBar/>
22+
<Editor/>
23+
</Col>
24+
<Col md={8}><View/></Col>
25+
</Row>
26+
</Container>
27+
28+
}
29+
30+
export default App
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useState } from 'react'
2+
import Stack from 'react-bootstrap/Stack'
3+
import Offcanvas from 'react-bootstrap/Offcanvas'
4+
import { DisplayCode } from "./DisplayCode"
5+
import { Button } from "react-bootstrap"
6+
import { FrameObj } from "./frameInit"
7+
8+
/**
9+
*
10+
* @param {*} code - function is called to copy example code to clipboard
11+
*/
12+
function copyToClipboard (code) {
13+
navigator.clipboard.writeText(code).then(() => {
14+
console.log("copied code", code)
15+
},(err) => {
16+
/* Rejected - clipboard failed */
17+
console.log("err", err)
18+
})
19+
}
20+
21+
export const MoreInfo = () => {
22+
const {
23+
code,
24+
setShowCode,
25+
showCode
26+
} = FrameObj()
27+
28+
//if(!showCode) return <div/>
29+
30+
const handleClose = () => setShowCode(false)
31+
32+
return <Offcanvas show={showCode} onHide={handleClose} key={"more-info"} placement={"end"} name={"more-info"} style={{width: "900px"}}>
33+
<Offcanvas.Header closeButton className="bg-light text-dark">
34+
<Offcanvas.Title>Code</Offcanvas.Title>
35+
</Offcanvas.Header>
36+
<Offcanvas.Body className='bg-secondary'>
37+
<Stack direction="horizontal" gap={3} className="mt-4 mb-4">
38+
{/*<h6>Click <a href={link}> here </a> to check out documentation</h6>*/}
39+
<Button variant="primary"
40+
title="Copy to clipboard"
41+
className="btn btn-sm ms-auto"
42+
style={{float: "right"}}
43+
onClick={(e) => copyToClipboard(code)}>
44+
<label>Copy Code</label>
45+
</Button>
46+
</Stack>
47+
<DisplayCode codeString={code}/>
48+
</Offcanvas.Body>
49+
</Offcanvas>
50+
}
51+
52+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react"
2+
import Row from "react-bootstrap/Row"
3+
4+
/** component to display */
5+
export const Search = ({ setSelected }) => {
6+
7+
function handleClick(e){
8+
if(setSelected) setSelected({ id: e.target.id, label: e.target.name })
9+
}
10+
11+
return <>
12+
Search this dummy result ....
13+
<Row className="w-100 border" id={"ID 1"} name="first id" onClick={handleClick}>{"ID 1"}</Row>
14+
<Row className="w-100 border" id={"ID 2"} name="second id" onClick={handleClick}>{"ID 2"}</Row>
15+
<Row className="w-100 border" id={"ID 3"} name="third id" onClick={handleClick}>{"ID 3"}</Row>
16+
</>
17+
}

0 commit comments

Comments
 (0)