Skip to content

Commit 9272d9d

Browse files
committed
control panel
1 parent 0fcf8a8 commit 9272d9d

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

app/routes/TryRoute.res

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let loader = async () => {
4040
module ClientOnly = {
4141
@react.component
4242
let make = (~bundleBaseUrl, ~versions) => {
43-
<React.Suspense>
43+
<React.Suspense fallback={<div className="h-full bg-gray-100 min-h-screen" />}>
4444
<LazyPlayground bundleBaseUrl versions />
4545
</React.Suspense>
4646
}
@@ -49,7 +49,5 @@ module ClientOnly = {
4949
let default = () => {
5050
let {bundleBaseUrl, versions} = ReactRouter.useLoaderData()
5151

52-
<div className="text-gray-40 text-14 overflow-scroll">
53-
<ClientOnly bundleBaseUrl versions />
54-
</div>
52+
<ClientOnly bundleBaseUrl versions />
5553
}

src/Playground.res

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ module Api = RescriptCompilerApi
66
type layout = Column | Row
77
type tab = JavaScript | Output | Problems | Settings
88

9+
%%raw(`
10+
import "../styles/main.css";
11+
import "../styles/_hljs.css";
12+
import "../styles/utils.css";
13+
14+
import hljs from 'highlight.js/lib/core';
15+
import bash from 'highlight.js/lib/languages/bash';
16+
import css from 'highlight.js/lib/languages/css';
17+
import diff from 'highlight.js/lib/languages/diff';
18+
import javascript from 'highlight.js/lib/languages/javascript';
19+
import json from 'highlight.js/lib/languages/json';
20+
import text from 'highlight.js/lib/languages/plaintext';
21+
import html from 'highlight.js/lib/languages/xml';
22+
import rescript from 'highlightjs-rescript';
23+
24+
hljs.registerLanguage('rescript', rescript)
25+
hljs.registerLanguage('javascript', javascript)
26+
hljs.registerLanguage('css', css)
27+
hljs.registerLanguage('ts', javascript)
28+
hljs.registerLanguage('sh', bash)
29+
hljs.registerLanguage('json', json)
30+
hljs.registerLanguage('text', text)
31+
hljs.registerLanguage('html', html)
32+
hljs.registerLanguage('diff', diff)
33+
`)
34+
935
module JsxCompilation = {
1036
type t =
1137
| Plain
@@ -1242,7 +1268,7 @@ module ControlPanel = {
12421268
}
12431269
}
12441270

1245-
<div className="flex flex-row gap-x-2">
1271+
<div className="flex flex-row gap-x-2" dataTestId="control-panel">
12461272
<ToggleButton
12471273
checked=autoRun
12481274
onChange={_ => {
@@ -1577,10 +1603,12 @@ let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
15771603
)
15781604

15791605
let (keyMap, setKeyMap) = React.useState(() => {
1580-
Dom.Storage2.localStorage
1581-
->Dom.Storage2.getItem("vimMode")
1582-
->Option.map(CodeMirror.KeyMap.fromString)
1583-
->Option.getOr(CodeMirror.KeyMap.Default)
1606+
CodeMirror.KeyMap.Default
1607+
1608+
// Dom.Storage2.localStorage
1609+
// ->Dom.Storage2.getItem("vimMode")
1610+
// ->Option.map(CodeMirror.KeyMap.fromString)
1611+
// ->Option.getOr(CodeMirror.KeyMap.Default)
15841612
})
15851613

15861614
React.useEffect1(() => {
@@ -1920,7 +1948,7 @@ let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
19201948
<button key={Int.toString(i)} onClick className disabled> {title} </button>
19211949
})
19221950

1923-
<main className={"flex flex-col bg-gray-100 overflow-hidden"}>
1951+
<main className={"flex flex-col bg-gray-100 text-gray-40 text-14 overflow-scroll mt-16"}>
19241952
<ControlPanel
19251953
actionIndicatorKey={Int.toString(actionCount)}
19261954
state=compilerState
@@ -1967,7 +1995,7 @@ let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
19671995
<div
19681996
ref={ReactDOM.Ref.domRef((Obj.magic(separatorRef): React.ref<Nullable.t<Dom.element>>))}
19691997
// TODO: touch-none not applied
1970-
className={`flex items-center justify-center touch-none select-none bg-gray-70 opacity-30 hover:opacity-50 rounded-lg ${layout ==
1998+
className={`flex items-center justify-center touch-none select-none bg-gray-70 opacity-30 hover:opacity-50 rounded-lg h-full ${layout ==
19711999
Column
19722000
? "cursor-row-resize"
19732001
: "cursor-col-resize"}`}

src/common/CompilerManagerHook.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ let useCompilerManager = (
619619
| SetupFailed(_) => ()
620620
| Ready(ready) =>
621621
let url = createUrl((pathname :> string), ready)
622+
Console.log2("Updated URL: ", url)
622623
WebAPI.History.replaceState(history, ~data=JSON.Null, ~unused="", ~url)
623624
}
624625
}

0 commit comments

Comments
 (0)