@@ -22,7 +22,7 @@ open CompilerManagerHook
22
22
module Api = RescriptCompilerApi
23
23
24
24
type layout = Column | Row
25
- type tab = JavaScript | Problems | Settings | Console
25
+ type tab = JavaScript | RenderOutput | Console | Problems | Settings
26
26
let breakingPoint = 1024
27
27
28
28
module DropdownSelect = {
@@ -1212,67 +1212,6 @@ let locMsgToCmError = (~kind: CodeMirror.Error.kind, locMsg: Api.LocMsg.t): Code
1212
1212
}
1213
1213
}
1214
1214
1215
- // module RenderOutput = {
1216
- // @react.component
1217
- // let make = (~compilerState: CompilerManagerHook.state) => {
1218
- // React.useEffect(() => {
1219
- // let code = switch compilerState {
1220
- // | Ready(ready) =>
1221
- // switch ready.result {
1222
- // | Comp(Success(_)) => ControlPanel.codeFromResult(ready.result)->Some
1223
- // | _ => None
1224
- // }
1225
- // | _ => None
1226
- // }
1227
-
1228
- // let _valid = switch code {
1229
- // | Some(code) =>
1230
- // switch RenderOutputManager.renderOutput(code) {
1231
- // | Ok(_) => true
1232
- // | Error(_) => false
1233
- // }
1234
- // | None => false
1235
- // }
1236
- // None
1237
- // }, [compilerState])
1238
-
1239
- // <div className={""}>
1240
- // <iframe
1241
- // width="100%"
1242
- // id="iframe-eval"
1243
- // className="relative w-full text-gray-20"
1244
- // srcDoc=RenderOutputManager.Frame.srcdoc
1245
- // />
1246
- // </div>
1247
-
1248
- // // switch code {
1249
- // // | Some(code) =>
1250
- // // switch RenderOutputManager.renderOutput(code) {
1251
- // // | Ok() =>
1252
- // // <iframe
1253
- // // width="100%"
1254
- // // id="iframe-eval"
1255
- // // className="relative w-full text-gray-20"
1256
- // // srcDoc=RenderOutputManager.Frame.srcdoc
1257
- // // />
1258
- // // | Error() =>
1259
- // // let code = `module App = {
1260
- // // @react.component
1261
- // // let make = () => {
1262
- // // <ModuleName />
1263
- // // }
1264
- // // }`
1265
- // // <div className={"whitespace-pre-wrap p-4 block"}>
1266
- // // <p className={"mb-2"}> {React.string("To render element create a module App")} </p>
1267
- // // <pre> {HighlightJs.renderHLJS(~code, ~darkmode=true, ~lang="rescript", ())} </pre>
1268
- // // </div>
1269
- // // }
1270
-
1271
- // // | _ => React.null
1272
- // // }
1273
- // }
1274
- // }
1275
-
1276
1215
module OutputPanel = {
1277
1216
@react.component
1278
1217
let make = (
@@ -1389,8 +1328,11 @@ module OutputPanel = {
1389
1328
1390
1329
prevSelected .current = selected
1391
1330
1331
+ let (logs , setLogs ) = React .useState (_ => [])
1332
+
1392
1333
let tabs = [
1393
- (Console , <ConsolePanel compilerState runOutput />),
1334
+ (RenderOutput , <RenderPanel runOutput compilerState clearLogs = {() => setLogs (_ => [])} />),
1335
+ (Console , <ConsolePanel logs setLogs />),
1394
1336
(JavaScript , output ),
1395
1337
(Problems , errorPane ),
1396
1338
(Settings , settingsPane ),
@@ -1416,68 +1358,51 @@ and the different jsx modes (classic and automatic).
1416
1358
module InitialContent = {
1417
1359
let original = ` module Button = {
1418
1360
@react.component
1419
- let make = (~count) => {
1361
+ let make = () => {
1362
+ let (count, setCount) = React.useState(_ => 0)
1420
1363
let times = switch count {
1421
1364
| 1 => "once"
1422
1365
| 2 => "twice"
1423
1366
| n => n->Belt.Int.toString ++ " times"
1424
1367
}
1425
1368
let text = \` Click me $\{ times\}\`
1426
1369
1427
- <button> {text->React.string} </button>
1370
+ <button onClick={_ => setCount(c => c + 1)}> {msg->React.string} </button>
1371
+ }
1372
+ }
1373
+
1374
+ module App = {
1375
+ @react.component
1376
+ let make = () => {
1377
+ <Button />
1428
1378
}
1429
1379
}
1430
1380
`
1431
1381
1432
- let since_10_1 = ` @@jsxConfig({ version: 4, mode: "automatic" })
1382
+ let since_10_1 = ` @@jsxConfig({version: 4, mode: "classic" })
1433
1383
1434
- module CounterMessage = {
1384
+ module Button = {
1435
1385
@react.component
1436
- let make = (~count, ~username=?) => {
1386
+ let make = () => {
1387
+ let (count, setCount) = React.useState(_ => 0)
1437
1388
let times = switch count {
1438
1389
| 1 => "once"
1439
1390
| 2 => "twice"
1440
- | n => Belt.Int.toString(n) ++ " times"
1441
- }
1442
-
1443
- let name = switch username {
1444
- | Some("") => "Anonymous"
1445
- | Some(name) => name
1446
- | None => "Anonymous"
1391
+ | n => n->Int.toString ++ " times"
1447
1392
}
1393
+ let msg = \` Click me $\{ times\}\`
1448
1394
1449
- <div> {React.string( \` Hello \$\{ name \} , you clicked me \` ++ times)} </div >
1395
+ <button onClick={_ => setCount(c => c + 1)}> {msg->React.string} </button >
1450
1396
}
1451
1397
}
1452
1398
1453
1399
module App = {
1454
1400
@react.component
1455
1401
let make = () => {
1456
- let (count, setCount) = React.useState(() => 0)
1457
- let (username, setUsername) = React.useState(() => "Anonymous")
1458
-
1459
- <div>
1460
- {React.string("Username: ")}
1461
- <input
1462
- type_="text"
1463
- value={username}
1464
- onChange={evt => {
1465
- evt->ReactEvent.Form.preventDefault
1466
- let username = (evt->ReactEvent.Form.target)["value"]
1467
- setUsername(_prev => username)
1468
- }}
1469
- />
1470
- <button
1471
- onClick={_evt => {
1472
- setCount(prev => prev + 1)
1473
- }}>
1474
- {React.string("Click me")}
1475
- </button>
1476
- <button onClick={_evt => setCount(_ => 0)}> {React.string("Reset")} </button>
1477
- <CounterMessage count username />
1478
- </div>
1402
+ <Button />
1479
1403
}
1480
1404
}
1405
+
1481
1406
`
1482
1407
}
1483
1408
@@ -1772,11 +1697,11 @@ let make = (~versions: array<string>) => {
1772
1697
"flex-1 items-center p-4 border-t-4 border-transparent " ++ activeClass
1773
1698
}
1774
1699
1775
- let tabs = [JavaScript , Console , Problems , Settings ]
1700
+ let tabs = [JavaScript , RenderOutput , Console , Problems , Settings ]
1776
1701
1777
1702
let headers = Belt .Array .mapWithIndex (tabs , (i , tab ) => {
1778
1703
let title = switch tab {
1779
- // | RenderOutput => "Render Output"
1704
+ | RenderOutput => "Render Output"
1780
1705
| Console => "Console"
1781
1706
| JavaScript => "JavaScript"
1782
1707
| Problems => "Problems"
0 commit comments