From da9e87a964c0e2dcbf148910b3781a4b4779ddb0 Mon Sep 17 00:00:00 2001 From: Johan Winther Date: Sun, 5 Nov 2023 17:17:46 +0100 Subject: [PATCH] Add Route to Click function --- src/UnisonLocal/Link.elm | 23 +++++++++++++++++++++++ src/UnisonLocal/Page/HomePage.elm | 23 +++++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/UnisonLocal/Link.elm b/src/UnisonLocal/Link.elm index f27b440..70a66b9 100644 --- a/src/UnisonLocal/Link.elm +++ b/src/UnisonLocal/Link.elm @@ -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) @@ -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 diff --git a/src/UnisonLocal/Page/HomePage.elm b/src/UnisonLocal/Page/HomePage.elm index e398425..dc10018 100644 --- a/src/UnisonLocal/Page/HomePage.elm +++ b/src/UnisonLocal/Page/HomePage.elm @@ -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 @@ -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 @@ -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 =