elm-pages 2.1.9 → 2.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,82 +0,0 @@
1
- module ElmHtml.ToHtml exposing (toHtml, factsToAttributes)
2
-
3
- {-| This module is particularly useful for putting parsed Html into Elm.Html at runtime.
4
- Estentially allowing the user to use tools like html-to-elm on their code.
5
-
6
- @docs toHtml, factsToAttributes
7
-
8
- -}
9
-
10
- import Dict exposing (Dict)
11
- import ElmHtml.InternalTypes exposing (..)
12
- import Html
13
- import Html.Attributes
14
- import Html.Events
15
- import Json.Decode
16
- import Json.Encode
17
- import String
18
-
19
-
20
- {-| Turns ElmHtml into normal Elm Html
21
- -}
22
- toHtml : ElmHtml msg -> Html.Html msg
23
- toHtml elmHtml =
24
- case elmHtml of
25
- TextTag text ->
26
- Html.text text.text
27
-
28
- NodeEntry { tag, children, facts } ->
29
- Html.node tag [] (List.map toHtml children)
30
-
31
- CustomNode record ->
32
- --let
33
- -- _ =
34
- -- Debug.log "Custom node is not supported" ""
35
- --in
36
- Html.text ""
37
-
38
- MarkdownNode record ->
39
- --let
40
- -- _ =
41
- -- Debug.log "Markdown node is not supported" ""
42
- --in
43
- Html.text ""
44
-
45
- NoOp ->
46
- Html.text ""
47
-
48
-
49
- stylesToAttribute : Dict String String -> List (Html.Attribute msg)
50
- stylesToAttribute =
51
- Dict.toList
52
- >> List.map (\( k, v ) -> Html.Attributes.style k v)
53
-
54
-
55
- eventsToAttributes : Dict String (Json.Decode.Decoder msg) -> List (Html.Attribute msg)
56
- eventsToAttributes =
57
- Dict.toList
58
- >> List.map (\( x, y ) -> Html.Events.on x y)
59
-
60
-
61
- stringAttributesToAttributes : Dict String String -> List (Html.Attribute msg)
62
- stringAttributesToAttributes =
63
- Dict.toList
64
- >> List.map (\( x, y ) -> Html.Attributes.attribute x y)
65
-
66
-
67
- boolAttributesToAttributes : Dict String Bool -> List (Html.Attribute msg)
68
- boolAttributesToAttributes =
69
- Dict.toList
70
- >> List.map (\( x, y ) -> Html.Attributes.property x (Json.Encode.bool y))
71
-
72
-
73
- {-| Turns a fact record into a list of attributes
74
- -}
75
- factsToAttributes : Facts msg -> List (Html.Attribute msg)
76
- factsToAttributes facts =
77
- List.concat
78
- [ stylesToAttribute facts.styles
79
- , eventsToAttributes facts.events
80
- , stringAttributesToAttributes facts.stringAttributes
81
- , boolAttributesToAttributes facts.boolAttributes
82
- ]