Module for flow contents.
You will use this module for two main purposes:
To add attributes or styles within a series of strings.
import Html.Attributes exposing (class, href)
import Neat.Flow as Flow
import Neat.View as View
sample : View SampleGap msg
sample =
View.fromFlows sampleGap
[ Flow.fromString "Please "
, Flow.fromString "contact us"
|> Flow.setNodeName "a"
|> Flow.setAttribute
(href "https://example.com/contact")
, Flow.fromString " if you receive this "
, Flow.fromString "error message"
|> Flow.setAttribute (class "error")
, Flow.fromString " multiple times."
]
-- <div>Please <a href="https://example.com/contact">contact us</a> if you receive this <span class="error">error message</span> multiple times.</div>To generate HTML elements that are allowed to contain only flow content.
import Html.Attributes exposing (attribute, selected, value)
import Html.Events as Events
import Neat.Boundary as Boundary
import Neat.Flow as Flow
import Neat.View as View
sampleSelect : Model -> Boundary Msg
sampleSelect model =
View.fromFlows sampleGap
[ Flow.fromString "-- Select one --"
|> Flow.setNodeName "option"
|> Flow.setAttributes
[ attribute "value" ""
, selected <| model.selected == ""
]
, Flow.fromString "Goat"
|> Flow.setNodeName "option"
|> Flow.setAttributes
[ attribute "value" "goat"
, selected <| model.selected == "goat"
]
, Flow.fromString "Dog"
|> Flow.setNodeName "option"
|> Flow.setAttributes
[ attribute "value" "dog"
, selected <| model.selected == "dog"
]
]
|> View.setBoundary
|> Boundary.setNodeName "select"
|> Boundary.setAttributes
[ value model.selected
, Events.onInput ChangeChoice
]Generate a Flow with given text content.
Append class attribute.
Append id attribute.
Set "role" value for WAI-ARIA.
Set "aria-*" value for WAI-ARIA.
e.g., setAria "required" "true" stands for "aria-required" is "true".
Set boolean "aria-*" value for WAI-ARIA.
i.e.,
setBoolAria name True is equal to setAria name "true"setBoolAria name False is equal to setAria name "false"Generate Nothing.
It can be used to realize Flows only displayed under certain conditions, as shown below.
fromFlows
[ case mtext of
Just t ->
text t
Nothing ->
none
]In most cases, however, a function like when will suffice.
Representing a text.