Add part9

This commit is contained in:
Richard Feldman
2018-08-12 14:05:15 -04:00
parent fa84d31f62
commit 17f96d1b56
55 changed files with 5948 additions and 0 deletions

48
intro/part9/src/Asset.elm Normal file
View File

@@ -0,0 +1,48 @@
module Asset exposing (Image, defaultAvatar, error, loading, src)
{-| Assets, such as images, videos, and audio. (We only have images for now.)
We should never expose asset URLs directly; this module should be in charge of
all of them. One source of truth!
-}
import Html exposing (Attribute, Html)
import Html.Attributes as Attr
type Image
= Image String
-- IMAGES
error : Image
error =
image "error.jpg"
loading : Image
loading =
image "loading.svg"
defaultAvatar : Image
defaultAvatar =
image "smiley-cyrus.jpg"
image : String -> Image
image filename =
Image ("/assets/images/" ++ filename)
-- USING IMAGES
src : Image -> Attribute msg
src (Image url) =
Attr.src url