Solution for advanced/part5
This commit is contained in:
@@ -109,7 +109,7 @@ view model =
|
||||
]
|
||||
, Feed.viewArticles model.timeZone feed
|
||||
|> List.map (Html.map GotFeedMsg)
|
||||
, [ viewPagination (Feed.articles feed) ]
|
||||
, [ PaginatedList.view ClickedFeedPage (Feed.articles feed) ]
|
||||
]
|
||||
]
|
||||
|
||||
@@ -155,46 +155,6 @@ viewBanner =
|
||||
|
||||
|
||||
|
||||
-- PAGINATION
|
||||
|
||||
|
||||
{-| 👉 TODO: Relocate `viewPagination` into `PaginatedList.view` and make it reusable,
|
||||
then refactor both Page.Home and Page.Profile to use it!
|
||||
|
||||
💡 HINT: Make `PaginatedList.view` return `Html msg` instead of `Html Msg`.
|
||||
(You'll need to introduce at least one extra argument for this to work.)
|
||||
|
||||
-}
|
||||
viewPagination : PaginatedList (Article Preview) -> Html Msg
|
||||
viewPagination list =
|
||||
let
|
||||
viewPageLink currentPage =
|
||||
pageLink currentPage (currentPage == page list)
|
||||
in
|
||||
if total list > 1 then
|
||||
List.range 1 (total list)
|
||||
|> List.map viewPageLink
|
||||
|> ul [ class "pagination" ]
|
||||
|
||||
else
|
||||
Html.text ""
|
||||
|
||||
|
||||
pageLink : Int -> Bool -> Html Msg
|
||||
pageLink targetPage isActive =
|
||||
li [ classList [ ( "page-item", True ), ( "active", isActive ) ] ]
|
||||
[ a
|
||||
[ class "page-link"
|
||||
, onClick (ClickedFeedPage targetPage)
|
||||
|
||||
-- The RealWorld CSS requires an href to work properly.
|
||||
, href ""
|
||||
]
|
||||
[ text (String.fromInt targetPage) ]
|
||||
]
|
||||
|
||||
|
||||
|
||||
-- TABS
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user