This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readPostBody : Post -> Html msg | |
readPostBody post = | |
main_ [ class "container" ] | |
[ div [ class "row" ] | |
[ div [ class "col l6 offset-l3" ] | |
[ h1 [] [ text <| "ID " ++ post.id ++ ": "++ post.title ] | |
, List.repeat 10 post.body |> List.map (\par -> p [] [ text par ]) |> div [] | |
] | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readPost : String -> Model -> Html msg | |
readPost id model = | |
case List.head <| List.filter (\post -> post.id == id) model.posts of | |
Just post -> | |
layout authHeader <| readPostBody post | |
Nothing -> | |
error "404 Not Found" | |
error : a -> Html msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main : Program Never Model msg | |
main = program | |
{ init = (initialModel, Cmd.none ) | |
-- , view = Pages.landing | |
, view = Pages.readPost "3" | |
, update = \msg model -> (model, Cmd.none) | |
, subscriptions = \model -> Sub.none | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alias User = | |
{ email : String | |
} | |
type alias Model = | |
{ posts: List Post | |
, user: User -- Added User to the Model | |
} | |
initialModel : Model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
userHeader : User -> Html msg | |
userHeader user = | |
header [] | |
[ nav [] | |
[ div [ class "nav-wrapper container" ] | |
[ a [class "btn" ] [ text "New Post" ] | |
, ul [ class "right" ] | |
[ li [] [ text user.email ] | |
, li [] [ a [class "btn" ] [ text "Logout" ] ] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createPost : Model -> Html msg | |
createPost model = | |
layout (userHeader model.user) createPostBody |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emailInput : Html msg | |
emailInput = | |
div [ class "input-field" ] | |
[ i [ class "material-icons prefix" ] [ text "email" ] | |
, input [ placeholder "Email", type_ "text" ] [] | |
] | |
passwordInput : Html msg | |
passwordInput = | |
div [ class "input-field" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
login : Model -> Html msg | |
login model = Components.login | |
signUp : Model -> Html msg | |
signUp model = Components.signUp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Do not remove this | |
$roboto-font-path: "~materialize-css/dist/fonts/roboto/"; | |
@import "../node_modules/materialize-css/sass/materialize"; | |
.full-height { | |
height: 100%; | |
} | |
body, html, #app, main{ | |
@extend .full-height; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Routes exposing (..) | |
import Navigation exposing (Location) | |
import UrlParser exposing (..) | |
type Route | |
= HomeRoute | |
| ReadPostRoute String | |
| CreatePostRoute | |
| LoginRoute |