Update part1 and part2

This commit is contained in:
Richard Feldman
2018-04-30 04:42:21 -04:00
parent 5e232596d9
commit 3b43ef3437
243 changed files with 34543 additions and 142 deletions

View File

@@ -0,0 +1,51 @@
module Views.Article exposing (view, viewTimestamp)
{-| Viewing a preview of an individual article, excluding its body.
-}
import Data.Article exposing (Article)
import Data.UserPhoto as UserPhoto exposing (UserPhoto)
import Date.Format
import Html exposing (..)
import Html.Attributes exposing (attribute, class, classList, href, id, src)
import Route exposing (Route)
import Views.Article.Favorite as Favorite
import Views.Author
view : (Article a -> msg) -> Article a -> Html msg
view toggleFavorite article =
let
author =
article.author
in
div [ class "article-preview" ]
[ div [ class "article-meta" ]
[ a [ Route.href (Route.Profile author.username) ]
[ img [ UserPhoto.src author.image ] [] ]
, div [ class "info" ]
[ Views.Author.view author.username
, viewTimestamp article
]
, Favorite.button
toggleFavorite
article
[ class "pull-xs-right" ]
[ text (" " ++ toString article.favoritesCount) ]
]
, a [ class "preview-link", Route.href (Route.Article article.slug) ]
[ h1 [] [ text article.title ]
, p [] [ text article.description ]
, span [] [ text "Read more..." ]
]
]
viewTimestamp : Article a -> Html msg
viewTimestamp article =
span [ class "date" ] [ text (formattedTimestamp article) ]
formattedTimestamp : Article a -> String
formattedTimestamp article =
Date.Format.format "%B %e, %Y" article.createdAt