Skip to content

Commit 6a4502f

Browse files
committed
stack the react and console panels
1 parent eb6f2e3 commit 6a4502f

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

src/ConsolePanel.res

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ let make = (~logs, ~setLogs) => {
2020
Some(() => Webapi.Window.removeEventListener("message", cb))
2121
}, [])
2222

23-
<div>
23+
<div className="px-2 py-6 relative">
24+
<h2 className="font-bold text-gray-5/50 absolute right-2 top-2"> {React.string("Console")} </h2>
2425
{switch logs {
2526
| [] =>
26-
<div className="m-2">
27-
{React.string(
28-
"Add some 'Console.log' to your code and enable 'Auto-run' to see your logs here.",
29-
)}
30-
</div>
27+
React.string(
28+
"Add some 'Console.log' to your code and enable 'Auto-run' to see your logs here.",
29+
)
3130
| logs =>
3231
let content =
3332
logs

src/OutputPanel.res

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@react.component
2+
let make = (~runOutput, ~compilerState, ~logs, ~setLogs) => {
3+
<div className="h-full">
4+
<RenderPanel runOutput compilerState clearLogs={() => setLogs(_ => [])} />
5+
<hr className="border-gray-60" />
6+
<ConsolePanel logs setLogs />
7+
</div>
8+
}

src/Playground.res

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ open CompilerManagerHook
2222
module Api = RescriptCompilerApi
2323

2424
type layout = Column | Row
25-
type tab = JavaScript | RenderOutput | Console | Problems | Settings
25+
type tab = JavaScript | Output | Problems | Settings
2626
let breakingPoint = 1024
2727

2828
module DropdownSelect = {
@@ -1331,8 +1331,7 @@ module OutputPanel = {
13311331
let (logs, setLogs) = React.useState(_ => [])
13321332

13331333
let tabs = [
1334-
(RenderOutput, <RenderPanel runOutput compilerState clearLogs={() => setLogs(_ => [])} />),
1335-
(Console, <ConsolePanel logs setLogs />),
1334+
(Output, <OutputPanel runOutput compilerState logs setLogs />),
13361335
(JavaScript, output),
13371336
(Problems, errorPane),
13381337
(Settings, settingsPane),
@@ -1714,12 +1713,11 @@ let make = (~versions: array<string>) => {
17141713
"flex-1 items-center p-4 border-t-4 border-transparent " ++ activeClass
17151714
}
17161715

1717-
let tabs = [JavaScript, RenderOutput, Console, Problems, Settings]
1716+
let tabs = [JavaScript, Output, Problems, Settings]
17181717

17191718
let headers = Belt.Array.mapWithIndex(tabs, (i, tab) => {
17201719
let title = switch tab {
1721-
| RenderOutput => "Render Output"
1722-
| Console => "Console"
1720+
| Output => "Output"
17231721
| JavaScript => "JavaScript"
17241722
| Problems => "Problems"
17251723
| Settings => "Settings"

src/RenderPanel.res

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ let make = (~compilerState: CompilerManagerHook.state, ~clearLogs, ~runOutput) =
2525
None
2626
}, (compilerState, runOutput))
2727

28-
<div className="p-2">
28+
<div className={`px-2 relative ${validReact ? "h-1/2 py-2" : "h-auto py-6"}`}>
29+
<h2 className="font-bold text-gray-5/50 absolute right-2 top-2"> {React.string("React")} </h2>
2930
{validReact
3031
? React.null
3132
: React.string(
3233
"Create a React component called 'App' if you want to render it here, then enable 'Auto-run'.",
3334
)}
34-
<EvalIFrame />
35+
<div className={validReact ? "h-full" : "h-0"}>
36+
<EvalIFrame />
37+
</div>
3538
</div>
3639
}

0 commit comments

Comments
 (0)