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

     1  module Assets exposing
     2      ( Asset(..)
     3      , CircleOutlineIcon(..)
     4      , ComponentType(..)
     5      , backgroundImage
     6      , toString
     7      )
     8  
     9  import Concourse.BuildStatus exposing (BuildStatus(..))
    10  import Concourse.Cli exposing (Cli(..))
    11  import Concourse.PipelineStatus exposing (PipelineStatus(..))
    12  import Url.Builder
    13  
    14  
    15  type Asset
    16      = CliIcon Cli
    17      | ChevronLeft
    18      | ChevronRight
    19      | ToggleSwitch Bool
    20      | VisibilityToggleIcon Bool
    21      | FavoritedToggleIcon { isFavorited : Bool, isHovered : Bool, isSideBar : Bool }
    22      | BuildFavicon (Maybe BuildStatus)
    23      | PinIconWhite
    24      | PinIconGrey
    25      | CheckmarkIcon
    26      | BreadcrumbIcon ComponentType
    27      | ArchivedPipelineIcon
    28      | PassportOfficerIcon
    29      | ConcourseLogoWhite
    30      | CircleOutlineIcon CircleOutlineIcon
    31      | CogsIcon
    32      | RunningLegend
    33      | NotBlockingCheckIcon
    34      | RerunIcon
    35      | PendingIcon
    36      | InterruptedIcon
    37      | CancelledIcon
    38      | SuccessCheckIcon
    39      | FailureTimesIcon
    40      | ExclamationTriangleIcon
    41      | PipelineStatusIcon PipelineStatus
    42      | PipelineStatusIconStale
    43      | PipelineStatusIconJobsDisabled
    44      | ClippyIcon
    45      | UpArrow
    46      | DownArrow
    47      | RefreshIcon
    48      | MessageIcon
    49      | HamburgerMenuIcon
    50      | PeopleIcon
    51      | PipelineIconGrey
    52      | PipelineIconLightGrey
    53      | PipelineIconWhite
    54      | PlusIcon
    55      | MinusIcon
    56      | PlayIcon
    57      | PauseIcon
    58      | PencilIcon
    59      | SearchIconWhite
    60      | SearchIconGrey
    61      | CloseIcon
    62  
    63  
    64  type ComponentType
    65      = PipelineComponent
    66      | JobComponent
    67      | ResourceComponent
    68  
    69  
    70  type CircleOutlineIcon
    71      = PlayCircleIcon
    72      | PauseCircleIcon
    73      | AddCircleIcon
    74      | AbortCircleIcon
    75  
    76  
    77  toString : Asset -> String
    78  toString asset =
    79      Url.Builder.absolute (toPath asset) []
    80  
    81  
    82  backgroundImage : Maybe Asset -> String
    83  backgroundImage maybeAsset =
    84      case maybeAsset of
    85          Nothing ->
    86              "none"
    87  
    88          Just asset ->
    89              "url(" ++ toString asset ++ ")"
    90  
    91  
    92  toPath : Asset -> List String
    93  toPath asset =
    94      let
    95          basePath =
    96              [ "public", "images" ]
    97      in
    98      case asset of
    99          CliIcon cli ->
   100              let
   101                  imageName =
   102                      case cli of
   103                          OSX ->
   104                              "apple"
   105  
   106                          Windows ->
   107                              "windows"
   108  
   109                          Linux ->
   110                              "linux"
   111              in
   112              basePath ++ [ imageName ++ "-logo.svg" ]
   113  
   114          ChevronLeft ->
   115              basePath ++ [ "baseline-chevron-left.svg" ]
   116  
   117          ChevronRight ->
   118              basePath ++ [ "baseline-chevron-right.svg" ]
   119  
   120          ToggleSwitch on ->
   121              let
   122                  imageName =
   123                      if on then
   124                          "on"
   125  
   126                      else
   127                          "off"
   128              in
   129              basePath ++ [ "ic-toggle-" ++ imageName ++ ".svg" ]
   130  
   131          VisibilityToggleIcon visible ->
   132              let
   133                  imageName =
   134                      if visible then
   135                          ""
   136  
   137                      else
   138                          "-off"
   139              in
   140              basePath ++ [ "baseline-visibility" ++ imageName ++ ".svg" ]
   141  
   142          FavoritedToggleIcon { isFavorited, isHovered, isSideBar } ->
   143              let
   144                  imageName =
   145                      if isFavorited then
   146                          "-filled"
   147  
   148                      else if isHovered then
   149                          "-unfilled-white"
   150  
   151                      else if isSideBar then
   152                          "-unfilled-bright"
   153  
   154                      else
   155                          "-unfilled"
   156              in
   157              basePath ++ [ "star" ++ imageName ++ ".svg" ]
   158  
   159          BuildFavicon maybeStatus ->
   160              basePath
   161                  ++ (case maybeStatus of
   162                          Just status ->
   163                              let
   164                                  imageName =
   165                                      Concourse.BuildStatus.show status
   166                              in
   167                              [ "favicon-" ++ imageName ++ ".png" ]
   168  
   169                          Nothing ->
   170                              [ "favicon.png" ]
   171                     )
   172  
   173          PinIconWhite ->
   174              basePath ++ [ "pin-ic-white.svg" ]
   175  
   176          PinIconGrey ->
   177              basePath ++ [ "pin-ic-grey.svg" ]
   178  
   179          PencilIcon ->
   180              basePath ++ [ "pencil-white.svg" ]
   181  
   182          CheckmarkIcon ->
   183              basePath ++ [ "checkmark-ic.svg" ]
   184  
   185          BreadcrumbIcon component ->
   186              let
   187                  imageName =
   188                      case component of
   189                          PipelineComponent ->
   190                              "pipeline-white"
   191  
   192                          JobComponent ->
   193                              "job"
   194  
   195                          ResourceComponent ->
   196                              "resource"
   197              in
   198              basePath ++ [ "ic-breadcrumb-" ++ imageName ++ ".svg" ]
   199  
   200          ArchivedPipelineIcon ->
   201              basePath ++ [ "ic-archived-pipeline.svg" ]
   202  
   203          PassportOfficerIcon ->
   204              basePath ++ [ "passport-officer-ic.svg" ]
   205  
   206          ConcourseLogoWhite ->
   207              basePath ++ [ "concourse-logo-white.svg" ]
   208  
   209          CircleOutlineIcon icon ->
   210              let
   211                  imageName =
   212                      case icon of
   213                          PlayCircleIcon ->
   214                              "play"
   215  
   216                          PauseCircleIcon ->
   217                              "pause"
   218  
   219                          AddCircleIcon ->
   220                              "add"
   221  
   222                          AbortCircleIcon ->
   223                              "abort"
   224              in
   225              basePath ++ [ "ic-" ++ imageName ++ "-circle-outline-white.svg" ]
   226  
   227          CogsIcon ->
   228              basePath ++ [ "ic-cogs.svg" ]
   229  
   230          RunningLegend ->
   231              basePath ++ [ "ic-running-legend.svg" ]
   232  
   233          NotBlockingCheckIcon ->
   234              basePath ++ [ "ic-not-blocking-check.svg" ]
   235  
   236          RerunIcon ->
   237              basePath ++ [ "ic-rerun.svg" ]
   238  
   239          PendingIcon ->
   240              basePath ++ [ "ic-pending.svg" ]
   241  
   242          InterruptedIcon ->
   243              basePath ++ [ "ic-interrupted.svg" ]
   244  
   245          CancelledIcon ->
   246              basePath ++ [ "ic-cancelled.svg" ]
   247  
   248          SuccessCheckIcon ->
   249              basePath ++ [ "ic-success-check.svg" ]
   250  
   251          FailureTimesIcon ->
   252              basePath ++ [ "ic-failure-times.svg" ]
   253  
   254          ExclamationTriangleIcon ->
   255              basePath ++ [ "ic-exclamation-triangle.svg" ]
   256  
   257          PipelineStatusIcon status ->
   258              let
   259                  imageName =
   260                      case status of
   261                          PipelineStatusPaused ->
   262                              "ic-pause-blue.svg"
   263  
   264                          PipelineStatusPending _ ->
   265                              "ic-pending-grey.svg"
   266  
   267                          PipelineStatusSucceeded _ ->
   268                              "ic-running-green.svg"
   269  
   270                          PipelineStatusFailed _ ->
   271                              "ic-failing-red.svg"
   272  
   273                          PipelineStatusAborted _ ->
   274                              "ic-aborted-brown.svg"
   275  
   276                          PipelineStatusErrored _ ->
   277                              "ic-error-orange.svg"
   278              in
   279              basePath ++ [ imageName ]
   280  
   281          PipelineStatusIconStale ->
   282              basePath ++ [ "ic-cached-grey.svg" ]
   283  
   284          PipelineStatusIconJobsDisabled ->
   285              basePath ++ [ "ic-sync.svg" ]
   286  
   287          ClippyIcon ->
   288              basePath ++ [ "clippy.svg" ]
   289  
   290          UpArrow ->
   291              basePath ++ [ "ic-arrow-upward.svg" ]
   292  
   293          DownArrow ->
   294              basePath ++ [ "ic-arrow-downward.svg" ]
   295  
   296          RefreshIcon ->
   297              basePath ++ [ "baseline-refresh.svg" ]
   298  
   299          MessageIcon ->
   300              basePath ++ [ "baseline-message.svg" ]
   301  
   302          HamburgerMenuIcon ->
   303              basePath ++ [ "baseline-menu.svg" ]
   304  
   305          PeopleIcon ->
   306              basePath ++ [ "baseline-people.svg" ]
   307  
   308          PipelineIconGrey ->
   309              basePath ++ [ "ic-breadcrumb-pipeline-grey.svg" ]
   310  
   311          PipelineIconLightGrey ->
   312              basePath ++ [ "ic-breadcrumb-pipeline-lightgrey.svg" ]
   313  
   314          PipelineIconWhite ->
   315              basePath ++ [ "ic-breadcrumb-pipeline-white.svg" ]
   316  
   317          PlusIcon ->
   318              basePath ++ [ "ic-plus.svg" ]
   319  
   320          MinusIcon ->
   321              basePath ++ [ "ic-minus.svg" ]
   322  
   323          PlayIcon ->
   324              basePath ++ [ "ic-play-white.svg" ]
   325  
   326          PauseIcon ->
   327              basePath ++ [ "ic-pause-white.svg" ]
   328  
   329          SearchIconWhite ->
   330              basePath ++ [ "ic-search-white.svg" ]
   331  
   332          SearchIconGrey ->
   333              basePath ++ [ "ic-search-grey.svg" ]
   334  
   335          CloseIcon ->
   336              basePath ++ [ "ic-close-white.svg" ]