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

Commit ec15c9f

Browse files
committed
Show Hashvatar in the sidebar perspective
When any namespace is set as the perspective, show a hashvatar, defaulting to a blank one.
1 parent 2251b15 commit ec15c9f

File tree

8 files changed

+30
-184
lines changed

8 files changed

+30
-184
lines changed

src/Hashvatar.elm

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import String.Extra exposing (break)
99
import UI.Color as Color exposing (Color)
1010

1111

12+
empty : Html msg
13+
empty =
14+
view_ HexGrid.empty
15+
16+
1217
view : Hash -> Html msg
1318
view hash =
1419
let
@@ -35,9 +40,12 @@ view hash =
3540
|> toGrid
3641
|> Maybe.withDefault HexGrid.empty
3742
in
38-
div [ class "hashvatar" ]
39-
[ HexGrid.view grid
40-
]
43+
view_ grid
44+
45+
46+
view_ : HexGrid.HexGrid -> Html msg
47+
view_ grid =
48+
div [ class "hashvatar" ] [ HexGrid.view grid ]
4149

4250

4351

src/UI.elm

-5
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,3 @@ divider =
7171
charWidth : Int -> String
7272
charWidth numChars =
7373
String.fromInt numChars ++ "ch"
74-
75-
76-
namespaceSlug : Html msg
77-
namespaceSlug =
78-
div [ class "namespace-slug" ] []

src/UnisonLocal/App.elm

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Env exposing (Env, OperatingSystem(..))
99
import Finder
1010
import Finder.SearchOptions as SearchOptions
1111
import FullyQualifiedName as FQN exposing (FQN)
12+
import Hashvatar
1213
import Html exposing (Html, a, div, h1, h2, h3, nav, p, section, span, strong, text)
1314
import Html.Attributes exposing (class, classList, href, id, rel, target, title)
1415
import Html.Events exposing (onClick)
@@ -493,19 +494,24 @@ viewSidebarHeader env =
493494
Codebase _ ->
494495
UI.nothing
495496

496-
Namespace { fqn } ->
497+
Namespace { fqn, details } ->
497498
let
498499
-- Imprecise, but close enough, approximation of overflowing,
499500
-- which results in a slight faded left edge A better way would
500501
-- be to measure the DOM like we do for overflowing docs, but
501502
-- thats quite involved...
502503
isOverflowing =
503504
fqn |> FQN.toString |> String.length |> (\l -> l > 20)
505+
506+
hashvatar =
507+
details
508+
|> RemoteData.map (Namespace.hash >> Hashvatar.view)
509+
|> RemoteData.withDefault Hashvatar.empty
504510
in
505511
Sidebar.header
506512
[ Sidebar.headerItem
507513
[ classList [ ( "is-overflowing", isOverflowing ) ] ]
508-
[ UI.namespaceSlug
514+
[ hashvatar
509515
, h2 [ class "namespace" ] [ FQN.view fqn ]
510516
]
511517
, UI.divider

src/UnisonShare/App.elm

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import CodebaseTree
77
import Definition.Reference exposing (Reference)
88
import Env exposing (Env)
99
import FullyQualifiedName as FQN exposing (FQN)
10+
import Hashvatar
1011
import Html exposing (Html, a, div, h1, h2, nav, p, span, text)
1112
import Html.Attributes exposing (class, classList, id, title)
1213
import Html.Events exposing (onClick)
@@ -512,7 +513,7 @@ viewSidebarHeader env =
512513
Codebase _ ->
513514
UI.nothing
514515

515-
Namespace { fqn } ->
516+
Namespace { fqn, details } ->
516517
let
517518
-- Imprecise, but close enough, approximation of overflowing,
518519
-- which results in a slight faded left edge A better way would
@@ -527,11 +528,16 @@ viewSidebarHeader env =
527528
|> Button.view
528529
|> List.singleton
529530
|> Sidebar.headerItem []
531+
532+
hashvatar =
533+
details
534+
|> RemoteData.map (Namespace.hash >> Hashvatar.view)
535+
|> RemoteData.withDefault Hashvatar.empty
530536
in
531537
Sidebar.header
532538
[ Sidebar.headerItem
533539
[ classList [ ( "is-overflowing", isOverflowing ) ] ]
534-
[ UI.namespaceSlug
540+
[ hashvatar
535541
, h2 [ class "namespace" ] [ FQN.view fqn ]
536542
]
537543
, download

src/UnisonShare/Page/Catalog.elm

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import UnisonShare.Route as Route
2424

2525

2626
type alias LoadedModel =
27+
-- TODO: perhaps use the SearchResults data structure?
2728
{ query : String
2829
, hasFocus : Bool
2930
, catalog : Catalog

src/css/elements.css

-9
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,6 @@ p {
171171
align-items: center;
172172
}
173173

174-
/* Namespace Slug */
175-
.namespace-slug {
176-
display: inline-flex;
177-
flex: 0 0 1.5rem;
178-
width: 1.5rem;
179-
height: 1.5rem;
180-
background: url(../img/namespace-slug-untitled.svg);
181-
}
182-
183174
@import "./elements/icon.css";
184175
@import "./elements/banner.css";
185176
@import "./elements/button.css";

src/css/ui/page-layout.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@
240240
);
241241
}
242242

243-
#main-sidebar .sidebar-header .namespace-slug {
243+
#main-sidebar .sidebar-header .hasvatar {
244244
position: relative;
245245
}
246246

247-
#main-sidebar .sidebar-header .is-overflowing .namespace-slug:after {
247+
#main-sidebar .sidebar-header .is-overflowing .hashvatar:after {
248248
position: absolute;
249249
top: 0;
250250
right: -1.5rem;

src/img/namespace-slug-untitled.svg

-161
This file was deleted.

0 commit comments

Comments
 (0)