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

Commit d4e5aa6

Browse files
authored
Merge pull request #292 from unisonweb/move-app-header-to-app
Move AppHeader back up to App
2 parents 207b6f3 + aa127fe commit d4e5aa6

File tree

6 files changed

+502
-504
lines changed

6 files changed

+502
-504
lines changed

src/UI/PageLayout.elm

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module UI.PageLayout exposing (..)
22

33
import Html exposing (Html, div, header, section)
44
import Html.Attributes exposing (class, classList)
5-
import UI.AppHeader as AppHeader exposing (AppHeader)
65
import UI.Sidebar as Sidebar
76

87

@@ -16,18 +15,16 @@ type PageContent msg
1615

1716
type PageLayout msg
1817
= HeroLayout
19-
{ header : AppHeader msg
20-
, hero : PageHero msg
18+
{ hero : PageHero msg
2119
, content :
2220
PageContent msg
2321
}
2422
| SidebarLayout
25-
{ header : AppHeader msg
26-
, sidebar : List (Html msg)
23+
{ sidebar : List (Html msg)
2724
, sidebarToggled : Bool
2825
, content : PageContent msg
2926
}
30-
| FullLayout { header : AppHeader msg, content : PageContent msg }
27+
| FullLayout { content : PageContent msg }
3128

3229

3330

@@ -47,25 +44,22 @@ viewContent (PageContent content) =
4744
view : PageLayout msg -> Html msg
4845
view page =
4946
case page of
50-
HeroLayout { header, hero, content } ->
47+
HeroLayout { hero, content } ->
5148
div [ class "page hero-layout" ]
52-
[ AppHeader.view header
53-
, viewHero hero
49+
[ viewHero hero
5450
, viewContent content
5551
]
5652

57-
SidebarLayout { header, sidebar, sidebarToggled, content } ->
53+
SidebarLayout { sidebar, sidebarToggled, content } ->
5854
div
5955
[ class "page sidebar-layout"
6056
, classList [ ( "sidebar-toggled", sidebarToggled ) ]
6157
]
62-
[ AppHeader.view header
63-
, Sidebar.view sidebar
58+
[ Sidebar.view sidebar
6459
, viewContent content
6560
]
6661

67-
FullLayout { header, content } ->
62+
FullLayout { content } ->
6863
div [ class "page full-layout" ]
69-
[ AppHeader.view header
70-
, viewContent content
64+
[ viewContent content
7165
]

src/UnisonLocal/App.elm

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -754,33 +754,37 @@ viewModal model =
754754

755755
viewAppLoading : Html msg
756756
viewAppLoading =
757-
PageLayout.view
758-
(PageLayout.SidebarLayout
759-
{ header = AppHeader.appHeader (appTitle Nothing)
760-
, sidebar = []
761-
, sidebarToggled = False
762-
, content = PageLayout.PageContent []
763-
}
764-
)
757+
div [ id "app" ]
758+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
759+
, PageLayout.view
760+
(PageLayout.SidebarLayout
761+
{ sidebar = []
762+
, sidebarToggled = False
763+
, content = PageLayout.PageContent []
764+
}
765+
)
766+
]
765767

766768

767769
viewAppError : Http.Error -> Html msg
768770
viewAppError error =
769-
PageLayout.view
770-
(PageLayout.SidebarLayout
771-
{ header = AppHeader.appHeader (appTitle Nothing)
772-
, sidebar = []
773-
, sidebarToggled = False
774-
, content =
775-
PageLayout.PageContent
776-
[ div [ class "app-error" ]
777-
[ Icon.view Icon.warn
778-
, p [ title (Api.errorToString error) ]
779-
[ text "Unison Local could not be started." ]
771+
div [ id "app" ]
772+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
773+
, PageLayout.view
774+
(PageLayout.SidebarLayout
775+
{ sidebar = []
776+
, sidebarToggled = False
777+
, content =
778+
PageLayout.PageContent
779+
[ div [ class "app-error" ]
780+
[ Icon.view Icon.warn
781+
, p [ title (Api.errorToString error) ]
782+
[ text "Unison Local could not be started." ]
783+
]
780784
]
781-
]
782-
}
783-
)
785+
}
786+
)
787+
]
784788

785789

786790
view : Model -> Browser.Document Msg
@@ -800,12 +804,11 @@ view model =
800804

801805
page =
802806
PageLayout.SidebarLayout
803-
{ header = viewAppHeader model
804-
, sidebar = viewMainSidebar model
807+
{ sidebar = viewMainSidebar model
805808
, sidebarToggled = model.sidebarToggled
806809
, content = PageLayout.PageContent [ pageContent ]
807810
}
808811
in
809812
{ title = "Unison Local"
810-
, body = [ div [ id "app" ] [ PageLayout.view page, viewModal model ] ]
813+
, body = [ div [ id "app" ] [ AppHeader.view (viewAppHeader model), PageLayout.view page, viewModal model ] ]
811814
}

src/UnisonShare/App.elm

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -646,54 +646,51 @@ viewMainSidebar model =
646646

647647
viewAppLoading : Html msg
648648
viewAppLoading =
649-
PageLayout.view
650-
(PageLayout.FullLayout
651-
{ header = AppHeader.appHeader (appTitle Nothing)
652-
, content = PageLayout.PageContent []
653-
}
654-
)
649+
div [ id "app" ]
650+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
651+
, PageLayout.view
652+
(PageLayout.FullLayout
653+
{ content = PageLayout.PageContent [] }
654+
)
655+
]
655656

656657

657658
viewAppError : Http.Error -> Html msg
658659
viewAppError error =
659-
PageLayout.view
660-
(PageLayout.FullLayout
661-
{ header = AppHeader.appHeader (appTitle Nothing)
662-
, content =
663-
PageLayout.PageContent
664-
[ div [ class "app-error" ]
665-
[ Icon.view Icon.warn
666-
, p [ title (Api.errorToString error) ]
667-
[ text "Unison Share could not be started." ]
660+
div [ id "app" ]
661+
[ AppHeader.view (AppHeader.appHeader (appTitle Nothing))
662+
, PageLayout.view
663+
(PageLayout.FullLayout
664+
{ content =
665+
PageLayout.PageContent
666+
[ div [ class "app-error" ]
667+
[ Icon.view Icon.warn
668+
, p [ title (Api.errorToString error) ]
669+
[ text "Unison Share could not be started." ]
670+
]
668671
]
669-
]
670-
}
671-
)
672+
}
673+
)
674+
]
672675

673676

674677
view : Model -> Browser.Document Msg
675678
view model =
676679
let
677680
appHeader =
678-
viewAppHeader model
681+
AppHeader.view (viewAppHeader model)
679682

680683
withSidebar pageContent =
681684
PageLayout.SidebarLayout
682-
{ header = viewAppHeader model
683-
, sidebar = viewMainSidebar model
685+
{ sidebar = viewMainSidebar model
684686
, sidebarToggled = model.sidebarToggled
685687
, content = PageLayout.PageContent [ pageContent ]
686688
}
687689

688690
page =
689691
case model.route of
690692
Route.Catalog ->
691-
let
692-
( m, _ ) =
693-
Catalog.init model.env
694-
in
695-
-- Html.map CatalogMsg (Catalog.view appHeader m)
696-
Catalog.view appHeader m
693+
Html.map CatalogMsg (Catalog.view model.catalog)
697694

698695
Route.Perspective _ ->
699696
Html.map PerspectiveLandingMsg
@@ -712,7 +709,8 @@ view model =
712709
{ title = "Unison Share"
713710
, body =
714711
[ div [ id "app" ]
715-
[ page
712+
[ appHeader
713+
, page
716714
, Html.map AppModalMsg (AppModal.view model.env model.appModal)
717715
]
718716
]

src/UnisonShare/Page/Catalog.elm

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import Env exposing (Env)
66
import FullyQualifiedName as FQN
77
import Html exposing (Html, a, div, h1, input, strong, text)
88
import Html.Attributes exposing (class, href, placeholder)
9+
import Html.Events exposing (onInput)
910
import Http
1011
import Project exposing (ProjectListing)
1112
import RemoteData exposing (RemoteData(..), WebData)
1213
import Set exposing (Set)
1314
import UI
14-
import UI.AppHeader exposing (AppHeader)
1515
import UI.Card as Card
1616
import UI.Icon as Icon
1717
import UI.PageLayout as PageLayout exposing (PageLayout)
@@ -133,8 +133,8 @@ viewCategory (Category category projects) =
133133
|> Card.view
134134

135135

136-
viewLoaded : AppHeader msg -> LoadedModel -> PageLayout msg
137-
viewLoaded appHeader _ =
136+
viewLoaded : LoadedModel -> PageLayout Msg
137+
viewLoaded model =
138138
let
139139
content =
140140
[ div [ class "categories" ]
@@ -165,8 +165,7 @@ viewLoaded appHeader _ =
165165
]
166166
in
167167
PageLayout.HeroLayout
168-
{ header = appHeader
169-
, hero =
168+
{ hero =
170169
PageLayout.PageHero
171170
(div [ class "catalog-hero" ]
172171
[ h1 []
@@ -180,37 +179,43 @@ viewLoaded appHeader _ =
180179
]
181180
, div [] [ text "Projects, libraries, documention, terms, and types" ]
182181
]
183-
, div [ class "catalog-search" ] [ Icon.view Icon.search, input [ placeholder "Search for projects" ] [] ]
182+
, div [ class "catalog-search" ]
183+
[ Icon.view Icon.search
184+
, input
185+
[ placeholder "Search for projects"
186+
, onInput UpdateQuery
187+
]
188+
[]
189+
]
184190
]
185191
)
186192
, content = PageLayout.PageContent content
187193
}
188194

189195

190-
disabledPage : AppHeader msg -> Html msg -> PageLayout msg
191-
disabledPage appHeader content =
196+
disabledPage : Html Msg -> PageLayout Msg
197+
disabledPage content =
192198
PageLayout.HeroLayout
193-
{ header = appHeader
194-
, hero = PageLayout.PageHero UI.nothing
199+
{ hero = PageLayout.PageHero UI.nothing
195200
, content = PageLayout.PageContent [ content ]
196201
}
197202

198203

199-
view : AppHeader msg -> Model -> Html msg
200-
view appHeader model =
204+
view : Model -> Html Msg
205+
view model =
201206
let
202207
page =
203208
case model of
204209
NotAsked ->
205-
disabledPage appHeader (div [] [])
210+
disabledPage (div [] [])
206211

207212
Loading ->
208-
disabledPage appHeader (div [] [])
213+
disabledPage (div [] [])
209214

210215
Failure _ ->
211-
disabledPage appHeader (div [] [])
216+
disabledPage (div [] [])
212217

213218
Success m ->
214-
viewLoaded appHeader m
219+
viewLoaded m
215220
in
216221
PageLayout.view page

0 commit comments

Comments
 (0)