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

Commit c2b9f8c

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 c2b9f8c

File tree

19 files changed

+341
-64
lines changed

19 files changed

+341
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"start:unisonLocal": "webpack serve --mode development --port 1234 --config webpack.unisonLocal.dev.js",
1414
"start:unisonShare": "webpack serve --mode development --port 1234 --config webpack.unisonShare.dev.js",
1515
"test": "elm-test",
16-
"review": "elm-review --ignore-files src/UI/Card.elm"
16+
"review": "elm-review"
1717
},
1818
"bugs": {
1919
"url": "https://github.com/unisonweb/codebase-ui/issues"

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Project exposing (..)
22

33
import FullyQualifiedName exposing (FQN)
4-
import Hash exposing (Hash)
54
import Json.Decode as Decode
65

76

@@ -10,13 +9,18 @@ type Owner
109

1110

1211
type alias Project a =
13-
{ a | owner : Owner, name : FQN, hash : Hash }
12+
{ a | owner : Owner, name : FQN }
1413

1514

1615
type alias ProjectListing =
1716
Project {}
1817

1918

19+
ownerToString : Owner -> String
20+
ownerToString (Owner o) =
21+
o
22+
23+
2024
decodeList : Decode.Decoder (List ProjectListing)
2125
decodeList =
2226
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: 19 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,15 @@ 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+
( model, Nav.pushUrl model.navKey (Url.toString url) )
136+
137+
-- External links are handled via target blank and never end up
138+
-- here
139+
Browser.External _ ->
140+
( model, Cmd.none )
134141

135142
UrlChanged url ->
136143
let
@@ -747,25 +754,25 @@ viewModal model =
747754

748755
viewAppLoading : Html msg
749756
viewAppLoading =
750-
Page.view
751-
(Page.SidebarLayout
757+
PageLayout.view
758+
(PageLayout.SidebarLayout
752759
{ header = AppHeader.appHeader (appTitle Nothing)
753760
, sidebar = []
754761
, sidebarToggled = False
755-
, content = Page.PageContent []
762+
, content = PageLayout.PageContent []
756763
}
757764
)
758765

759766

760767
viewAppError : Http.Error -> Html msg
761768
viewAppError error =
762-
Page.view
763-
(Page.SidebarLayout
769+
PageLayout.view
770+
(PageLayout.SidebarLayout
764771
{ header = AppHeader.appHeader (appTitle Nothing)
765772
, sidebar = []
766773
, sidebarToggled = False
767774
, content =
768-
Page.PageContent
775+
PageLayout.PageContent
769776
[ div [ class "app-error" ]
770777
[ Icon.view Icon.warn
771778
, p [ title (Api.errorToString error) ]
@@ -792,13 +799,13 @@ view model =
792799
Html.map WorkspaceMsg (Workspace.view model.workspace)
793800

794801
page =
795-
Page.SidebarLayout
802+
PageLayout.SidebarLayout
796803
{ header = viewAppHeader model
797804
, sidebar = viewMainSidebar model
798805
, sidebarToggled = model.sidebarToggled
799-
, content = Page.PageContent [ pageContent ]
806+
, content = PageLayout.PageContent [ pageContent ]
800807
}
801808
in
802809
{ title = "Unison Local"
803-
, body = [ div [ id "app" ] [ Page.view page, viewModal model ] ]
810+
, body = [ div [ id "app" ] [ PageLayout.view page, viewModal model ] ]
804811
}

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)