Copyright | (C) 2016-2018 David M. Johnson |
---|---|
License | BSD3-style (see the file LICENSE) |
Maintainer | David M. Johnson <djohnson.m@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Example usage:
import Miso data IntAction = Add | Subtract intView :: Int -> View IntAction intView n = div_ [ class_ "main" ] [ btn_ [ onClick Add ] [ text_ "+" ] , text_ $ pack (show n) , btn_ [ onClick Subtract ] [ text_ "-" ] ]
More information on how to use miso
is available on GitHub
- module Miso.Html.Element
- module Miso.Html.Event
- data VTree action where
- newtype View action = View {}
- class ToView v where
- data Attribute action
- = P MisoString Value
- | E ()
- node :: NS -> MisoString -> Maybe Key -> [Attribute action] -> [View action] -> View action
- text :: MisoString -> View action
- newtype Key = Key MisoString
- class ToKey key where
- data NS
- prop :: ToJSON a => MisoString -> a -> Attribute action
- style_ :: Map MisoString MisoString -> Attribute action
- on :: MisoString -> Decoder r -> (r -> action) -> Attribute action
- onWithOptions :: Options -> MisoString -> Decoder r -> (r -> action) -> Attribute action
- module Miso.Html.Property
Documentation
module Miso.Html.Element
module Miso.Html.Event
Core types and interface
data VTree action where Source #
Virtual DOM implemented as a Rose Vector
.
Used for diffing, patching and event delegation.
Not meant to be constructed directly, see View
instead.
Convenience class for using View
data Attribute action Source #
View
Attributes to annotate DOM, converted into Events, Props, Attrs and CSS
P MisoString Value | |
E () |
Smart View
constructors
node :: NS -> MisoString -> Maybe Key -> [Attribute action] -> [View action] -> View action Source #
VNode
creation
Key patch internals
Key for specific children patch
Namespace
Namespace for element creation
Setting properties on virtual DOM nodes
prop :: ToJSON a => MisoString -> a -> Attribute action Source #
Constructs a property on a VNode
, used to set fields on a DOM Node
Setting CSS
style_ :: Map MisoString MisoString -> Attribute action Source #
Constructs CSS for a DOM Element
import qualified Data.Map as M div_ [ style_ $ M.singleton "background" "red" ] [ ]
Handling events
on :: MisoString -> Decoder r -> (r -> action) -> Attribute action Source #
For defining delegated events
let clickHandler = on "click" emptyDecoder $ \() -> Action in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]
onWithOptions :: Options -> MisoString -> Decoder r -> (r -> action) -> Attribute action Source #
For defining delegated events with options
let clickHandler = onWithOptions defaultOptions "click" emptyDecoder $ \() -> Action in button_ [ clickHandler, class_ "add" ] [ text_ "+" ]
module Miso.Html.Property