Skip to content

Commit

Permalink
#97 Remap clicks for the green checkmark.
Browse files Browse the repository at this point in the history
  • Loading branch information
igorocky committed Jun 17, 2023
1 parent 4039ab7 commit f99e39d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/metamath/ui/MM_cmp_root_stmts.res
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ let make = (
<td style=ReactDOM.Style.make(~paddingTop, ())>
{
if (proofStatusesAreAvailable) {
rndProofStatus(~proofStatus=getProofStatus(stmt), ())
rndProofStatus(
~proofStatus=getProofStatus(stmt),
~longClickEnabled=false,
~longClickDelayMs=0,
()
)
} else {
React.null
}
Expand Down
68 changes: 58 additions & 10 deletions src/metamath/ui/MM_cmp_user_stmt.res
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,18 @@ let stmtPartMarginLeft = "10px"
let stmtPartMarginTopInt = 5
let stmtPartMarginTop = stmtPartMarginTopInt->Belt.Int.toString ++ "px"

let checkMarkSymbol = "\u2713"

let rndProofStatus = (
~proofStatus:option<proofStatus>,
~longClickEnabled:bool,
~longClickDelayMs:int,
~readyTooltip:option<string>=?,
~waitingTooltip:option<string>=?,
~noJstfTooltip:option<string>=?,
~jstfIsIncorrectTooltip:option<string>=?,
~onReadyIconClicked:option<unit=>unit>=?,
~onReadyIconAltClicked:option<unit=>unit>=?,
~onErrorIconClicked:option<unit=>unit>=?,
~onNoJstfIconClicked:option<unit=>unit>=?,
()
Expand All @@ -449,15 +454,55 @@ let rndProofStatus = (
| Some(status) => {
switch status {
| Ready =>
<span
title=?readyTooltip
style={commonStyle->ReactDOM.Style.combine(ReactDOM.Style.make(
~color="green",
~cursor=if (onReadyIconClicked->Belt_Option.isSome) {"pointer"} else {"default"},
()
))}
onClick={_=>onReadyIconClicked->Belt_Option.forEach(clbk => clbk())}
>{React.string("\u2713")}</span>
let style = commonStyle->ReactDOM.Style.combine(ReactDOM.Style.make(
~color="green",
~cursor=
if (onReadyIconClicked->Belt_Option.isSome || onReadyIconAltClicked->Belt_Option.isSome) {
"pointer"
} else {
"default"
},
()
))
switch onReadyIconAltClicked {
| None => {
<span
title=?readyTooltip
style
onClick={_=>callbackOpt(onReadyIconClicked)()}
>{React.string(checkMarkSymbol)}</span>
}
| Some(onReadyIconAltClicked) => {
<LongClickSpan
onClick={
clickHnd2(
clickClbkMake(~act = callbackOpt(onReadyIconClicked), ()),
clickClbkMake(~alt=true, ~act=onReadyIconAltClicked, ()),
)
}
longClickEnabled
longClickDelayMs
onShortClick={
(clickAttrs:option<UseLongClick.clickAttrs>) => {
switch clickAttrs {
| None => callbackOpt(onReadyIconClicked)()
| Some({alt}) => {
if (alt) {
onReadyIconAltClicked()
} else {
callbackOpt(onReadyIconClicked)()
}
}
}
}
}
onLongClick=onReadyIconAltClicked

title=?readyTooltip
style
>{React.string(checkMarkSymbol)}</LongClickSpan>
}
}
| Waiting =>
<span
title=?waitingTooltip
Expand Down Expand Up @@ -1473,11 +1518,14 @@ let make = React.memoCustomCompareProps( ({
let rndProofStatusInner = () => {
rndProofStatus(
~proofStatus=stmt.proofStatus,
~longClickEnabled,
~longClickDelayMs,
~readyTooltip="Proof is ready, left-click to generate compressed proof",
~waitingTooltip="Justification for this step is correct",
~noJstfTooltip="Justification cannot be determined automatically. Click to debug.",
~jstfIsIncorrectTooltip="Justification is incorrect. Click to debug.",
~onReadyIconClicked=onGenerateProof,
~onReadyIconClicked=actToggleInfoExpanded,
~onReadyIconAltClicked=onGenerateProof,
~onErrorIconClicked=onDebug,
~onNoJstfIconClicked=onDebug,
()
Expand Down
3 changes: 3 additions & 0 deletions src/metamath/ui/MM_cmp_user_stmt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ open MM_syntax_tree

let rndProofStatus: (
~proofStatus:option<proofStatus>,
~longClickEnabled:bool,
~longClickDelayMs:int,
~readyTooltip:string=?,
~waitingTooltip:string=?,
~noJstfTooltip:string=?,
~jstfIsIncorrectTooltip:string=?,
~onReadyIconClicked:unit=>unit =?,
~onReadyIconAltClicked:unit=>unit=?,
~onErrorIconClicked:unit=>unit =?,
~onNoJstfIconClicked:unit=>unit =?,
()
Expand Down

0 comments on commit f99e39d

Please sign in to comment.