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

Commit 53c0489

Browse files
authored
Merge pull request #277 from unisonweb/fix-namespace-perspective-overflow
Perspective: Improve rendering of very long names
2 parents a1532a9 + 0a43ca5 commit 53c0489

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

src/App.elm

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -504,26 +504,19 @@ viewPerspective env =
504504
Codebase _ ->
505505
UI.nothing
506506

507-
Namespace { codebaseHash, fqn } ->
507+
Namespace { fqn } ->
508508
let
509-
fqnText =
510-
FQN.toString fqn
511-
512-
context =
513-
Env.appContextToString env.appContext
514-
515-
back =
516-
Tooltip.tooltip
517-
(Button.icon (ChangePerspective (Codebase codebaseHash)) Icon.arrowLeftUp |> Button.small |> Button.uncontained |> Button.view)
518-
(Tooltip.Text ("You're currently viewing a subset of " ++ context ++ " (" ++ fqnText ++ "), click to reveal everything."))
519-
|> Tooltip.withArrow Tooltip.Start
520-
|> Tooltip.view
509+
-- Imprecise, but close enough, approximation of overflowing,
510+
-- which results in a slight faded left edge A better way would
511+
-- be to measure the DOM like we do for overflowing docs, but
512+
-- thats quite involved...
513+
isOverflowing =
514+
fqn |> FQN.toString |> String.length |> (\l -> l > 20)
521515
in
522516
header
523-
[ class "perspective" ]
524-
[ div [ class "namespace-slug" ] []
525-
, h2 [] [ FQN.view fqn ]
526-
, back
517+
[ classList [ ( "perspective", True ), ( "is-overflowing", isOverflowing ) ] ]
518+
[ UI.namespaceSlug
519+
, h2 [ class "namespace" ] [ FQN.view fqn ]
527520
]
528521

529522

src/UI.elm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ divider =
6666
charWidth : Int -> String
6767
charWidth numChars =
6868
String.fromInt numChars ++ "ch"
69+
70+
71+
namespaceSlug : Html msg
72+
namespaceSlug =
73+
div [ class "namespace-slug" ] []

src/css/app.css

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
display: flex;
193193
flex-direction: row;
194194
position: relative;
195+
gap: 0.75rem;
195196
}
196197

197198
#main-sidebar .perspective:after {
@@ -209,14 +210,34 @@
209210
}
210211

211212
#main-sidebar .perspective .namespace-slug {
212-
margin-right: 0.75rem;
213+
position: relative;
213214
}
214215

215-
#main-sidebar .perspective h2 {
216+
#main-sidebar .perspective.is-overflowing .namespace-slug:after {
217+
position: absolute;
218+
top: 0;
219+
right: -1.5rem;
220+
bottom: 0;
221+
content: "";
222+
width: 1.5rem;
223+
background: linear-gradient(
224+
90deg,
225+
var(--color-sidebar-bg),
226+
var(--color-sidebar-bg),
227+
var(--color-sidebar-bg-transparent)
228+
);
229+
}
230+
231+
#main-sidebar .perspective .namespace {
232+
display: inline-flex;
216233
color: var(--color-sidebar-fg-em);
217234
font-size: 1rem;
218235
font-weight: 500;
219236
height: 1.5rem;
237+
overflow: hidden;
238+
white-space: nowrap;
239+
text-align: right;
240+
flex-direction: row-reverse;
220241
}
221242

222243
#main-sidebar .perspective .tooltip-bubble {

src/css/elements.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ hr {
174174
/* Namespace Slug */
175175
.namespace-slug {
176176
display: inline-flex;
177+
flex: 0 0 1.5rem;
177178
width: 1.5rem;
178179
height: 1.5rem;
179180
background: url(../img/namespace-slug-untitled.svg);

0 commit comments

Comments
 (0)