@@ -30,17 +30,18 @@ import React.Basic.Helpers (jsx)
30import React.Basic.Hooks (component, useState)
30import React.Basic.Hooks (component, useState)
31import React.Basic.Hooks as React
31import React.Basic.Hooks as React
32import React.Basic.Hooks.Spring (useTransition)
32import React.Basic.Hooks.Spring (useTransition)
33+import React.Basic.SyntaxHighlighter.Component (HighlighterTheme, syntaxHighlighterImpl)
33import Shared.Models.Body (CompileResult, RunResult)
34import Shared.Models.Body (CompileResult, RunResult)
34−import Type.Row (type (+))
35import Yoga.Button.Component (ButtonType(..), mkButton)
35import Yoga.Button.Component (ButtonType(..), mkButton)
36import Yoga.ClickAway.Component as ClickAway
36import Yoga.ClickAway.Component as ClickAway
37import Yoga.CloseIcon.Component as CloseIcon
37import Yoga.CloseIcon.Component as CloseIcon
38import Yoga.Cluster.Component as Cluster
38import Yoga.Cluster.Component as Cluster
39import Yoga.Compiler.Types (Compiler)
39import Yoga.Compiler.Types (Compiler)
40import Yoga.Helpers ((?||))
40import Yoga.Helpers ((?||))
41−import Yoga.Highlighter.Types (Highlighter)
42import Yoga.InlineCode.Component as InlineCode
41import Yoga.InlineCode.Component as InlineCode
43import Yoga.Modal.Component as Modal
42import Yoga.Modal.Component as Modal
43+import Yoga.Theme.Styles (useTheme)
44+import Yoga.Theme.Syntax (mkHighlighterTheme)
45data Segment
46data Segment
46 = ExpectedResult String
47 = ExpectedResult String
@@ -82,14 +83,14 @@ visibleRange arr = { start, end }
82 start = A.findIndex (_ == [ Start ]) arr ?|| 0
83 start = A.findIndex (_ == [ Start ]) arr ?|| 0
83 end = A.findIndex (_ == [ End ]) arr ?|| A.length arr
84 end = A.findIndex (_ == [ End ]) arr ?|| A.length arr
85−renderSegments ∷ ReactComponent InlineCode.Props -> ((Array (Array Segment) -> Array (Array Segment)) -> Effect Unit) -> Array (Array Segment) -> JSX
86+renderSegments ∷ HighlighterTheme -> ReactComponent InlineCode.Props -> ((Array (Array Segment) -> Array (Array Segment)) -> Effect Unit) -> Array (Array Segment) -> JSX
86−renderSegments ic update arrs = R.div_ (A.mapWithIndex renderLine arrs)
87+renderSegments highlighterTheme ic update arrs = R.div_ (A.mapWithIndex renderLine arrs)
88 { start, end } = visibleRange arrs
89 { start, end } = visibleRange arrs
89 renderLine i l = R.div_ (A.mapWithIndex (renderSegment i) l)
90 renderLine i l = R.div_ (A.mapWithIndex (renderSegment i) l)
90 renderSegment i j s =
91 renderSegment i j s =
91 if between start end i then case s of
92 if between start end i then case s of
92− Filler s' -> R.code_ [ R.text s' ]
93+ Filler s' -> element syntaxHighlighterImpl { style: highlighterTheme, language: "purescript", children: s' }
93 Hole width _ ->
94 Hole width _ ->
94 element ic
95 element ic
95 $ justifill
96 $ justifill
@@ -135,10 +136,10 @@ toSegment = case _ of
135 other -> Filler other
136 other -> Filler other
137type Ctx r
138type Ctx r
138− = (Compiler + Highlighter r)
139+ = (Compiler r)
140makeComponent ∷ { | Ctx () } -> Effect (ReactComponent { code ∷ String })
141makeComponent ∷ { | Ctx () } -> Effect (ReactComponent { code ∷ String })
141−makeComponent { compileAndRun, highlight } = do
142+makeComponent { compileAndRun } = do
142 ic <- InlineCode.makeComponent
143 ic <- InlineCode.makeComponent
143 modal <- Modal.makeComponent
144 modal <- Modal.makeComponent
144 closeIcon <- CloseIcon.makeComponent
145 closeIcon <- CloseIcon.makeComponent
@@ -152,6 +153,9 @@ makeComponent { compileAndRun, highlight } = do
152 initialSegments = lines <#> \line -> rawSegments line <#> toSegment
153 initialSegments = lines <#> \line -> rawSegments line <#> toSegment
153 segments /\ modifySegments <- useState initialSegments
154 segments /\ modifySegments <- useState initialSegments
154 result /\ modifyResult <- useState Nothing
155 result /\ modifyResult <- useState Nothing
156+ cssTheme <- useTheme
158+ highlighterTheme = mkHighlighterTheme cssTheme
155 modalTransitions <-
159 modalTransitions <-
156 useTransition [ result ] (Just show)
160 useTransition [ result ] (Just show)
@@ -184,7 +188,7 @@ makeComponent { compileAndRun, highlight } = do
184 modifyResult (const (Just $ res)) # liftEffect
188 modifyResult (const (Just $ res)) # liftEffect
186 $ fragment
190 $ fragment
187− $ [ renderSegments ic (modifySegments) segments
191+ $ [ renderSegments highlighterTheme ic (modifySegments) segments
188 , jsx cluster {}
192 , jsx cluster {}
190 [ jsx button
194 [ jsx button