@@ -300,22 +300,28 @@ viewChangeIcon item =
300300 )
301301
302302
303- viewChangeBadge : Int -> ChangeLine -> Html Msg
303+ viewChangeBadge : Int -> ChangeLine -> Html msg
304304viewChangeBadge maxBadgeLength changeLine =
305305 let
306306 type_ =
307307 ChangeLine . toString changeLine
308+ in
309+ viewChangeBadge_ maxBadgeLength ( changeIcon changeLine) type_
310+
308311
312+ viewChangeBadge_ : Int -> Icon msg -> String -> Html msg
313+ viewChangeBadge_ maxBadgeLength icon label_ =
314+ let
309315 width =
310316 String . fromInt maxBadgeLength
311317 in
312318 span [ class " change-badge_wrapper" , style " width" ( width ++ " ch" ) ]
313319 [ span
314320 [ class " change-badge"
315- , class ( String . toLower type_ )
321+ , class ( String . toLower label_ )
316322 ]
317- [ Icon . view ( changeIcon changeLine )
318- , label [] [ text type_ ]
323+ [ Icon . view icon
324+ , label [] [ text label_ ]
319325 ]
320326 ]
321327
@@ -549,15 +555,9 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
549555 |> Card . view
550556
551557
552- viewChangedDefinitionsCards : ProjectRef -> ToggledChangeLines -> BranchDiff -> List (Html Msg )
553- viewChangedDefinitionsCards projectRef toggledChangeLines branchDiff =
558+ viewChangedDefinitionsCards : ProjectRef -> ToggledChangeLines -> Int -> BranchDiff -> List (Html Msg )
559+ viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength branchDiff =
554560 let
555- maxBadgeLength =
556- branchDiff. lines
557- |> List . map ( ChangeLine . toString >> String . length)
558- |> List . maximum
559- |> Maybe . withDefault 0
560-
561561 view_ =
562562 viewChangedDefinitionCard
563563 projectRef
@@ -665,8 +665,8 @@ viewChangedDefinitionsCards projectRef toggledChangeLines branchDiff =
665665 go branchDiff. lines
666666
667667
668- viewLibDep : LibDep -> Html msg
669- viewLibDep dep =
668+ viewLibDep : Int -> LibDep -> Html msg
669+ viewLibDep maxBadgeLength dep =
670670 let
671671 viewCard content =
672672 Card . card
@@ -675,17 +675,12 @@ viewLibDep dep =
675675 |> Card . asContained
676676 |> Card . view
677677
678- changeIcon_ type_ icon =
678+ badge icon type_ =
679679 Tooltip . text type_
680680 |> Tooltip . tooltip
681681 |> Tooltip . withArrow Tooltip . Start
682682 |> Tooltip . view
683- ( span
684- [ class " change-icon"
685- , class ( String . toLower type_)
686- ]
687- [ Icon . view icon ]
688- )
683+ ( viewChangeBadge_ maxBadgeLength icon type_)
689684
690685 viewTitle name =
691686 let
@@ -697,7 +692,7 @@ viewLibDep dep =
697692 case dep of
698693 LibDep . Added { name } ->
699694 viewCard
700- [ changeIcon_ " Added " Icon . largePlus
695+ [ badge Icon . largePlus " Added "
701696 , div [ class " def-icon-anchor" ]
702697 [ Tooltip . text " Lib dependency"
703698 |> Tooltip . tooltip
@@ -709,7 +704,7 @@ viewLibDep dep =
709704
710705 LibDep . Removed { name } ->
711706 viewCard
712- [ changeIcon_ " Removed " Icon . dash
707+ [ badge Icon . dash " Removed "
713708 , div [ class " def-icon-anchor" ]
714709 [ Tooltip . text " Lib dependency"
715710 |> Tooltip . tooltip
@@ -720,9 +715,9 @@ viewLibDep dep =
720715 ]
721716
722717
723- viewLibDeps : List LibDep -> List (Html msg )
724- viewLibDeps deps =
725- List . map viewLibDep deps
718+ viewLibDeps : Int -> List LibDep -> List (Html msg )
719+ viewLibDeps maxBadgeLength deps =
720+ List . map ( viewLibDep maxBadgeLength ) deps
726721
727722
728723viewBranchDiff : ProjectRef -> ToggledChangeLines -> BranchDiff -> Html Msg
@@ -731,6 +726,12 @@ viewBranchDiff projectRef toggledChangeLines diff =
731726 summary =
732727 BranchDiff . summary diff
733728
729+ maxBadgeLength =
730+ diff. lines
731+ |> List . map ( ChangeLine . toString >> String . length)
732+ |> List . maximum
733+ |> Maybe . withDefault 0
734+
734735 -- There's no reason to show a tree with a single element...
735736 tree =
736737 if BranchDiff . size diff > 1 then
@@ -751,8 +752,8 @@ viewBranchDiff projectRef toggledChangeLines diff =
751752 , div [ class " branch-diff-content-cards" ]
752753 [ tree
753754 , div [ id " definition-changes" , class " definition-changes" ]
754- ( viewLibDeps diff. libDeps
755- ++ viewChangedDefinitionsCards projectRef toggledChangeLines diff
755+ ( viewLibDeps maxBadgeLength diff. libDeps
756+ ++ viewChangedDefinitionsCards projectRef toggledChangeLines maxBadgeLength diff
756757 )
757758 ]
758759 ]
0 commit comments