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

Commit 3f0171d

Browse files
committed
Perspective Landing: always show "Find Definition"
Fix a bug where on the perspective landing page, when the namespace had a readme, there would be no button to open the finder.
1 parent 2cddd4b commit 3f0171d

8 files changed

+70
-38
lines changed

src/PerspectiveLanding.elm

+24-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import RemoteData exposing (RemoteData(..))
1515
import UI
1616
import UI.Button as Button exposing (Button)
1717
import UI.Icon as Icon
18+
import UI.Toolbar as Toolbar
1819

1920

2021
type alias Model =
@@ -114,7 +115,7 @@ viewEmptyStateCodebase : AppContext -> Html Msg
114115
viewEmptyStateCodebase appContext =
115116
let
116117
button =
117-
Button.iconThenLabel Find Icon.search "Find Definitions"
118+
Button.iconThenLabel Find Icon.search "Find Definition"
118119
|> Button.primaryMono
119120
|> Button.medium
120121
in
@@ -168,17 +169,28 @@ view env model =
168169
viewLoading
169170

170171
Success (Namespace _ _ { readme }) ->
171-
case readme of
172-
Just r ->
173-
container
174-
[ div [ class "perspective-landing-readme" ]
175-
[ header [] [ Icon.view Icon.doc, text "README" ]
176-
, Readme.view OpenReference ToggleDocFold model r
177-
]
178-
]
179-
180-
Nothing ->
181-
viewEmptyStateNamespace fqn
172+
let
173+
content =
174+
case readme of
175+
Just r ->
176+
container
177+
[ div [ class "perspective-landing-readme" ]
178+
[ header [ class "title" ] [ Icon.view Icon.doc, text "README" ]
179+
, Readme.view OpenReference ToggleDocFold model r
180+
]
181+
]
182+
183+
Nothing ->
184+
viewEmptyStateNamespace fqn
185+
in
186+
div []
187+
[ Button.iconThenLabel Find Icon.search "Find Definition"
188+
|> Button.small
189+
|> Button.view
190+
|> Toolbar.toolbar
191+
|> Toolbar.view
192+
, content
193+
]
182194

183195
Failure error ->
184196
viewError fqn (Api.errorToString error)

src/UI/Toolbar.elm

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module UI.Toolbar exposing (..)
2+
3+
import Html exposing (Html, header)
4+
import Html.Attributes exposing (class)
5+
6+
7+
type alias Toolbar msg =
8+
{ content : Html msg
9+
}
10+
11+
12+
toolbar : Html msg -> Toolbar msg
13+
toolbar =
14+
Toolbar
15+
16+
17+
view : Toolbar msg -> Html msg
18+
view { content } =
19+
header [ class "toolbar" ] [ content ]

src/Workspace.elm

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Env exposing (Env)
1818
import FullyQualifiedName exposing (FQN)
1919
import Hash
2020
import HashQualified as HQ
21-
import Html exposing (Html, article, div, header, section)
21+
import Html exposing (Html, article, div, section)
2222
import Html.Attributes exposing (class, id)
2323
import Http
2424
import KeyboardShortcut exposing (KeyboardShortcut(..))
@@ -28,6 +28,7 @@ import Perspective exposing (Perspective)
2828
import Task
2929
import UI.Button as Button
3030
import UI.Icon as Icon
31+
import UI.Toolbar as Toolbar
3132
import Workspace.WorkspaceItem as WorkspaceItem exposing (Item, WorkspaceItem)
3233
import Workspace.WorkspaceItems as WorkspaceItems exposing (WorkspaceItems)
3334

@@ -499,10 +500,11 @@ view model =
499500

500501
WorkspaceItems.WorkspaceItems _ ->
501502
article [ id "workspace" ]
502-
[ header
503-
[ id "workspace-toolbar" ]
504-
[ Button.iconThenLabel Find Icon.search "Find Definition" |> Button.small |> Button.view
505-
]
503+
[ Button.iconThenLabel Find Icon.search "Find Definition"
504+
|> Button.small
505+
|> Button.view
506+
|> Toolbar.toolbar
507+
|> Toolbar.view
506508
, section
507509
[ id "workspace-content" ]
508510
[ section [ class "definitions-pane" ] (viewWorkspaceItems model.workspaceItems) ]

src/css/elements.css

+1
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,4 @@ p {
179179
@import "./elements/fully-qualified-name.css";
180180
@import "./elements/card.css";
181181
@import "./elements/hashvatar.css";
182+
@import "./elements/toolbar.css";

src/css/elements/toolbar.css

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.toolbar {
2+
height: var(--toolbar-height);
3+
padding-left: 2.625rem;
4+
padding-right: 1rem;
5+
font-size: var(--font-size-medium);
6+
background: var(--color-main-bg);
7+
border-bottom: 1px solid var(--color-main-border);
8+
display: flex;
9+
flex-direction: row;
10+
align-items: center;
11+
}
12+
13+
.toolbar .right {
14+
margin-left: auto;
15+
}

src/css/main.css

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
--main-sidebar-collapsed-width: 4.5rem;
77
--main-content-width: 45.5rem;
88
--border-radius-base: 0.25rem;
9+
--toolbar-height: 3.5rem;
910

1011
/* -- Layers ------------------------------------------------------------- */
1112
--layer-beneath: 0;

src/css/perspective-landing.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@
146146
justify-content: flex-end;
147147
}
148148

149-
.perspective-landing-readme header {
149+
.perspective-landing-readme header.title {
150150
font-size: var(--font-size-medium);
151151
font-weight: bold;
152152
height: 1.5rem;
153153
line-height: 1;
154154
display: flex;
155155
flex-direction: row;
156+
align-items: center;
156157
}
157158

158159
.perspective-landing-readme header .icon {

src/css/workspace.css

+1-20
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,12 @@
66
background: var(--color-workspace-bg);
77
color: var(--color-workspace-fg);
88

9-
--workspace-toolbar-height: 3.5rem;
109
--workspace-content-width: var(--main-content-width);
1110
}
1211

13-
#workspace-toolbar {
14-
height: var(--workspace-toolbar-height);
15-
padding-left: 2.625rem;
16-
padding-right: 1rem;
17-
font-size: var(--font-size-medium);
18-
background: var(--color-workspace-item-bg);
19-
border-bottom: 1px solid var(--color-workspace-border);
20-
display: flex;
21-
flex-direction: row;
22-
align-items: center;
23-
}
24-
25-
#workspace-toolbar .right {
26-
margin-left: auto;
27-
}
28-
2912
#workspace-content {
3013
overflow: auto;
31-
height: calc(
32-
calc(100vh - var(--workspace-toolbar-height)) - var(--app-header-height)
33-
);
14+
height: calc(calc(100vh - var(--toolbar-height)) - var(--app-header-height));
3415
padding-top: 2rem;
3516
scroll-behavior: smooth;
3617
scrollbar-width: auto;

0 commit comments

Comments
 (0)