,
) => {
let (state, setState) = React.useState(_ => Init)
- let {pathname} = ReactRouter.useLocation()
+ let {pathname} = PlaygroundReactRouter.useLocation()
// Dispatch method for the public interface
let dispatch = React.useCallback((action: action): unit => {
diff --git a/apps/docs/src/playground/CompilerManagerHook.resi b/packages/playground/src/CompilerManagerHook.resi
similarity index 100%
rename from apps/docs/src/playground/CompilerManagerHook.resi
rename to packages/playground/src/CompilerManagerHook.resi
diff --git a/apps/docs/src/playground/ConsolePanel.res b/packages/playground/src/ConsolePanel.res
similarity index 100%
rename from apps/docs/src/playground/ConsolePanel.res
rename to packages/playground/src/ConsolePanel.res
diff --git a/apps/docs/src/playground/EvalIFrame.res b/packages/playground/src/EvalIFrame.res
similarity index 100%
rename from apps/docs/src/playground/EvalIFrame.res
rename to packages/playground/src/EvalIFrame.res
diff --git a/apps/docs/src/playground/LzString.res b/packages/playground/src/LzString.res
similarity index 100%
rename from apps/docs/src/playground/LzString.res
rename to packages/playground/src/LzString.res
diff --git a/apps/docs/src/playground/OutputPanel.res b/packages/playground/src/OutputPanel.res
similarity index 100%
rename from apps/docs/src/playground/OutputPanel.res
rename to packages/playground/src/OutputPanel.res
diff --git a/apps/docs/src/playground/Playground.res b/packages/playground/src/Playground.res
similarity index 97%
rename from apps/docs/src/playground/Playground.res
rename to packages/playground/src/Playground.res
index a45a22b86..07f0e565f 100644
--- a/apps/docs/src/playground/Playground.res
+++ b/packages/playground/src/Playground.res
@@ -37,7 +37,42 @@ module ExperimentalFeatures = {
let breakingPoint = 1024
let playgroundThemeStorageKey = "playgroundTheme"
+let playgroundVersionStorageKey = "playground_version"
let newLightModeToastSeenStorageKey = "playgroundLightModeToastSeen"
+let dropdownLabelNext = "--- Next ---"
+let dropdownLabelReleased = "--- Released ---"
+
+let getLocalStorageItem = key => {
+ try {
+ WebAPI.Storage.getItem(window.localStorage, key)->Null.toOption
+ } catch {
+ | JsExn(_) => None
+ }
+}
+
+let setLocalStorageItem = (~key, ~value) => {
+ try {
+ WebAPI.Storage.setItem(window.localStorage, ~key, ~value)
+ } catch {
+ | JsExn(_) => ()
+ }
+}
+
+let getSessionStorageItem = key => {
+ try {
+ WebAPI.Storage.getItem(window.sessionStorage, key)->Null.toOption
+ } catch {
+ | JsExn(_) => None
+ }
+}
+
+let setSessionStorageItem = (~key, ~value) => {
+ try {
+ WebAPI.Storage.setItem(window.sessionStorage, ~key, ~value)
+ } catch {
+ | JsExn(_) => ()
+ }
+}
let isDarkTheme = (theme: CodeMirror.Theme.t): bool =>
switch theme {
@@ -126,6 +161,12 @@ module ToggleSelection = {
}
}
+module SelectSectionHeader = {
+ @react.component
+ let make = (~value) =>
+
+}
+
module ResultPane = {
module PreWrap = {
@react.component
@@ -317,9 +358,13 @@ module ResultPane = {
{React.string(
"The compiler bundle API returned a result that couldn't be interpreted. Please open an issue on our ",
)}
-
+
{React.string("issue tracker")}
-
+
{React.string(".")}
@@ -960,7 +1005,7 @@ module Settings = {
switch id->Semver.parse {
| Some(v) =>
onCompilerSelect(v)
- WebAPI.Storage.setItem(localStorage, ~key=(Url.Playground :> string), ~value=id)
+ setLocalStorageItem(~key=playgroundVersionStorageKey, ~value=id)
| None => ()
}
}}
@@ -1009,7 +1054,7 @@ module Settings = {
}->Float.fromInt
})
<>
-
+
{versionByOrder
->Array.map(version => {
let version = Semver.toString(version)
@@ -1018,7 +1063,7 @@ module Settings = {
})
->React.array}
-
+
>
}}
{switch stableVersions {
@@ -1599,7 +1644,7 @@ let initialReContent = `Js.log("Hello Reason 3.6!");`
@react.component
let make = (~bundleBaseUrl: string, ~versions: array) => {
- let (searchParams, _) = ReactRouter.useSearchParams()
+ let (searchParams, _) = PlaygroundReactRouter.useSearchParams()
let containerRef = React.useRef(Nullable.null)
let editorRef: React.ref