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

Add (and style) the basic Catalog page layout #290

Merged
merged 1 commit into from
Dec 15, 2021
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start:unisonLocal": "webpack serve --mode development --port 1234 --config webpack.unisonLocal.dev.js",
"start:unisonShare": "webpack serve --mode development --port 1234 --config webpack.unisonShare.dev.js",
"test": "elm-test",
"review": "elm-review --ignore-files src/UI/Card.elm"
"review": "elm-review"
},
"bugs": {
"url": "https://github.com/unisonweb/codebase-ui/issues"
Expand Down
12 changes: 12 additions & 0 deletions src/FullyQualifiedName.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module FullyQualifiedName exposing
( FQN
, append
, cons
, decode
, decodeFromParent
, equals
Expand All @@ -16,6 +17,7 @@ module FullyQualifiedName exposing
, namespaceOf
, numSegments
, segments
, snoc
, toString
, toUrlSegments
, toUrlString
Expand Down Expand Up @@ -179,6 +181,16 @@ append (FQN a) (FQN b) =
FQN (NEL.append a b)


cons : String -> FQN -> FQN
cons s (FQN segments_) =
FQN (NEL.cons s segments_)


snoc : FQN -> String -> FQN
snoc (FQN segments_) s =
FQN (NEL.append segments_ (NEL.fromElement s))


{-| This is passed through a string as a suffix name can include
namespaces like List.map (where the FQN would be
base.List.map)
Expand Down
8 changes: 6 additions & 2 deletions src/Project.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Project exposing (..)

import FullyQualifiedName exposing (FQN)
import Hash exposing (Hash)
import Json.Decode as Decode


Expand All @@ -10,13 +9,18 @@ type Owner


type alias Project a =
{ a | owner : Owner, name : FQN, hash : Hash }
{ a | owner : Owner, name : FQN }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the Hash field for now to make it easier to mock (creating a Hash returns a Maybe)—it'll be back in a later iteration.



type alias ProjectListing =
Project {}


ownerToString : Owner -> String
ownerToString (Owner o) =
o


decodeList : Decode.Decoder (List ProjectListing)
decodeList =
Decode.succeed []
5 changes: 4 additions & 1 deletion src/UI/Card.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module UI.Card exposing (..)

import Html exposing (Html, div, text)
import Html exposing (Html, div, h3, text)
import Html.Attributes exposing (class)


Expand Down Expand Up @@ -40,5 +40,8 @@ view card_ =
case card_.title of
Just t ->
h3 [ class "card-title" ] [ text t ] :: card_.items

Nothing ->
card_.items
in
div [ class "card" ] items
16 changes: 8 additions & 8 deletions src/UI/Page.elm → src/UI/PageLayout.elm
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module UI.Page exposing (..)
module UI.PageLayout exposing (..)

import Html exposing (Html, div, header, section)
import Html.Attributes exposing (class, classList)
import UI.AppHeader as AppHeader exposing (AppHeader)
import UI.Sidebar as Sidebar


type Hero msg
= Hero (Html msg)
type PageHero msg
= PageHero (Html msg)


type PageContent msg
= PageContent (List (Html msg))


type Page msg
type PageLayout msg
= HeroLayout
{ header : AppHeader msg
, hero : Hero msg
, hero : PageHero msg
, content :
PageContent msg
}
Expand All @@ -34,8 +34,8 @@ type Page msg
-- VIEW


viewHero : Hero msg -> Html msg
viewHero (Hero content) =
viewHero : PageHero msg -> Html msg
viewHero (PageHero content) =
header [ class "page-hero" ] [ content ]


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


view : Page msg -> Html msg
view : PageLayout msg -> Html msg
view page =
case page of
HeroLayout { header, hero, content } ->
Expand Down
31 changes: 19 additions & 12 deletions src/UnisonLocal/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import UI.Button as Button
import UI.Click as Click exposing (Click(..))
import UI.Icon as Icon
import UI.Modal as Modal
import UI.Page as Page
import UI.PageLayout as PageLayout
import UI.Sidebar as Sidebar
import UI.Tooltip as Tooltip
import UnisonLocal.Route as Route exposing (Route)
Expand Down Expand Up @@ -129,8 +129,15 @@ type Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg ({ env } as model) =
case msg of
LinkClicked _ ->
( model, Cmd.none )
LinkClicked urlRequest ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl model.navKey (Url.toString url) )

-- External links are handled via target blank and never end up
-- here
Browser.External _ ->
( model, Cmd.none )

UrlChanged url ->
let
Expand Down Expand Up @@ -747,25 +754,25 @@ viewModal model =

viewAppLoading : Html msg
viewAppLoading =
Page.view
(Page.SidebarLayout
PageLayout.view
(PageLayout.SidebarLayout
{ header = AppHeader.appHeader (appTitle Nothing)
, sidebar = []
, sidebarToggled = False
, content = Page.PageContent []
, content = PageLayout.PageContent []
}
)


viewAppError : Http.Error -> Html msg
viewAppError error =
Page.view
(Page.SidebarLayout
PageLayout.view
(PageLayout.SidebarLayout
{ header = AppHeader.appHeader (appTitle Nothing)
, sidebar = []
, sidebarToggled = False
, content =
Page.PageContent
PageLayout.PageContent
[ div [ class "app-error" ]
[ Icon.view Icon.warn
, p [ title (Api.errorToString error) ]
Expand All @@ -792,13 +799,13 @@ view model =
Html.map WorkspaceMsg (Workspace.view model.workspace)

page =
Page.SidebarLayout
PageLayout.SidebarLayout
{ header = viewAppHeader model
, sidebar = viewMainSidebar model
, sidebarToggled = model.sidebarToggled
, content = Page.PageContent [ pageContent ]
, content = PageLayout.PageContent [ pageContent ]
}
in
{ title = "Unison Local"
, body = [ div [ id "app" ] [ Page.view page, viewModal model ] ]
, body = [ div [ id "app" ] [ PageLayout.view page, viewModal model ] ]
}
33 changes: 20 additions & 13 deletions src/UnisonShare/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UI.Banner as Banner
import UI.Button as Button
import UI.Click as Click exposing (Click(..))
import UI.Icon as Icon
import UI.Page as Page
import UI.PageLayout as PageLayout
import UI.Sidebar as Sidebar
import UI.Tooltip as Tooltip
import UnisonShare.AppModal as AppModal
Expand Down Expand Up @@ -126,8 +126,15 @@ type Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg ({ env } as model) =
case msg of
LinkClicked _ ->
( model, Cmd.none )
LinkClicked urlRequest ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl model.navKey (Url.toString url) )

-- External links are handled via target blank and never end up
-- here
Browser.External _ ->
( model, Cmd.none )

UrlChanged url ->
let
Expand Down Expand Up @@ -639,21 +646,21 @@ viewMainSidebar model =

viewAppLoading : Html msg
viewAppLoading =
Page.view
(Page.FullLayout
PageLayout.view
(PageLayout.FullLayout
{ header = AppHeader.appHeader (appTitle Nothing)
, content = Page.PageContent []
, content = PageLayout.PageContent []
}
)


viewAppError : Http.Error -> Html msg
viewAppError error =
Page.view
(Page.FullLayout
PageLayout.view
(PageLayout.FullLayout
{ header = AppHeader.appHeader (appTitle Nothing)
, content =
Page.PageContent
PageLayout.PageContent
[ div [ class "app-error" ]
[ Icon.view Icon.warn
, p [ title (Api.errorToString error) ]
Expand All @@ -671,11 +678,11 @@ view model =
viewAppHeader model

withSidebar pageContent =
Page.SidebarLayout
PageLayout.SidebarLayout
{ header = viewAppHeader model
, sidebar = viewMainSidebar model
, sidebarToggled = model.sidebarToggled
, content = Page.PageContent [ pageContent ]
, content = PageLayout.PageContent [ pageContent ]
}

page =
Expand All @@ -695,12 +702,12 @@ view model =
model.perspectiveLanding
)
|> withSidebar
|> Page.view
|> PageLayout.view

Route.Definition _ _ ->
Html.map WorkspaceMsg (Workspace.view model.workspace)
|> withSidebar
|> Page.view
|> PageLayout.view
in
{ title = "Unison Share"
, body =
Expand Down
Loading