Skip to content

Commit 4b7dc8b

Browse files
committed
add a 'Run' button
1 parent 9d3a72f commit 4b7dc8b

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

src/ConsolePanel.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let make = (~logs, ~appendLog) => {
2626
{switch logs {
2727
| [] =>
2828
React.string(
29-
"Add some 'Console.log' to your code and enable 'Auto-run' to see your logs here.",
29+
"Add some 'Console.log' to your code and click 'Run' or enable 'Auto-run' to see your logs here.",
3030
)
3131
| logs =>
3232
let content =

src/Playground.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ module ControlPanel = {
11531153
<ToggleButton checked=autoRun onChange={_ => dispatch(ToggleAutoRun)}>
11541154
{React.string("Auto-run")}
11551155
</ToggleButton>
1156+
<Button onClick={_ => dispatch(RunCode)}> {React.string("Run")} </Button>
11561157
<Button onClick=onFormatClick> {React.string("Format")} </Button>
11571158
<ShareButton actionIndicatorKey />
11581159
</div>

src/RenderPanel.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let make = (~validReact) => {
55
{validReact
66
? React.null
77
: React.string(
8-
"Create a React component called 'App' if you want to render it here, then enable 'Auto-run'.",
8+
"Create a React component called 'App' if you want to render it here, then click 'Run' or enable 'Auto-run'.",
99
)}
1010
<div className={validReact ? "h-full" : "h-0"}>
1111
<EvalIFrame />

src/common/CompilerManagerHook.res

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ type action =
189189
| UpdateConfig(Config.t)
190190
| AppendLog(ConsolePanel.log)
191191
| ToggleAutoRun
192+
| RunCode
192193

193194
let createUrl = (pathName, ready) => {
194195
let params = switch ready.targetLang {
@@ -350,6 +351,12 @@ let useCompilerManager = (
350351
| Ready({autoRun: false} as ready) => Compiling({...ready, autoRun: true})
351352
| _ => state
352353
}
354+
| RunCode =>
355+
switch state {
356+
| Ready({result: Comp(Success({js_code}))} as ready) =>
357+
Executing({state: {...ready, autoRun: false}, jsCode: js_code})
358+
| _ => state
359+
}
353360
}
354361
)
355362
}

src/common/CompilerManagerHook.resi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type action =
5050
| UpdateConfig(Config.t)
5151
| AppendLog(ConsolePanel.log)
5252
| ToggleAutoRun
53+
| RunCode
5354

5455
let useCompilerManager: (
5556
~initialVersion: Semver.t=?,

0 commit comments

Comments
 (0)