Skip to content

Commit 33e197f

Browse files
author
Sjoerd Visscher
committed
2 parents ee62027 + 814ff3e commit 33e197f

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/Main.purs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import Data.String.Common (trim)
77
import Data.String.Regex (regex, match)
88
import Data.String.Regex.Flags (ignoreCase)
99
import Data.Either (either)
10+
import Data.List (List(..))
1011
import Data.Maybe (Maybe(..), fromMaybe, maybe)
11-
import Data.Traversable (traverse)
12+
import Data.Traversable (traverse, for)
1213
import Effect (Effect)
1314
import Effect.Aff (Aff)
1415
import Effect.Class (liftEffect)
@@ -26,8 +27,11 @@ import Web.HTML.Event.EventTypes (message) as ET
2627
import Web.Event.EventTarget (addEventListener, eventListener)
2728
import Web.MessageEvent as MessageEvent
2829

29-
import View.App (Action(UpdateContext, UpdatePixels))
30+
import Model (Box, Selection)
3031
import View.App as App
32+
import View.App (Action(UpdateContext, UpdatePixels))
33+
import View.Bricks as Bricks
34+
import View.Term as Term
3135

3236

3337
initialPixels :: String
@@ -91,6 +95,26 @@ runJs2 initialInput selector = do
9195

9296
--------------------------------------------------------------------------------
9397

98+
runBricksComponent :: q. Bricks.Input -> String -> Aff (Maybe (HalogenIO q Bricks.Output Aff))
99+
runBricksComponent input selector = do
100+
elemMaybe <- selectElement (QuerySelector selector)
101+
for elemMaybe $ runUI Bricks.bricksView input
102+
103+
toBricksInput :: App.Input -> Box -> Bricks.Input
104+
toBricksInput = App.toBricksInput
105+
106+
--------------------------------------------------------------------------------
107+
108+
runTermComponent :: q. Term.Input -> String -> Aff (Maybe (HalogenIO q Void Aff))
109+
runTermComponent input selector = do
110+
elemMaybe <- selectElement (QuerySelector selector)
111+
for elemMaybe $ runUI Term.termView input
112+
113+
emptySelection :: Selection
114+
emptySelection = { path: Nil, count: 0 }
115+
116+
--------------------------------------------------------------------------------
117+
94118
parseHash :: String -> App.Input
95119
parseHash hash =
96120
let defaultInput = { pixels: initialPixels, context: initialContext } in

src/View/Term.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ handleAction = case _ of
4545
Update st@{ term } -> do
4646
H.put st
4747

48-
render :: m. State -> H.ComponentHTML Action () m
48+
render :: m. Input -> H.ComponentHTML Action () m
4949
render { term, selection: { path, count } } = div [ classes [ ClassName "term" ] ] (rec (Just path) term) where
5050
rec :: Maybe Path -> TTerm -> Array (H.ComponentHTML Action () m)
5151
rec p (Fix (Ann _ TUnit)) = [ div [ clsSel p "tunit" ] [ i_ [ text "I" ] ] ]

0 commit comments

Comments
 (0)