diff --git a/src/ConsolePanel.res b/src/ConsolePanel.res index 2777aea2b..04f11d9b8 100644 --- a/src/ConsolePanel.res +++ b/src/ConsolePanel.res @@ -5,9 +5,7 @@ type logLevel = [ ] @react.component -let make = (~compilerState, ~runOutput) => { - let (logs, setLogs) = React.useState(_ => []) - +let make = (~logs, ~setLogs) => { React.useEffect(() => { let cb = e => { let data = e["data"] @@ -22,23 +20,13 @@ let make = (~compilerState, ~runOutput) => { Some(() => Webapi.Window.removeEventListener("message", cb)) }, []) - React.useEffect(() => { - if runOutput { - switch compilerState { - | CompilerManagerHook.Ready({result: Comp(Success({js_code}))}) => - setLogs(_ => []) - let ast = AcornParse.parse(js_code) - let transpiled = AcornParse.removeImportsAndExports(ast) - EvalIFrame.sendOutput(transpiled) - | _ => () - } - } - None - }, (compilerState, runOutput)) - -
+
+

{React.string("Console")}

{switch logs { - | [] => React.null + | [] => + React.string( + "Add some 'Console.log' to your code and enable 'Auto-run' to see your logs here.", + ) | logs => let content = logs @@ -56,8 +44,7 @@ let make = (~compilerState, ~runOutput) => { }) ->React.array -
content
+
content
}} -
} diff --git a/src/OutputPanel.res b/src/OutputPanel.res new file mode 100644 index 000000000..17d07ad90 --- /dev/null +++ b/src/OutputPanel.res @@ -0,0 +1,8 @@ +@react.component +let make = (~runOutput, ~compilerState, ~logs, ~setLogs) => { +
+ setLogs(_ => [])} /> +
+ +
+} diff --git a/src/Playground.res b/src/Playground.res index c42eb3be5..288a80197 100644 --- a/src/Playground.res +++ b/src/Playground.res @@ -22,7 +22,7 @@ open CompilerManagerHook module Api = RescriptCompilerApi type layout = Column | Row -type tab = JavaScript | Problems | Settings | Console +type tab = JavaScript | Output | Problems | Settings let breakingPoint = 1024 module DropdownSelect = { @@ -1204,67 +1204,6 @@ let locMsgToCmError = (~kind: CodeMirror.Error.kind, locMsg: Api.LocMsg.t): Code } } -// module RenderOutput = { -// @react.component -// let make = (~compilerState: CompilerManagerHook.state) => { -// React.useEffect(() => { -// let code = switch compilerState { -// | Ready(ready) => -// switch ready.result { -// | Comp(Success(_)) => ControlPanel.codeFromResult(ready.result)->Some -// | _ => None -// } -// | _ => None -// } - -// let _valid = switch code { -// | Some(code) => -// switch RenderOutputManager.renderOutput(code) { -// | Ok(_) => true -// | Error(_) => false -// } -// | None => false -// } -// None -// }, [compilerState]) - -//
-//