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

Commit 27026b0

Browse files
committed
Add (and style) the basic Catalog page layout
* To support the Catalog page, add a unison-share css folder for the catalog page and a new Card module for cards holding each category in the catalog. * Rename `UI.Page` to `UI.PageLayout` to better communicate what that module is for. * Add a way to generate a Route from a Project (exclusively to the Unison Share target) to allow clicking to through to the project page from the catalog
1 parent 470a9d7 commit 27026b0

File tree

18 files changed

+348
-63
lines changed

18 files changed

+348
-63
lines changed

src/CodebaseTree.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import FullyQualifiedName as FQN exposing (FQN, unqualifiedName)
1515
import FullyQualifiedNameSet as FQNSet exposing (FQNSet)
1616
import HashQualified exposing (HashQualified(..))
1717
import Html exposing (Html, a, div, label, span, text)
18-
import Html.Attributes exposing (class, title)
18+
import Html.Attributes exposing (class, href, title)
1919
import Html.Events exposing (onClick)
2020
import Http
2121
import Perspective exposing (Perspective)

src/FullyQualifiedName.elm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module FullyQualifiedName exposing
22
( FQN
33
, append
4+
, cons
45
, decode
56
, decodeFromParent
67
, equals
@@ -16,6 +17,7 @@ module FullyQualifiedName exposing
1617
, namespaceOf
1718
, numSegments
1819
, segments
20+
, snoc
1921
, toString
2022
, toUrlSegments
2123
, toUrlString
@@ -179,6 +181,16 @@ append (FQN a) (FQN b) =
179181
FQN (NEL.append a b)
180182

181183

184+
cons : String -> FQN -> FQN
185+
cons s (FQN segments_) =
186+
FQN (NEL.cons s segments_)
187+
188+
189+
snoc : FQN -> String -> FQN
190+
snoc (FQN segments_) s =
191+
FQN (NEL.append segments_ (NEL.fromElement s))
192+
193+
182194
{-| This is passed through a string as a suffix name can include
183195
namespaces like List.map (where the FQN would be
184196
base.List.map)

src/Project.elm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ type Owner
1010

1111

1212
type alias Project a =
13-
{ a | owner : Owner, name : FQN, hash : Hash }
13+
{ a | owner : Owner, name : FQN }
14+
15+
16+
17+
-- { a | owner : Owner, name : FQN, hash : Hash }
1418

1519

1620
type alias ProjectListing =
1721
Project {}
1822

1923

24+
ownerToString : Owner -> String
25+
ownerToString (Owner o) =
26+
o
27+
28+
2029
decodeList : Decode.Decoder (List ProjectListing)
2130
decodeList =
2231
Decode.succeed []

src/UI/Card.elm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module UI.Card exposing (..)
22

3-
import Html exposing (Html, div, text)
3+
import Html exposing (Html, div, h3, text)
44
import Html.Attributes exposing (class)
55

66

@@ -40,5 +40,8 @@ view card_ =
4040
case card_.title of
4141
Just t ->
4242
h3 [ class "card-title" ] [ text t ] :: card_.items
43+
44+
Nothing ->
45+
card_.items
4346
in
4447
div [ class "card" ] items

src/UI/Page.elm renamed to src/UI/PageLayout.elm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
module UI.Page exposing (..)
1+
module UI.PageLayout exposing (..)
22

33
import Html exposing (Html, div, header, section)
44
import Html.Attributes exposing (class, classList)
55
import UI.AppHeader as AppHeader exposing (AppHeader)
66
import UI.Sidebar as Sidebar
77

88

9-
type Hero msg
10-
= Hero (Html msg)
9+
type PageHero msg
10+
= PageHero (Html msg)
1111

1212

1313
type PageContent msg
1414
= PageContent (List (Html msg))
1515

1616

17-
type Page msg
17+
type PageLayout msg
1818
= HeroLayout
1919
{ header : AppHeader msg
20-
, hero : Hero msg
20+
, hero : PageHero msg
2121
, content :
2222
PageContent msg
2323
}
@@ -34,8 +34,8 @@ type Page msg
3434
-- VIEW
3535

3636

37-
viewHero : Hero msg -> Html msg
38-
viewHero (Hero content) =
37+
viewHero : PageHero msg -> Html msg
38+
viewHero (PageHero content) =
3939
header [ class "page-hero" ] [ content ]
4040

4141

@@ -44,7 +44,7 @@ viewContent (PageContent content) =
4444
section [ class "page-content" ] content
4545

4646

47-
view : Page msg -> Html msg
47+
view : PageLayout msg -> Html msg
4848
view page =
4949
case page of
5050
HeroLayout { header, hero, content } ->

src/UnisonLocal/App.elm

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import UI.Button as Button
2626
import UI.Click as Click exposing (Click(..))
2727
import UI.Icon as Icon
2828
import UI.Modal as Modal
29-
import UI.Page as Page
29+
import UI.PageLayout as PageLayout
3030
import UI.Sidebar as Sidebar
3131
import UI.Tooltip as Tooltip
3232
import UnisonLocal.Route as Route exposing (Route)
@@ -129,8 +129,19 @@ type Msg
129129
update : Msg -> Model -> ( Model, Cmd Msg )
130130
update msg ({ env } as model) =
131131
case msg of
132-
LinkClicked _ ->
133-
( model, Cmd.none )
132+
LinkClicked urlRequest ->
133+
case urlRequest of
134+
Browser.Internal url ->
135+
let
136+
x =
137+
Debug.log "url" url
138+
in
139+
( model, Nav.pushUrl model.navKey (Url.toString url) )
140+
141+
-- External links are handled via target blank and never end up
142+
-- here
143+
Browser.External _ ->
144+
( model, Cmd.none )
134145

135146
UrlChanged url ->
136147
let
@@ -747,25 +758,25 @@ viewModal model =
747758

748759
viewAppLoading : Html msg
749760
viewAppLoading =
750-
Page.view
751-
(Page.SidebarLayout
761+
PageLayout.view
762+
(PageLayout.SidebarLayout
752763
{ header = AppHeader.appHeader (appTitle Nothing)
753764
, sidebar = []
754765
, sidebarToggled = False
755-
, content = Page.PageContent []
766+
, content = PageLayout.PageContent []
756767
}
757768
)
758769

759770

760771
viewAppError : Http.Error -> Html msg
761772
viewAppError error =
762-
Page.view
763-
(Page.SidebarLayout
773+
PageLayout.view
774+
(PageLayout.SidebarLayout
764775
{ header = AppHeader.appHeader (appTitle Nothing)
765776
, sidebar = []
766777
, sidebarToggled = False
767778
, content =
768-
Page.PageContent
779+
PageLayout.PageContent
769780
[ div [ class "app-error" ]
770781
[ Icon.view Icon.warn
771782
, p [ title (Api.errorToString error) ]
@@ -792,13 +803,13 @@ view model =
792803
Html.map WorkspaceMsg (Workspace.view model.workspace)
793804

794805
page =
795-
Page.SidebarLayout
806+
PageLayout.SidebarLayout
796807
{ header = viewAppHeader model
797808
, sidebar = viewMainSidebar model
798809
, sidebarToggled = model.sidebarToggled
799-
, content = Page.PageContent [ pageContent ]
810+
, content = PageLayout.PageContent [ pageContent ]
800811
}
801812
in
802813
{ title = "Unison Local"
803-
, body = [ div [ id "app" ] [ Page.view page, viewModal model ] ]
814+
, body = [ div [ id "app" ] [ PageLayout.view page, viewModal model ] ]
804815
}

src/UnisonShare/App.elm

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UI.Banner as Banner
2424
import UI.Button as Button
2525
import UI.Click as Click exposing (Click(..))
2626
import UI.Icon as Icon
27-
import UI.Page as Page
27+
import UI.PageLayout as PageLayout
2828
import UI.Sidebar as Sidebar
2929
import UI.Tooltip as Tooltip
3030
import UnisonShare.AppModal as AppModal
@@ -126,8 +126,15 @@ type Msg
126126
update : Msg -> Model -> ( Model, Cmd Msg )
127127
update msg ({ env } as model) =
128128
case msg of
129-
LinkClicked _ ->
130-
( model, Cmd.none )
129+
LinkClicked urlRequest ->
130+
case urlRequest of
131+
Browser.Internal url ->
132+
( model, Nav.pushUrl model.navKey (Url.toString url) )
133+
134+
-- External links are handled via target blank and never end up
135+
-- here
136+
Browser.External _ ->
137+
( model, Cmd.none )
131138

132139
UrlChanged url ->
133140
let
@@ -639,21 +646,21 @@ viewMainSidebar model =
639646

640647
viewAppLoading : Html msg
641648
viewAppLoading =
642-
Page.view
643-
(Page.FullLayout
649+
PageLayout.view
650+
(PageLayout.FullLayout
644651
{ header = AppHeader.appHeader (appTitle Nothing)
645-
, content = Page.PageContent []
652+
, content = PageLayout.PageContent []
646653
}
647654
)
648655

649656

650657
viewAppError : Http.Error -> Html msg
651658
viewAppError error =
652-
Page.view
653-
(Page.FullLayout
659+
PageLayout.view
660+
(PageLayout.FullLayout
654661
{ header = AppHeader.appHeader (appTitle Nothing)
655662
, content =
656-
Page.PageContent
663+
PageLayout.PageContent
657664
[ div [ class "app-error" ]
658665
[ Icon.view Icon.warn
659666
, p [ title (Api.errorToString error) ]
@@ -671,11 +678,11 @@ view model =
671678
viewAppHeader model
672679

673680
withSidebar pageContent =
674-
Page.SidebarLayout
681+
PageLayout.SidebarLayout
675682
{ header = viewAppHeader model
676683
, sidebar = viewMainSidebar model
677684
, sidebarToggled = model.sidebarToggled
678-
, content = Page.PageContent [ pageContent ]
685+
, content = PageLayout.PageContent [ pageContent ]
679686
}
680687

681688
page =
@@ -695,12 +702,12 @@ view model =
695702
model.perspectiveLanding
696703
)
697704
|> withSidebar
698-
|> Page.view
705+
|> PageLayout.view
699706

700707
Route.Definition _ _ ->
701708
Html.map WorkspaceMsg (Workspace.view model.workspace)
702709
|> withSidebar
703-
|> Page.view
710+
|> PageLayout.view
704711
in
705712
{ title = "Unison Share"
706713
, body =

0 commit comments

Comments
 (0)