Skip to content

Instantly share code, notes, and snippets.

@slapers
Created February 1, 2017 08:53
Show Gist options
  • Select an option

  • Save slapers/a1d49d93805da316fd799580b95d8bd4 to your computer and use it in GitHub Desktop.

Select an option

Save slapers/a1d49d93805da316fd799580b95d8bd4 to your computer and use it in GitHub Desktop.
Modal starter, not working/finished yet
module App.UiModal exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
type alias Modal =
{ content : Maybe String
}
type Msg
= ShowModal String
| HideModal
(=>) : a -> b -> ( a, b )
(=>) =
(,)
updateModal : Maybe String -> Modal -> Modal
updateModal content modal =
{ modal | content = content }
viewModal : (Msg -> msg) -> Modal -> Html msg
viewModal tagging modal =
case modal.content of
Nothing -> viewEmptyModal
Just _ -> viewModalWithContent
viewEmptyModal : Html Never
viewEmptyModal =
div [ style [ "display" => "none" ] ] []
viewModalWithContent : (Msg -> msg) -> Modal -> Html msg
viewModalWithContent
div
[ style
[ "position" => "absolute"
, "height" => "100%"
, "width" => "100%"
, "background-color" => "rgba(0, 0, 0, 0.2)"
]
, onClick (tagging HideModal)
]
[ text "test"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment