@@ -25,7 +25,7 @@ module DropdownSelect = {
25
25
let opacity = disabled ? " opacity-50" : "" ;
26
26
<select
27
27
className= {
28
- "border border-night-light inline-block rounded px-4 py-1 bg-gray-100 appearance-none font-semibold "
28
+ "text-14 bg-transparent border border-night-light inline-block rounded px-4 py-1 font-semibold"
29
29
++ opacity
30
30
}
31
31
name
@@ -1228,9 +1228,33 @@ module Settings = {
1228
1228
setConfig(defaultConfig);
1229
1229
};
1230
1230
1231
+ let onCompilerSelect = id => {
1232
+ dispatch(
1233
+ SwitchToCompiler ({id, libraries: readyState. selected. libraries}),
1234
+ );
1235
+ };
1236
+
1231
1237
let titleClass = "text-18 font-bold mb-2" ;
1232
1238
<div className= "p-4 pt-8 bg-night-dark text-snow-darker" >
1233
1239
<div >
1240
+ <div className= titleClass> "ReScript Version" -> s </div >
1241
+ <DropdownSelect
1242
+ name= "compilerVersions"
1243
+ value= {readyState. selected. id}
1244
+ onChange= {evt => {
1245
+ ReactEvent . Form . preventDefault(evt);
1246
+ let id = evt-> ReactEvent . Form . target## value;
1247
+ onCompilerSelect(id);
1248
+ }}>
1249
+ {Belt . Array . map(readyState. versions, version => {
1250
+ <option className= "py-4" key= version value= version>
1251
+ version-> s
1252
+ </option >
1253
+ })
1254
+ -> ate}
1255
+ </DropdownSelect >
1256
+ </div >
1257
+ <div className= "mt-6" >
1234
1258
<div className= titleClass> "Syntax" -> s </div >
1235
1259
<ToggleSelection
1236
1260
values= availableTargetLangs
@@ -1291,6 +1315,8 @@ module ControlPanel = {
1291
1315
let children =
1292
1316
switch (state) {
1293
1317
| Init => "Initializing..." -> s
1318
+ | SwitchingCompiler (_ , _ , _ ) =>
1319
+ ("Switching Compiler..." )-> s
1294
1320
| Compiling (_ready , _ )
1295
1321
| Ready (_ready ) =>
1296
1322
let onFormatClick = evt => {
@@ -1579,7 +1605,9 @@ module OutputPanel = {
1579
1605
"flex items-center h-12 px-4 pr-16 " ++ activeClass;
1580
1606
};
1581
1607
1582
- <div className= "h-full bg-night-dark" > <Pane tabs makeTabClass /> </div >;
1608
+ <div className= "h-full bg-night-dark" >
1609
+ <Pane selected= 2 tabs makeTabClass />
1610
+ </div >;
1583
1611
};
1584
1612
};
1585
1613
@@ -1743,6 +1771,76 @@ module Button3 = {
1743
1771
| _ => [||]
1744
1772
};
1745
1773
1774
+ let controlPanel =
1775
+ switch (compilerState) {
1776
+ | Ready (ready )
1777
+ | Compiling (ready , _ )
1778
+ | SwitchingCompiler (ready , _ , _ ) =>
1779
+ let availableTargetLangs =
1780
+ Api . Version . availableLanguages(ready. selected. apiVersion);
1781
+
1782
+ let selectedTargetLang =
1783
+ switch (ready. targetLang) {
1784
+ | Res => (Api . Lang . Res , ready. selected. compilerVersion)
1785
+ | Reason => (Reason , ready. selected. reasonVersion)
1786
+ | OCaml => (OCaml , ready. selected. ocamlVersion)
1787
+ };
1788
+
1789
+ let onCompilerSelect = id => {
1790
+ compilerDispatch(
1791
+ SwitchToCompiler ({id, libraries: ready. selected. libraries}),
1792
+ );
1793
+ };
1794
+
1795
+ let onTargetLangSelect = lang => {
1796
+ compilerDispatch(
1797
+ SwitchLanguage ({lang, code: React . Ref . current(editorCode)}),
1798
+ );
1799
+ };
1800
+
1801
+ let onCompileClick = () => {
1802
+ compilerDispatch(
1803
+ CompileCode (ready. targetLang, React . Ref . current(editorCode)),
1804
+ );
1805
+ };
1806
+
1807
+ // When a new compiler version was selected, it should
1808
+ // be shown in the control panel as the currently selected
1809
+ // version, even when it is currently loading
1810
+ let compilerVersion =
1811
+ switch (compilerState) {
1812
+ | SwitchingCompiler (_ , version , _ ) => version
1813
+ | _ => ready. selected. id
1814
+ };
1815
+
1816
+ let onFormatClick = () => {
1817
+ compilerDispatch(Format (React . Ref . current(editorCode)));
1818
+ };
1819
+
1820
+ let isCompilerSwitching =
1821
+ switch (compilerState) {
1822
+ | SwitchingCompiler (_ , _ , _ ) => true
1823
+ | _ => false
1824
+ };
1825
+
1826
+ <>
1827
+ <ControlPanelOld
1828
+ isCompilerSwitching
1829
+ compilerVersion
1830
+ availableTargetLangs
1831
+ availableCompilerVersions= {ready. versions}
1832
+ selectedTargetLang
1833
+ loadedLibraries= {ready. selected. libraries}
1834
+ onCompilerSelect
1835
+ onTargetLangSelect
1836
+ onCompileClick
1837
+ onFormatClick
1838
+ />
1839
+ </>;
1840
+ | Init => "Initializing" -> s
1841
+ | SetupFailed (msg ) => <> {("Setup failed: " ++ msg)-> s} </>
1842
+ };
1843
+
1746
1844
<>
1747
1845
<Meta
1748
1846
title= "ReScript Playground"
0 commit comments