Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import "./App.css";
import AppFooter from "./components/App/AppFooter";
import AppHeader from "./components/App/AppHeader";
import { Container, Section, Bar } from "@column-resizer/react";
import { RefreshCw } from "react-feather";
import { decompressSharedTd } from "./share";
import { editor } from "monaco-editor";
import BaseButton from "./components/TDViewer/base/BaseButton";
import ErrorDialog from "./components/Dialogs/ErrorDialog";

const GlobalStateWrapper = () => {
Expand All @@ -46,7 +44,7 @@ const App: React.FC = () => {
const context = useContext(ediTDorContext);

const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
const [doShowJSON, setDoShowJSON] = useState(false);
const [doShowJSON, setDoShowJSON] = useState(true);
const [customBreakpointsState, setCustomBreakpointsState] = useState(0);
const tdViewerRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -165,11 +163,19 @@ const App: React.FC = () => {

return (
<main className="flex max-h-screen w-screen flex-col">
<AppHeader></AppHeader>
<AppHeader
onToggleJSON={handleToggleJSON}
isJSONVisible={doShowJSON}
/>

<div className="">
<Container className="height-adjust flex flex-col md:flex-row">
<Section minSize={550} className="w-full min-w-16 md:w-7/12">
<Section
minSize={550}
className={`w-full min-w-16 ${
doShowJSON ? "md:w-7/12" : "md:w-full"
}`}
>
<div ref={tdViewerRef} className="h-full w-full">
<TDViewer
onUndo={handleUndo}
Expand All @@ -179,23 +185,19 @@ const App: React.FC = () => {
</div>
</Section>

<Bar
size={7.5}
className="cursor-col-resize bg-gray-300 hover:bg-blue-500"
/>
{doShowJSON && (
<>
<Bar
size={7.5}
className="cursor-col-resize bg-gray-300 hover:bg-blue-500"
/>

<Section className="w-full md:w-5/12">
<JsonEditor editorRef={editorRef} />
</Section>
<Section className="w-full md:w-5/12">
<JsonEditor editorRef={editorRef} />
</Section>
</>
)}

<BaseButton
type="button"
className="fixed bottom-12 right-2 z-10 rounded-full bg-blue-500 p-4"
onClick={handleToggleJSON}
variant="empty"
>
<RefreshCw color="white" />
</BaseButton>
</Container>
</div>
<div className="fixed bottom-0 w-screen">
Expand Down
13 changes: 12 additions & 1 deletion src/components/App/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
Share,
Link,
Send,
Eye,
EyeOff,
} from "react-feather";
import editdorLogo from "../../assets/editdor.png";
import ediTDorContext from "../../context/ediTDorContext";
Expand All @@ -49,7 +51,10 @@ const INVALID_TYPE_MESSAGE =
const VALIDATION_FAILED_MESSAGE =
"The Thing Model did not pass the JSON schema validation Please make sure the Thing Model is valid according to the JSON schema before contributing it to the catalog.";

const AppHeader: React.FC = () => {
const AppHeader: React.FC<{
onToggleJSON: () => void;
isJSONVisible: boolean;
}> = ({ onToggleJSON, isJSONVisible }) => {
const context = useContext(ediTDorContext);
const td: ThingDescription = context.parsedTD;
/** States*/
Expand Down Expand Up @@ -335,6 +340,12 @@ const AppHeader: React.FC = () => {
<Settings />
<div className="text-xs">Settings</div>
</Button>
<Button onClick={onToggleJSON}>
{isJSONVisible ? <EyeOff /> : <Eye />}
<div className="text-xs">
{isJSONVisible ? "Hide Code" : "Show Code"}
</div>
</Button>
</div>
</header>
<SendTDDialog ref={sendTdDialog} currentTdId={currentTdId} />
Expand Down
Loading