Skip to content

Show the number of errors and warnings in the Problems tab's title #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d21e5e6
Use Int.toString instead of Belt.Int.toString for ReScript v11+
mediremi May 1, 2025
573b863
Use more padding and set max default content width in React and Conso…
mediremi May 1, 2025
06bf524
Show error and problem counts in 'Problems' tab title
mediremi May 1, 2025
c5e8621
Only show syntax selection if there are at least 2 syntaxes to choose…
mediremi May 1, 2025
fd86598
Update TailwindCSS to v3.4.17 to get extended min-width, max-width, a…
mediremi May 1, 2025
92bb2ea
Set min-width on problem counts
mediremi May 1, 2025
7a4ce15
Only reset warning flags, not other config, when clicking warning fla…
mediremi May 1, 2025
ec20549
Add missing warning flag description
mediremi May 1, 2025
9760eda
Remove warning flags that no longer exist
mediremi May 1, 2025
8553e6b
Improve styles for warnings flags input
mediremi May 1, 2025
39527e5
Remove warnings 61 and 109 from default warn flags
mediremi May 1, 2025
6d80d6c
Refactor ToggleSelection component
mediremi May 1, 2025
cfaa584
Remove outdated TODOs
mediremi May 1, 2025
dad68a1
Remove unused OCaml variant in RescriptCompilerApi.Lang.t
mediremi May 1, 2025
2f7cd58
Remove unused RescriptCompilerApi.Compiler.ocamlCompile
mediremi May 1, 2025
5e74246
Remove warning flag descriptions for flags that no longer exist
mediremi May 1, 2025
2384d4c
Merge branch 'master' into playground-tweaks
mediremi May 1, 2025
7beeea0
Move problem counts to after 'Problems' tab title
mediremi May 2, 2025
0afa602
Restore warnings flags reset value to support older compilers
mediremi May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ConsolePanel.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ let make = (~logs, ~appendLog) => {
<h2 className="font-bold text-gray-5/50 absolute right-2 top-2"> {React.string("Console")} </h2>
{switch logs {
| [] =>
React.string(
"Add some 'Console.log' to your code and click 'Run' or enable 'Auto-run' to see your logs here.",
)
<p className="p-4 max-w-prose">
{React.string(
"Add some 'Console.log' to your code and click 'Run' or enable 'Auto-run' to see your logs here.",
)}
</p>
| logs =>
let content =
logs
Expand Down
58 changes: 53 additions & 5 deletions src/Playground.res
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,56 @@ module InitialContent = {
}
}

module App = {
@react.component
let make = () => {
let (count, setCount) = React.useState(() => 0)
let (username, setUsername) = React.useState(() => "Anonymous")

<div>
{React.string("Username: ")}
<input
type_="text"
value={username}
onChange={event => {
event->ReactEvent.Form.preventDefault
let eventTarget = event->ReactEvent.Form.target
let username = eventTarget["value"]
setUsername(_prev => username)
}}
/>
<button
onClick={_evt => {
setCount(prev => prev + 1)
}}>
{React.string("Click me")}
</button>
<button onClick={_evt => setCount(_ => 0)}> {React.string("Reset")} </button>
<CounterMessage count username />
</div>
}
}
`

let since_11 = `module CounterMessage = {
@react.component
let make = (~count, ~username=?) => {
let times = switch count {
| 1 => "once"
| 2 => "twice"
| n => Int.toString(n) ++ " times"
}

let name = switch username {
| Some("") => "Anonymous"
| Some(name) => name
| None => "Anonymous"
}

<div> {React.string(\`Hello \$\{name\}, you clicked me \` ++ times)} </div>
}
}

module App = {
@react.component
let make = () => {
Expand Down Expand Up @@ -1416,7 +1466,7 @@ let make = (~versions: array<string>) => {
| (None, _) =>
switch initialVersion {
| Some({major: 10, minor}) if minor >= 1 => InitialContent.since_10_1
| Some({major}) if major > 10 => InitialContent.since_10_1
| Some({major}) if major > 10 => InitialContent.since_11
| _ => InitialContent.original
}
}
Expand Down Expand Up @@ -1666,16 +1716,14 @@ let make = (~versions: array<string>) => {
| Problems => "Problems"
| Settings => "Settings"
}
let onMouseDown = evt => {
let onClick = evt => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using onClick instead of onMouseDown makes the tabs keyboard accessible - buttons with a click handler can be triggered with Enter/Space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might have been an optimisation so that event.preventDefault() gets invoked faster. Or maybe it was deliberate that it does not get focused.

@ryyppy do you still remember?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was most likely a good reason. I think it had something to do with touch event delay. Ultimately one should consider adapting a accessibility component lib like react-aria to have a fully accessible tab bar etc.

ReactEvent.Mouse.preventDefault(evt)
ReactEvent.Mouse.stopPropagation(evt)
setCurrentTab(_ => tab)
}
let active = currentTab === tab
// For Safari iOS12
let onClick = _ => ()
let className = makeTabClass(active)
<button key={Int.toString(i) ++ ("-" ++ title)} onMouseDown onClick className disabled>
<button key={Int.toString(i) ++ ("-" ++ title)} onClick className disabled>
{React.string(title)}
</button>
})
Expand Down
8 changes: 5 additions & 3 deletions src/RenderPanel.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ let make = (~validReact) => {
<h2 className="font-bold text-gray-5/50 absolute right-2 top-2"> {React.string("React")} </h2>
{validReact
? React.null
: React.string(
"Create a React component called 'App' if you want to render it here, then click 'Run' or enable 'Auto-run'.",
)}
: <p className="p-4 max-w-prose">
{React.string(
"Create a React component called 'App' if you want to render it here, then click 'Run' or enable 'Auto-run'.",
)}
</p>}
<div className={validReact ? "h-full" : "h-0"}>
<EvalIFrame />
</div>
Expand Down