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 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
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
92 changes: 49 additions & 43 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,53 +38,58 @@ export const Content: FunctionComponent<ContentProps> = ({ setNewConfig, setNewQ

return (
<div className="h-full w-full flex">
{/* OPTIONS & EDITOR */}
<div className="h-full w-[50%] flex">
{
showOptions && <div className={`bg-[#1f2937] text-white h-full w-[100%] md:w-[40%]`}>
<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"
/>
<PanelGroup direction="horizontal">
{/* OPTIONS & EDITOR */}
<Panel className="flex flex-row" id="left-panel">
{
showOptions &&
<div className={`bg-[#1f2937] text-white h-full w-[100%] md:w-[40%]`}>
<OptionsNavigation setNewConfig={setNewConfig} />
</div>
}
<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">
{
showOutputNavigation && <div className='h-full w-[100%] md:w-[30%]'>
<OutputNavigation />
</div>
}
<div className={`h-full ${showOutputNavigation ? "w-[70%]" : "w-full"}`}>
<div className={`h-full`}>
{error ? (
<CustomError statusCode={statusCode} errorMessage={errorMessage} />
) : (
<PlaygroundGeneratedContext.Provider
value={PlaygroundGeneratedContextValue}
>
<GeneratedModelsComponent setNewQuery={setNewQuery} />
</PlaygroundGeneratedContext.Provider>
)}
<PanelResizeHandle />

{/* OUTPUT NAVIGATION AND OUTPUTS */}
<Panel className="flex flex-row" id="right-panel" minSize={4}>
{
showOutputNavigation && <div className='h-full w-[100%] md:w-[30%]'>
<OutputNavigation />
</div>
}
<div className={`h-full ${showOutputNavigation ? "w-[70%]" : "w-full"}`}>
<div className={`h-full`}>
{error ? (
<CustomError statusCode={statusCode} errorMessage={errorMessage} />
) : (
<PlaygroundGeneratedContext.Provider
value={PlaygroundGeneratedContextValue}
>
<GeneratedModelsComponent setNewQuery={setNewQuery} />
</PlaygroundGeneratedContext.Provider>
)}
</div>
</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