Skip to content

Commit b922845

Browse files
committed
Improve nav & editor layout, make naive mobile version available
1 parent 768f29d commit b922845

File tree

4 files changed

+97
-102
lines changed

4 files changed

+97
-102
lines changed

components/CodeMirror2.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ if (typeof window !== "undefined" && typeof window.navigator !== "undefined") {
2020
}
2121
|};
2222

23-
let useWindowWidth: unit => option(int) = [%raw
23+
let useWindowWidth: unit => int = [%raw
2424
{j| () => {
2525
const isClient = typeof window === 'object';
2626
2727
function getSize() {
2828
return {
29-
width: isClient ? window.innerWidth : undefined,
30-
height: isClient ? window.innerHeight : undefined
29+
width: isClient ? window.innerWidth : 0,
30+
height: isClient ? window.innerHeight : 0
3131
};
3232
}
3333

components/Navigation.re

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
479479
style={Style.make(~minWidth, ())}
480480
className={
481481
fixedNav
482-
++ " flex xs:justify-center w-full h-18 bg-night-dark shadow text-white-80 text-base"
482+
++ " flex xs:justify-center w-full h-18 bg-gray-95 shadow text-white-80 text-base"
483483
}>
484484
<div
485485
className="flex justify-between mx-4 md:mx-8 items-center h-full w-full max-w-1280">
@@ -490,13 +490,9 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
490490
<img src="/static/[email protected]" />
491491
</a>
492492
</div>
493-
/*<img*/
494-
/*className="inline-block w-full h-full"*/
495-
/*src="/static/reason_logo.svg"*/
496-
/*/>*/
497493
/* Desktop horizontal navigation */
498494
<div
499-
className="flex items-center xs:justify-end w-full bg-night-dark sm:h-auto sm:relative">
495+
className="flex items-center xs:justify-end w-full bg-gray-95 sm:h-auto sm:relative">
500496
<div
501497
className="flex ml-10 w-full max-w-320"
502498
style={Style.make(~maxWidth="26rem", ())}>
@@ -591,7 +587,7 @@ let make = (~fixed=true, ~overlayState: (bool, (bool => bool) => unit)) => {
591587
style={Style.make(~minWidth, ~top="4.5rem", ())}
592588
className={
593589
(isOverlayOpen ? "flex" : "hidden")
594-
++ " sm:hidden flex-col fixed top-0 left-0 h-full w-full sm:w-9/12 bg-night-dark sm:h-auto sm:flex sm:relative sm:flex-row sm:justify-between"
590+
++ " sm:hidden flex-col fixed top-0 left-0 h-full w-full z-20 sm:w-9/12 bg-gray-100 sm:h-auto sm:flex sm:relative sm:flex-row sm:justify-between"
595591
}>
596592
<MobileNav route />
597593
</div>

re_pages/Playground.re

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module DropdownSelect = {
2525
let opacity = disabled ? " opacity-50" : "";
2626
<select
2727
className={
28-
"border border-night-light inline-block rounded px-4 py-1 bg-onyx appearance-none font-semibold "
28+
"border border-night-light inline-block rounded px-4 py-1 bg-gray-100 appearance-none font-semibold "
2929
++ opacity
3030
}
3131
name
@@ -114,7 +114,7 @@ module Pane = {
114114
let defaultMakeTabClass = (active: bool): string => {
115115
let rest =
116116
active
117-
? "text-fire font-medium bg-onyx hover:cursor-default"
117+
? "text-fire font-medium bg-gray-100 hover:cursor-default"
118118
: "hover:cursor-pointer";
119119

120120
"flex items-center h-12 px-4 pr-24 " ++ rest;
@@ -181,7 +181,7 @@ module Pane = {
181181
Belt.Array.mapWithIndex(
182182
tabs,
183183
(i, tab) => {
184-
let className = current === i ? "block" : "hidden";
184+
let className = current === i ? "block h-full" : "hidden";
185185

186186
<div key={Belt.Int.toString(i)} className> {tab.content} </div>;
187187
},
@@ -435,7 +435,7 @@ module ResultPane = {
435435
| Comp(Success({warnings, time})) =>
436436
if (Array.length(warnings) === 0) {
437437
let ms = Belt.Float.toInt(time)->Belt.Int.toString ++ " ms";
438-
<PreWrap> {("0 Errors, 0 Warnings, built in " ++ ms)->s} </PreWrap>;
438+
<PreWrap> "0 Errors, 0 Warnings"->s </PreWrap>;
439439
} else {
440440
filterHighlightedLocWarnings(~focusedRowCol, warnings)
441441
->Belt.Array.mapWithIndex((i, warning) => {
@@ -1081,7 +1081,7 @@ module MiscPanel = {
10811081
Belt.Option.map(suggestions, elements => {
10821082
<div
10831083
ref={ReactDOMRe.Ref.domRef(listboxRef)}
1084-
className="p-2 absolute overflow-auto z-50 border-b rounded border-l border-r block w-full bg-onyx"
1084+
className="p-2 absolute overflow-auto z-50 border-b rounded border-l border-r block w-full bg-gray-100"
10851085
style={ReactDOMRe.Style.make(~maxHeight="15rem", ())}>
10861086
elements
10871087
</div>
@@ -1300,7 +1300,7 @@ module ControlPanel = {
13001300
| None => None
13011301
};
13021302

1303-
<div className="flex bg-onyx text-night-light px-6 text-14 w-full">
1303+
<div className="flex bg-gray-100 text-night-light px-6 text-14 w-full">
13041304
<div
13051305
className="flex justify-between items-center border-t py-4 border-night-60 w-full">
13061306
<div>
@@ -1468,10 +1468,10 @@ module OutputPanel = {
14681468
style={ReactDOMRe.Style.make(~height="calc(100vh - 9rem)", ())}>
14691469
resultPane
14701470
codeElement
1471-
<div className="absolute bottom-0 w-full">
1472-
<Statusbar actionIndicatorKey state=compilerState />
1473-
</div>
14741471
</div>;
1472+
/*<div className="absolute bottom-0 w-full">*/
1473+
/*<Statusbar actionIndicatorKey state=compilerState />*/
1474+
/*</div>*/
14751475
/*resultPane*/
14761476

14771477
let errorPane =
@@ -1560,6 +1560,8 @@ let default = () => {
15601560

15611561
let overlayState = React.useState(() => false);
15621562

1563+
let windowWidth = CodeMirror2.useWindowWidth();
1564+
15631565
// The user can focus an error / warning on a specific line & column
15641566
// which is stored in this ref and triggered by hover / click states
15651567
// in the CodeMirror editor
@@ -1781,91 +1783,89 @@ module Button3 = {
17811783
title="ReScript Playground"
17821784
description="Try ReScript in the browser"
17831785
/>
1784-
<div className="text-16 pt-2 bg-night-dark">
1786+
<Next.Head>
1787+
<style> {j|body { background-color: #010427; } |j}->s </style>
1788+
</Next.Head>
1789+
<div className="text-16 bg-gray-100">
17851790
<div className="text-night text-14">
17861791
<Navigation fixed=false overlayState />
1787-
/* MOBILE PLACEHOLDER */
1788-
<div className="block lg:hidden h-screen text-snow-darker text-center">
1789-
<div className="font-bold mb-4">
1790-
"Mobile Playground version not available yet."->s
1791-
</div>
1792-
<div>
1793-
"Please use a screen with at least 1024px width for the desktop version"
1794-
->s
1795-
</div>
1796-
</div>
1797-
/* DESKTOP */
17981792
<main
1799-
className="hidden lg:block mt-4 bg-onyx overflow-hidden h-screen"
1800-
style={ReactDOMRe.Style.make(~maxHeight="calc(100vh - 6rem)", ())}>
1801-
<div className="flex justify-center">
1802-
<div className="w-full flex border-t-4 border-night">
1803-
<div
1804-
className="w-full border-r-4 pl-2 border-night"
1805-
style={ReactDOMRe.Style.make(~maxWidth="65%", ())}>
1806-
<div className="bg-onyx text-snow-darker">
1807-
<CodeMirror2
1808-
className="w-full pb-4"
1809-
minHeight="calc(100vh - 10.5rem)"
1810-
maxHeight="calc(100vh - 10.5rem)"
1811-
mode="reason"
1812-
errors=cmErrors
1813-
value={React.Ref.current(editorCode)}
1814-
onChange={value => {
1815-
React.Ref.setCurrent(editorCode, value);
1816-
1817-
switch (React.Ref.current(typingTimer)) {
1818-
| None => ()
1819-
| Some(timer) => Js.Global.clearTimeout(timer)
1820-
};
1821-
let timer =
1822-
Js.Global.setTimeout(
1823-
() => {
1824-
(React.Ref.current(timeoutCompile))();
1825-
React.Ref.setCurrent(typingTimer, None);
1826-
},
1827-
100,
1828-
);
1829-
React.Ref.setCurrent(typingTimer, Some(timer));
1830-
}}
1831-
onMarkerFocus={rowCol => {
1832-
setFocusedRowCol(prev => {Some(rowCol)})
1833-
}}
1834-
onMarkerFocusLeave={_ => {setFocusedRowCol(_ => None)}}
1835-
/>
1836-
</div>
1793+
className="bg-gray-100 lg:overflow-hidden lg:h-screen"
1794+
style={ReactDOMRe.Style.make(~maxHeight="calc(100vh - 4.5rem)", ())}>
1795+
<div
1796+
className="w-full h-full flex flex-col lg:flex-row border-t-4 border-night">
1797+
<div className="w-full lg:border-r-4 pl-2 border-night">
1798+
<div className="bg-gray-100 text-snow-darker">
1799+
<CodeMirror2
1800+
className="w-full py-4"
1801+
minHeight="calc(100vh - 6rem)"
1802+
maxHeight="calc(100vh - 6rem)"
1803+
mode="reason"
1804+
errors=cmErrors
1805+
value={React.Ref.current(editorCode)}
1806+
onChange={value => {
1807+
React.Ref.setCurrent(editorCode, value);
1808+
1809+
switch (React.Ref.current(typingTimer)) {
1810+
| None => ()
1811+
| Some(timer) => Js.Global.clearTimeout(timer)
1812+
};
1813+
let timer =
1814+
Js.Global.setTimeout(
1815+
() => {
1816+
(React.Ref.current(timeoutCompile))();
1817+
React.Ref.setCurrent(typingTimer, None);
1818+
},
1819+
100,
1820+
);
1821+
React.Ref.setCurrent(typingTimer, Some(timer));
1822+
}}
1823+
onMarkerFocus={rowCol => {
1824+
setFocusedRowCol(prev => {Some(rowCol)})
1825+
}}
1826+
onMarkerFocusLeave={_ => {setFocusedRowCol(_ => None)}}
1827+
/>
18371828
</div>
1838-
<div
1839-
className="w-1/2"
1840-
style={ReactDOMRe.Style.make(~maxWidth="56rem", ())}>
1841-
<OutputPanel
1829+
</div>
1830+
<div
1831+
className="relative w-full overflow-x-hidden h-screen lg:h-auto lg:w-1/2"
1832+
style={ReactDOMRe.Style.make(
1833+
~maxWidth=windowWidth > 1024 ? "56rem" : "100%",
1834+
(),
1835+
)}>
1836+
<OutputPanel
1837+
actionIndicatorKey={Belt.Int.toString(actionCount)}
1838+
compilerDispatch
1839+
compilerState
1840+
/>
1841+
<div className="absolute bottom-0 w-full">
1842+
<Statusbar
18421843
actionIndicatorKey={Belt.Int.toString(actionCount)}
1843-
compilerDispatch
1844-
compilerState
1844+
state=compilerState
18451845
/>
1846-
{switch (compilerState) {
1847-
| Ready(ready)
1848-
| Compiling(ready, _)
1849-
| SwitchingCompiler(ready, _, _) =>
1850-
let disabled =
1851-
switch (compilerState) {
1852-
| SwitchingCompiler(_, _, _) => true
1853-
| _ => false
1854-
};
1855-
let config = ready.selected.config;
1856-
let setConfig = config => {
1857-
compilerDispatch(UpdateConfig(config));
1858-
};
1859-
1860-
<div />;
1861-
/*<MiscPanel*/
1862-
/*disabled*/
1863-
/*className="border-t-4 border-night"*/
1864-
/*/>;*/
1865-
| Init
1866-
| SetupFailed(_) => React.null
1867-
}}
18681846
</div>
1847+
{switch (compilerState) {
1848+
| Ready(ready)
1849+
| Compiling(ready, _)
1850+
| SwitchingCompiler(ready, _, _) =>
1851+
let disabled =
1852+
switch (compilerState) {
1853+
| SwitchingCompiler(_, _, _) => true
1854+
| _ => false
1855+
};
1856+
let config = ready.selected.config;
1857+
let setConfig = config => {
1858+
compilerDispatch(UpdateConfig(config));
1859+
};
1860+
1861+
<div />;
1862+
/*<MiscPanel*/
1863+
/*disabled*/
1864+
/*className="border-t-4 border-night"*/
1865+
/*/>;*/
1866+
| Init
1867+
| SetupFailed(_) => React.null
1868+
}}
18691869
</div>
18701870
</div>
18711871
</main>

styles/cm.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
.cm-s-material.CodeMirror {
2424
/*background-color: #263238;*/
25-
@apply font-mono py-8;
25+
@apply font-mono; /*py-8;*/
2626
}
2727

2828
.cm-s-material .CodeMirror-gutters {
@@ -32,10 +32,9 @@
3232
color: inherit;
3333
}
3434

35-
.CodeMirror pre.CodeMirror-line,
36-
.CodeMirror pre.CodeMirror-line-like {
37-
@apply pl-8 pr-2;
38-
}
35+
/*.CodeMirror pre.CodeMirror-line,*/
36+
/*.CodeMirror pre.CodeMirror-line-like {*/
37+
/*}*/
3938

4039
.cm-s-material .CodeMirror-guttermarker,
4140
.cm-s-material .CodeMirror-guttermarker-subtle,

0 commit comments

Comments
 (0)