diff --git a/www/src/App.elm b/www/src/App.elm index 5622fc9..53ba252 100644 --- a/www/src/App.elm +++ b/www/src/App.elm @@ -273,7 +273,7 @@ update msg model = ( { model | criteria = newCriteria }, cmd ) Search -> - ( model + ( { model | cardPage = Nothing } , Cmd.batch [ search model.criteria , Browser.Navigation.pushUrl model.navigationKey <| @@ -282,7 +282,16 @@ update msg model = ) GetPage url -> - ( model, loadPage url ) + let + clearPage maybePage = + case maybePage of + Just page -> + Just { page | values = [] } + + Nothing -> + Nothing + in + ( { model | cardPage = clearPage model.cardPage }, loadPage url ) FoundCards (Ok cardPage) -> ( { model | cardPage = Just cardPage }, Cmd.none ) @@ -314,6 +323,10 @@ viewCardBrowser model = -- 50% of the Scryfall border_crop image width 240 + cardHeight = + -- 50% of the Scryfall border_crop image height + 340 + cardSpacing = 10 @@ -329,6 +342,9 @@ viewCardBrowser model = in (max 3 >> min 9) (availableColumns // 3 * 3) + cardRows = + 18 // cardColumns + viewCard cardModel = E.column [] [ E.image [ E.width (E.px cardWidth) ] @@ -362,7 +378,12 @@ viewCardBrowser model = E.none Just cardPage -> - E.row [ E.width E.fill, E.centerX ] <| + E.row + [ E.width E.fill + , E.height (E.px (cardRows * (cardHeight + cardSpacing))) + , E.centerX + ] + <| [ navButton "←" cardPage.prev , E.wrappedRow [ E.width (E.px (cardColumns * (cardWidth + cardSpacing)))