github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/src/Concourse/Pagination.elm (about)

     1  module Concourse.Pagination exposing
     2      ( Direction(..)
     3      , Page
     4      , Paginated
     5      , Pagination
     6      , chevronContainer
     7      , chevronLeft
     8      , chevronRight
     9      , equal
    10      , isPreviousPage
    11      )
    12  
    13  import Assets
    14  import Colors
    15  import Html
    16  import Html.Attributes exposing (style)
    17  
    18  
    19  type alias Paginated a =
    20      { content : List a
    21      , pagination : Pagination
    22      }
    23  
    24  
    25  type alias Pagination =
    26      { previousPage : Maybe Page
    27      , nextPage : Maybe Page
    28      }
    29  
    30  
    31  type alias Page =
    32      { direction : Direction
    33      , limit : Int
    34      }
    35  
    36  
    37  type Direction
    38      = From Int
    39      | To Int
    40      | ToMostRecent
    41  
    42  
    43  equal : Page -> Page -> Bool
    44  equal =
    45      (==)
    46  
    47  
    48  isPreviousPage : Page -> Bool
    49  isPreviousPage p =
    50      case p.direction of
    51          From _ ->
    52              True
    53  
    54          _ ->
    55              False
    56  
    57  
    58  chevronContainer : List (Html.Attribute msg)
    59  chevronContainer =
    60      [ style "padding" "5px"
    61      , style "display" "flex"
    62      , style "align-items" "center"
    63      , style "border-left" <| "1px solid " ++ Colors.background
    64      ]
    65  
    66  
    67  chevron :
    68      Assets.Asset
    69      -> { enabled : Bool, hovered : Bool }
    70      -> List (Html.Attribute msg)
    71  chevron asset { enabled, hovered } =
    72      [ style "background-image" <|
    73          Assets.backgroundImage <|
    74              Just asset
    75      , style "background-position" "50% 50%"
    76      , style "background-repeat" "no-repeat"
    77      , style "width" "24px"
    78      , style "height" "24px"
    79      , style "padding" "5px"
    80      , style "opacity" <|
    81          if enabled then
    82              "1"
    83  
    84          else
    85              "0.5"
    86      ]
    87          ++ (if hovered then
    88                  [ style "background-color" Colors.paginationHover
    89                  , style "border-radius" "50%"
    90                  ]
    91  
    92              else
    93                  []
    94             )
    95  
    96  
    97  chevronLeft : { enabled : Bool, hovered : Bool } -> List (Html.Attribute msg)
    98  chevronLeft =
    99      chevron <| Assets.ChevronLeft
   100  
   101  
   102  chevronRight : { enabled : Bool, hovered : Bool } -> List (Html.Attribute msg)
   103  chevronRight =
   104      chevron <| Assets.ChevronRight