@@ -59,10 +59,15 @@ let playgroundThemeClass = (theme: CodeMirror.Theme.t): string =>
5959
6060module DropdownSelect = {
6161 @react.component
62- let make = (~onChange , ~name , ~value , ~disabled = false , ~children ) => {
62+ let make = (~onChange , ~name , ~value , ~theme , ~disabled = false , ~children ) => {
63+ let themeClass = switch theme {
64+ | CodeMirror .Theme .Dark => "bg-gray-100 border-gray-80 text-gray-20"
65+ | CodeMirror .Theme .Light => "bg-white border-gray-30 text-gray-80"
66+ }
6367 let opacity = disabled ? " opacity-50" : ""
6468 <select
65- className = {"playground-select text-14 border inline-block rounded px-4 py-1 font-semibold" ++
69+ className = {"playground-select text-14 border inline-block rounded px-4 py-1 font-semibold " ++
70+ themeClass ++
6671 opacity }
6772 name
6873 value
@@ -76,12 +81,16 @@ module DropdownSelect = {
7681
7782module SelectionOption = {
7883 @react.component
79- let make = (~label , ~isActive , ~disabled , ~onClick ) => {
84+ let make = (~label , ~isActive , ~disabled , ~onClick , ~theme ) => {
85+ let inactiveClass = switch theme {
86+ | CodeMirror .Theme .Dark => "bg-gray-80 opacity-50 hover:opacity-80 text-gray-20"
87+ | CodeMirror .Theme .Light => "bg-gray-10 border border-gray-30 text-gray-80 hover:bg-gray-20"
88+ }
8089 <button
8190 className = {"playground-selection-option mr-1 px-2 py-1 rounded inline-block " ++ if isActive {
8291 "playground-selection-option-active font-bold"
8392 } else {
84- "opacity-50 hover:opacity-80"
93+ inactiveClass
8594 }}
8695 onClick
8796 disabled
@@ -97,6 +106,7 @@ module ToggleSelection = {
97106 ~onChange : 'a => unit ,
98107 ~values : array <'a >,
99108 ~toLabel : 'a => string ,
109+ ~theme : CodeMirror .Theme .t ,
100110 ~selected : 'a ,
101111 ~disabled = false ,
102112 ) => {
@@ -119,7 +129,7 @@ module ToggleSelection = {
119129 }
120130 }
121131
122- <SelectionOption key = {label } label isActive onClick disabled />
132+ <SelectionOption key = {label } label isActive onClick disabled theme />
123133 })
124134 -> React .array }
125135 </div >
@@ -954,6 +964,7 @@ module Settings = {
954964 <DropdownSelect
955965 name = "compilerVersions"
956966 value = {Semver .toString (readyState .selected .id )}
967+ theme
957968 onChange = {evt => {
958969 ReactEvent .Form .preventDefault (evt )
959970 let id : string = (evt -> ReactEvent .Form .target )["value" ]
@@ -1041,6 +1052,7 @@ module Settings = {
10411052 <ToggleSelection
10421053 values = availableTargetLangs
10431054 toLabel = {lang => lang -> Api .Lang .toExt -> String .toUpperCase }
1055+ theme
10441056 selected = readyState .targetLang
10451057 onChange = onTargetLangSelect
10461058 />
@@ -1052,6 +1064,7 @@ module Settings = {
10521064 <div className = titleClass > {React .string ("Use Vim Keymap" )} </div >
10531065 <ToggleSelection
10541066 values = [CodeMirror .KeyMap .Default , CodeMirror .KeyMap .Vim ]
1067+ theme
10551068 toLabel = {enabled =>
10561069 switch enabled {
10571070 | CodeMirror .KeyMap .Vim => "On"
@@ -1065,6 +1078,7 @@ module Settings = {
10651078 <div className = titleClass > {React .string ("Module-System" )} </div >
10661079 <ToggleSelection
10671080 values = ["commonjs" , "esmodule" ]
1081+ theme
10681082 toLabel = {value => value }
10691083 selected = config .moduleSystem
10701084 onChange = onModuleSystemUpdate
@@ -1074,6 +1088,7 @@ module Settings = {
10741088 <div className = titleClass > {React .string ("Playground Theme" )} </div >
10751089 <ToggleSelection
10761090 values = [CodeMirror .Theme .Dark , CodeMirror .Theme .Light ]
1091+ theme
10771092 toLabel = themeLabel
10781093 selected = theme
10791094 onChange = {value => setTheme (_ => value )}
@@ -1085,6 +1100,7 @@ module Settings = {
10851100 <div className = titleClass > {React .string ("JSX" )} </div >
10861101 <ToggleSelection
10871102 values = [JsxCompilation .Plain , PreserveJsx ]
1103+ theme
10881104 toLabel = JsxCompilation .getLabel
10891105 selected = {config .jsxPreserveMode -> Option .getOr (false )-> JsxCompilation .fromBool }
10901106 onChange = onJsxPreserveModeUpdate
@@ -1099,6 +1115,7 @@ module Settings = {
10991115 <SelectionOption
11001116 key
11011117 disabled = false
1118+ theme
11021119 label = {feature -> ExperimentalFeatures .getLabel }
11031120 isActive = {config .experimentalFeatures
11041121 -> Option .getOr ([])
@@ -1227,6 +1244,7 @@ module ControlPanel = {
12271244 let make = (
12281245 ~actionIndicatorKey : string ,
12291246 ~state : CompilerManagerHook .state ,
1247+ ~theme : CodeMirror .Theme .t ,
12301248 ~dispatch : CompilerManagerHook .action => unit ,
12311249 ~editorRef : React .ref <option <CodeMirror .editorInstance >>,
12321250 ~setCurrentTab : (tab => tab ) => unit ,
@@ -1283,6 +1301,7 @@ module ControlPanel = {
12831301 <div className = "flex flex-row gap-x-2" dataTestId = "control-panel" >
12841302 <ToggleButton
12851303 checked = autoRun
1304+ isLightTheme = {! isDarkTheme (theme )}
12861305 onChange = {_ => {
12871306 switch state {
12881307 | Ready ({autoRun : false }) => setCurrentTab (_ => Output )
@@ -2158,6 +2177,7 @@ let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
21582177 <ControlPanel
21592178 actionIndicatorKey = {Int .toString (actionCount )}
21602179 state = compilerState
2180+ theme
21612181 dispatch = compilerDispatch
21622182 setCurrentTab
21632183 editorRef
0 commit comments