diff --git a/bower.json b/bower.json index 85d20eb..ff5c55e 100644 --- a/bower.json +++ b/bower.json @@ -21,12 +21,11 @@ "yarn.lock" ], "dependencies": { - "purescript-string-parsers": "^5.0.0", - "purescript-halogen": "^5.0.0-rc.4" + "purescript-string-parsers": "^6.0.0", + "purescript-halogen": "^6.1.0" }, "devDependencies": { - "purescript-psci-support": "^4.0.0", - "purescript-jest": "^0.3.0", - "purescript-debug": "^4.0.0" + "purescript-psci-support": "^5.0.0", + "purescript-debug": "^5.0.0" } } diff --git a/example/bower.json b/example/bower.json index 1116c61..ced36d6 100644 --- a/example/bower.json +++ b/example/bower.json @@ -8,10 +8,11 @@ "output" ], "dependencies": { - "purescript-string-parsers": "^5.0.0", - "purescript-halogen": "^5.0.0-rc.4" + "purescript-string-parsers": "^6.0.0", + "purescript-jest": "^0.5.0", + "purescript-halogen": "^6.1.0" }, "devDependencies": { - "purescript-psci-support": "^4.0.0" + "purescript-psci-support": "^5.0.0" } } diff --git a/example/src/App.purs b/example/src/App.purs index ee98a26..54a8656 100644 --- a/example/src/App.purs +++ b/example/src/App.purs @@ -2,14 +2,16 @@ module App where import Prelude +import Control.Monad.State (class MonadState) import Data.Const (Const) -import Data.Maybe (Maybe(..)) +import Effect.Aff.Class (class MonadAff) import Halogen as H import Halogen.HTML as HH import Halogen.HTML.Events as HE import Halogen.HTML.Properties as HP import Html.Renderer.Halogen as PH +type Query :: forall k. k -> Type type Query = Const Void data Action = OnValueChange String @@ -51,47 +53,49 @@ class_ = HP.class_ <<< HH.ClassName style :: forall r i. String -> HP.IProp ("style" :: String | r) i style = HP.attr (HH.AttrName "style") -render :: forall m. State -> H.ComponentHTML Action () m -render state = - HH.div [ class_ "grid" ] - [ HH.h2 [ class_ "header" ] - [ HH.text "purescript-html-parser-halogen example" ] - , HH.div [ class_ "col col-edit" ] - [ HH.h4_ [ HH.text "EDIT" ] - , HH.textarea - [ class_ "edit" - , HP.value state.value - , HE.onValueInput $ Just <<< OnValueChange - ] - ] - , HH.div [ class_ "col col-preview" ] - [ HH.h4_ [ HH.text "PREVIEW" ] - , HH.div [ class_ "preview" ] - [ PH.render_ state.value ] - ] - , HH.div [ class_ "footer" ] - [ HH.a - [ HP.href demoSourceUrl] [HH.text "source code"] - , HH.text " Powered by " - , HH.img - [ HP.src "https://upload.wikimedia.org/wikipedia/commons/6/64/PureScript_Logo.png" - , style "width: 1rem; height: 1rem" - ] - ] - ] - where - repoUrl = "https://github.com/rnons/purescript-html-parser-halogen" - demoSourceUrl = repoUrl <> "/tree/master/example" - -app :: forall m. H.Component HH.HTML Query Unit Void m -app = H.mkComponent +component :: forall query input output m. MonadAff m => H.Component query input output m +component = H.mkComponent { initialState: const initialState , render , eval: H.mkEval $ H.defaultEval { handleAction = handleAction } } + where + + render state = + HH.div [ class_ "grid" ] + [ HH.h2 [ class_ "header" ] + [ HH.text "purescript-html-parser-halogen example" ] + , HH.div [ class_ "col col-edit" ] + [ HH.h4_ [ HH.text "EDIT" ] + , HH.textarea + [ class_ "edit" + , HP.value state.value + , HE.onValueInput \s -> OnValueChange s + ] + ] + , HH.div [ class_ "col col-preview" ] + [ HH.h4_ [ HH.text "PREVIEW" ] + , HH.div [ class_ "preview" ] + [ PH.render_ state.value ] + ] + , HH.div [ class_ "footer" ] + [ HH.a + [ HP.href demoSourceUrl] [HH.text "source code"] + , HH.text " Powered by " + , HH.img + [ HP.src "https://upload.wikimedia.org/wikipedia/commons/6/64/PureScript_Logo.png" + , style "width: 1rem; height: 1rem" + ] + ] + ] + where + repoUrl = "https://github.com/rnons/purescript-html-parser-halogen" + demoSourceUrl = repoUrl <> "/tree/master/example" -handleAction :: forall m. Action -> H.HalogenM State Action () Void m Unit +handleAction :: forall m. + MonadState State m => + Action -> m Unit handleAction = case _ of OnValueChange value -> do H.modify_ $ _ { value = value } diff --git a/example/src/Main.purs b/example/src/Main.purs index 28f160d..d9bd97a 100644 --- a/example/src/Main.purs +++ b/example/src/Main.purs @@ -4,9 +4,9 @@ import Prelude import Effect (Effect) import Halogen.Aff as HA import Halogen.VDom.Driver (runUI) -import App (app) +import App (component) main :: Effect Unit main = HA.runHalogenAff do body <- HA.awaitBody - runUI app unit body + runUI component unit body