Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Use normal hrefs for the App title click #311

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/UI/AppHeader.elm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module UI.AppHeader exposing (..)

import Html exposing (Html, a, header, section, span)
import Html exposing (Html, a, header, section)
import Html.Attributes exposing (class, id)
import Html.Events exposing (onClick)
import UI
import UI.Banner as Banner exposing (Banner)
import UI.Button as Button exposing (Button)
import UI.Click as Click exposing (Click)
import UI.Icon as Icon


type AppTitle msg
= Clickable msg (Html msg)
| Disabled (Html msg)
= AppTitle (Click msg) (Html msg)


type alias MenuToggle msg =
Expand Down Expand Up @@ -70,13 +70,8 @@ view appHeader_ =


viewAppTitle : AppTitle msg -> Html msg
viewAppTitle title =
case title of
Clickable clickMsg content ->
a [ class "app-title", onClick clickMsg ] [ content ]

Disabled content ->
span [ class "app-title" ] [ content ]
viewAppTitle (AppTitle click content) =
Click.view [ class "app-title" ] [ content ] click


view_ : List (Html msg) -> Html msg
Expand Down
44 changes: 14 additions & 30 deletions src/UnisonLocal/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -451,36 +451,20 @@ subscriptions model =
-- VIEW


appTitle : Maybe msg -> AppHeader.AppTitle msg
appTitle clickMsg =
let
appTitle_ =
case clickMsg of
Nothing ->
AppHeader.Disabled

Just msg ->
AppHeader.Clickable msg
in
appTitle_ (h1 [] [ text "Unison", span [ class "context unison-local" ] [ text "Local" ] ])


viewAppHeader : Model -> AppHeader.AppHeader Msg
viewAppHeader model =
let
changePerspectiveMsg =
case model.env.perspective of
Codebase codebaseHash ->
ChangePerspective (Codebase codebaseHash)
appTitle : Click msg -> AppHeader.AppTitle msg
appTitle click =
AppHeader.AppTitle click
(h1 []
[ text "Unison"
, span [ class "context unison-local" ] [ text "Local" ]
]
)

Namespace { codebaseHash } ->
ChangePerspective (Codebase codebaseHash)

appTitle_ =
appTitle (Just changePerspectiveMsg)
in
appHeader : AppHeader.AppHeader Msg
appHeader =
{ menuToggle = Just ToggleSidebar
, appTitle = appTitle_
, appTitle = appTitle (Click.Href "/")
, banner = Nothing
, rightButton = Just (Button.button (ShowModal PublishModal) "Publish on Unison Share" |> Button.share)
}
Expand Down Expand Up @@ -746,7 +730,7 @@ viewModal model =
viewAppLoading : Html msg
viewAppLoading =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
[ AppHeader.view (AppHeader.appHeader (appTitle Click.Disabled))
, PageLayout.view
(PageLayout.SidebarLayout
{ sidebar = []
Expand All @@ -760,7 +744,7 @@ viewAppLoading =
viewAppError : Http.Error -> Html msg
viewAppError error =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
[ AppHeader.view (AppHeader.appHeader (appTitle Click.Disabled))
, PageLayout.view
(PageLayout.SidebarLayout
{ sidebar = []
Expand Down Expand Up @@ -801,5 +785,5 @@ view model =
}
in
{ title = "Unison Local"
, body = [ div [ id "app" ] [ AppHeader.view (viewAppHeader model), PageLayout.view page, viewModal model ] ]
, body = [ div [ id "app" ] [ AppHeader.view appHeader, PageLayout.view page, viewModal model ] ]
}
46 changes: 14 additions & 32 deletions src/UnisonShare/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -494,34 +494,19 @@ subscriptions model =
-- VIEW


appTitle : Maybe msg -> AppHeader.AppTitle msg
appTitle clickMsg =
let
appTitle_ =
case clickMsg of
Nothing ->
AppHeader.Disabled

Just msg ->
AppHeader.Clickable msg
in
appTitle_ (h1 [] [ text "Unison", span [ class "context unison-share" ] [ text "Share" ] ])
appTitle : Click msg -> AppHeader.AppTitle msg
appTitle click =
AppHeader.AppTitle click
(h1 []
[ text "Unison"
, span [ class "context unison-share" ] [ text "Share" ]
]
)


viewAppHeader : Model -> AppHeader.AppHeader Msg
viewAppHeader model =
appHeader : AppHeader.AppHeader Msg
appHeader =
let
changePerspectiveMsg =
case model.env.perspective of
Codebase codebaseHash ->
ChangePerspective (Codebase codebaseHash)

Namespace { codebaseHash } ->
ChangePerspective (Codebase codebaseHash)

appTitle_ =
appTitle (Just changePerspectiveMsg)

banner =
Just
(Banner.promotion "article"
Expand All @@ -531,7 +516,7 @@ viewAppHeader model =
)
in
{ menuToggle = Just ToggleSidebar
, appTitle = appTitle_
, appTitle = appTitle (Click.Href "/")
, banner = banner
, rightButton = Just (Button.button (ShowModal AppModal.PublishModal) "Publish on Unison Share" |> Button.share)
}
Expand Down Expand Up @@ -675,7 +660,7 @@ viewMainSidebar model =
viewAppLoading : Html msg
viewAppLoading =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
[ AppHeader.view (AppHeader.appHeader (appTitle Click.Disabled))
, PageLayout.view
(PageLayout.FullLayout
{ content = PageLayout.PageContent [] }
Expand All @@ -686,7 +671,7 @@ viewAppLoading =
viewAppError : Http.Error -> Html msg
viewAppError error =
div [ id "app" ]
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
[ AppHeader.view (AppHeader.appHeader (appTitle Click.Disabled))
, PageLayout.view
(PageLayout.FullLayout
{ content =
Expand All @@ -705,9 +690,6 @@ viewAppError error =
view : Model -> Browser.Document Msg
view model =
let
appHeader =
AppHeader.view (viewAppHeader model)

withSidebar pageContent =
PageLayout.SidebarLayout
{ sidebar = viewMainSidebar model
Expand Down Expand Up @@ -748,7 +730,7 @@ view model =
{ title = "Unison Share"
, body =
[ div [ id "app", class pageId ]
[ appHeader
[ AppHeader.view appHeader
, page
, Html.map AppModalMsg (AppModal.view model.env model.appModal)
]
Expand Down