Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add resizable property in playground #1908

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 35 additions & 0 deletions modelina-website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modelina-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"react-dom": "18.2.0",
"react-icons": "^4.12.0",
"react-markdown": "^8.0.7",
"react-resizable-panels": "^2.0.13",
"react-syntax-highlighter": "15.5.0",
"rehype-raw": "^6.1.1",
"rehype-slug": "^5.1.0",
Expand All @@ -45,6 +46,7 @@
"@types/node": "16.11.7",
"@types/react": "18.0.27",
"@types/react-dom": "18.0.10",
"@types/react-resizable": "^3.0.7",
"@types/react-syntax-highlighter": "^15.5.6",
"autoprefixer": "^10.4.13",
"cross-env": "^7.0.3",
Expand Down
59 changes: 33 additions & 26 deletions modelina-website/src/components/playground/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CustomError from '../CustomError';
import OutputNavigation from './OutputNavigation';
import { OptionsNavigation } from './OptionsNavigation';
import GeneratedModelsComponent from './GeneratedModels';
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";

interface ContentProps {
setNewConfig: (config: string, configValue: any, updateCode?: boolean) => void;
Expand Down Expand Up @@ -37,41 +38,47 @@ export const Content: FunctionComponent<ContentProps> = ({ setNewConfig, setNewQ

return (
<div className="h-full w-full flex">
{/* OPTIONS & EDITOR */}
<div className="h-full w-[50%] flex">
<PanelGroup direction="horizontal">
{/* OPTIONS */}
{
showOptions && <div className={`bg-[#1f2937] text-white h-full w-[100%] md:w-[40%]`}>
showOptions &&
<div className={`bg-[#1f2937] text-white h-full w-[20%]`}>
<OptionsNavigation setNewConfig={setNewConfig} />
</div>
}
<div className={`h-full ${showOptions ? "w-[60%]" : "w-full"}`}>
<div className="max-xl:col-span-2 xl:grid-cols-1 h-full">
<div className="h-full bg-code-editor-dark text-white rounded-b shadow-lg font-bold">
<MonacoEditorWrapper
value={input}
onChange={(_, change) => {
setInput(change);
generateNewCode(change);
}}
editorDidMount={() => {
setLoaded({ ...loaded, editorLoaded: true });
}}
language="json"
/>
{/* EDITOR */}
<Panel className="flex flex-row" id="left-panel">
<div className={`h-full w-full`}>
<div className="max-xl:col-span-2 xl:grid-cols-1 h-full">
<div className="h-full bg-code-editor-dark text-white rounded-b shadow-lg font-bold">
<MonacoEditorWrapper
value={input}
onChange={(_, change) => {
setInput(change);
generateNewCode(change);
}}
editorDidMount={() => {
setLoaded({ ...loaded, editorLoaded: true });
}}
language="json"
/>
</div>
</div>
</div>
</div>
</div>
</Panel>

{/* OUTPUT NAVIGATION AND OUTPUTS */}
<div className="h-full w-[50%] flex">
<PanelResizeHandle className="w-1.5 bg-blue-700" />

{/* OUTPUT NAVIGATION */}
{
showOutputNavigation && <div className='h-full w-[100%] md:w-[30%]'>
showOutputNavigation &&
<div className='h-full w-[20%]'>
<OutputNavigation />
</div>
}
<div className={`h-full ${showOutputNavigation ? "w-[70%]" : "w-full"}`}>
<div className={`h-full`}>
{/* OUTPUTS */}
<Panel className="flex flex-row" id="right-panel">
<div className={`h-full w-full`}>
{error ? (
<CustomError statusCode={statusCode} errorMessage={errorMessage} />
) : (
Expand All @@ -82,8 +89,8 @@ export const Content: FunctionComponent<ContentProps> = ({ setNewConfig, setNewQ
</PlaygroundGeneratedContext.Provider>
)}
</div>
</div>
</div>
</Panel>
</PanelGroup>
</div>
);
};
2 changes: 1 addition & 1 deletion modelina-website/src/pages/playground.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client"
"use client";
import { useEffect, useState } from 'react';
import Playground from '@/components/playground/Playground';
import GenericLayout from '@/components/layouts/GenericLayout';
Expand Down
Loading