concept viewselectedphoto in category elm
appears as: viewSelectedPhoto, viewSelectedPhoto

This is an excerpt from Manning's book Elm in Action.
To implement this, we’ll begin by creating two new functions, viewSelectedPhoto and viewRelatedPhoto, which we’ll call from view to render the selected photo and its related thumbnails. Let’s add the contents of the following listing to the end of PhotoFolders.elm.
Listing 7.2. PhotoFolders.elm
type alias Photo = { title : String , size : Int , relatedUrls : List String #1 , url : String } viewSelectedPhoto : Photo -> Html Msg #2 viewSelectedPhoto photo = #2 div [ class "selected-photo" ] [ h2 [] [ text photo.title ] , img [src (urlPrefix ++ "photos/" ++ photo.url ++ "/full") ] [] , span [] [ text (String.fromInt photo.size ++ "KB") ] , h3 [] [ text "Related" ] , div [ class "related-photos" ] (List.map viewRelatedPhoto photo.relatedUrls) #3 ] viewRelatedPhoto : String -> Html Msg viewRelatedPhoto url = img [ class "related-photo" , onClick (ClickedPhoto url) #4 , src (urlPrefix ++ "photos/" ++ url ++ "/thumb") ] [] urlPrefix : String urlPrefix = "http://elm-in-action.com/"We started by defining a type alias Photo much like the one we used in PhotoGroove.elm, except the one we defined before didn’t have a relatedUrls field. (After all, the Related Photos feature didn’t exist back then!) We then used Photo to annotate viewSelectedPhoto.