Skip to content

Commit

Permalink
Add Route to Click function
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanWinther committed Nov 5, 2023
1 parent 83168b2 commit da9e87a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
23 changes: 23 additions & 0 deletions src/UnisonLocal/Link.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module UnisonLocal.Link exposing (..)

import Code.BranchRef exposing (BranchRef)
import Code.Perspective as Perspective
import Html exposing (Html, text)
import UI.Click as Click exposing (Click)
import UnisonLocal.ProjectName exposing (ProjectName)
import UnisonLocal.Route as Route exposing (Route)



Expand All @@ -13,6 +17,25 @@ import UI.Click as Click exposing (Click)
Various UI.Click link helpers for Routes and external links
-}
-- ROUTES


projectBranchRoot : ProjectName -> BranchRef -> Click msg
projectBranchRoot projectName branchRef =
let
pers =
Perspective.relativeRootPerspective
in
Route.projectBranchRoot projectName branchRef pers
|> toClick


toClick : Route -> Click msg
toClick =
Route.toUrlString >> Click.href



-- EXTERNAL


Expand Down
23 changes: 11 additions & 12 deletions src/UnisonLocal/Page/HomePage.elm
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module UnisonLocal.Page.HomePage exposing (..)

import Code.BranchRef as BranchRef exposing (BranchSlug(..))
import Code.Perspective as Perspective
import Dict exposing (Dict)
import Html exposing (Html, div, h2, p, text)
import Json.Decode as Decode
import Lib.HttpApi as HttpApi
import Lib.Util as Util
import RemoteData exposing (RemoteData(..), WebData)
import UI.Click as Click
import UI.PageContent as PageContent
import UI.PageLayout as PageLayout exposing (PageFooter(..))
import UI.PageTitle as PageTitle
Expand All @@ -17,8 +15,8 @@ import UnisonLocal.Api as LocalApi
import UnisonLocal.AppContext exposing (AppContext)
import UnisonLocal.AppDocument as AppDocument exposing (AppDocument)
import UnisonLocal.AppHeader as AppHeader
import UnisonLocal.Link as Link
import UnisonLocal.ProjectName as ProjectName exposing (ProjectName)
import UnisonLocal.Route as Route



Expand Down Expand Up @@ -142,15 +140,16 @@ viewProjectList : Projects -> List (Html Msg)
viewProjectList projects =
let
branchTag projectName branchName =
BranchRef.projectBranchRef branchName
|> (\branchRef ->
BranchRef.toTag branchRef
|> Tag.withClick
(Route.projectBranchRoot projectName branchRef Perspective.relativeRootPerspective
|> Route.toUrlString
|> Click.href
)
)
let
branchRef =
BranchRef.projectBranchRef branchName

branchRootLink =
Link.projectBranchRoot projectName branchRef
in
branchRef
|> BranchRef.toTag
|> Tag.withClick branchRootLink
|> Tag.view

branchList projectName branches =
Expand Down

0 comments on commit da9e87a

Please sign in to comment.