Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion primer-miso/src/Primer/Miso.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ import Primer.Miso.Util (
bindingsInExpr,
bindingsInType,
clayToMiso,
exitFullscreen,
findASTDef,
kindsInType,
nodeSelectionType,
optToName,
readMs,
realToClay,
requestFullscreen,
runMutationWithNullDb,
runTC,
selectedDefName,
Expand Down Expand Up @@ -333,7 +335,14 @@ updateModel =
SetEvalOpts f -> do
#components % #eval % #opts %= f
setEval
ToggleFullscreenEval -> #components % #eval % #fullscreen %= not
ToggleFullscreenEval -> do
#components % #eval % #fullscreen %= not
fs' <- use $ #components % #eval % #fullscreen
scheduleIO_ $
void
if fs'
then requestFullscreen
else exitFullscreen
where
-- TODO the only part of this that should really require `IO` is writing to a database
-- (currently we use `NullDb` anyway but this will change)
Expand Down
8 changes: 8 additions & 0 deletions primer-miso/src/Primer/Miso/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

-- | Things which should really be upstreamed rather than living in this project.
module Primer.Miso.Util (
requestFullscreen,
exitFullscreen,
startAppWithSavedState,
showMs,
readMs,
Expand Down Expand Up @@ -57,6 +59,7 @@ import Data.Map qualified as Map
import Data.String (String)
import Data.UUID.Types qualified as UUID
import GHC.Base (error)
import Language.Javascript.JSaddle qualified as JS
import Linear (Additive, R1 (_x), R2 (_y), V2, zero)
import Linear.Affine (Point (..), unP)
import Miso (
Expand Down Expand Up @@ -134,6 +137,11 @@ import Primer.TypeDef (TypeDefMap)
import Primer.Typecheck (ExprT, exprTtoExpr, typeTtoType)
import StmContainers.Map qualified as StmMap

requestFullscreen :: JSM JS.JSVal
requestFullscreen = JS.eval ("document.documentElement.requestFullscreen()" :: MisoString)
exitFullscreen :: JSM JS.JSVal
exitFullscreen = JS.eval ("document.exitFullscreen()" :: MisoString)

{- Miso -}

-- https://github.com/dmjio/miso/issues/749
Expand Down