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

Commit 55d38b3

Browse files
authored
Merge pull request #203 from unisonweb/flyout-menu
Improve tooltips and show fly out menu
2 parents 08d1616 + 4faa0dc commit 55d38b3

16 files changed

+560
-360
lines changed

src/App.elm

+26-16
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,7 @@ update msg ({ env } as model) =
120120
( { model | route = Route.fromUrl env.basePath url }, Cmd.none )
121121

122122
ChangePerspective perspective ->
123-
let
124-
newEnv =
125-
{ env | perspective = perspective }
126-
127-
( codebaseTree, codebaseTreeCmd ) =
128-
CodebaseTree.init newEnv
129-
130-
changeRouteCmd =
131-
Route.replacePerspective model.navKey (Perspective.toParams perspective) model.route
132-
in
133-
( { model | env = newEnv, codebaseTree = codebaseTree }
134-
, Cmd.batch [ Cmd.map CodebaseTreeMsg codebaseTreeCmd, changeRouteCmd ]
135-
)
123+
replacePerspective model perspective
136124

137125
Keydown event ->
138126
keydown model event
@@ -228,6 +216,23 @@ openDefinition model ref =
228216
( model3, Cmd.batch [ cmd, Cmd.map WorkspaceMsg wCmd ] )
229217

230218

219+
replacePerspective : Model -> Perspective -> ( Model, Cmd Msg )
220+
replacePerspective ({ env } as model) perspective =
221+
let
222+
newEnv =
223+
{ env | perspective = perspective }
224+
225+
( codebaseTree, codebaseTreeCmd ) =
226+
CodebaseTree.init newEnv
227+
228+
changeRouteCmd =
229+
Route.replacePerspective model.navKey (Perspective.toParams perspective) model.route
230+
in
231+
( { model | env = newEnv, codebaseTree = codebaseTree }
232+
, Cmd.batch [ Cmd.map CodebaseTreeMsg codebaseTreeCmd, changeRouteCmd ]
233+
)
234+
235+
231236
handleWorkspaceOutMsg : Model -> Workspace.OutMsg -> ( Model, Cmd Msg )
232237
handleWorkspaceOutMsg model out =
233238
case out of
@@ -243,6 +248,11 @@ handleWorkspaceOutMsg model out =
243248
Workspace.Emptied ->
244249
( model, Route.navigateToCurrentPerspective model.navKey model.route )
245250

251+
Workspace.ChangePerspectiveToNamespace fqn ->
252+
fqn
253+
|> Perspective.toNamespacePerspective model.env.perspective
254+
|> replacePerspective model
255+
246256

247257
keydown : Model -> KeyboardEvent -> ( Model, Cmd Msg )
248258
keydown model keyboardEvent =
@@ -370,9 +380,9 @@ viewPerspective env =
370380

371381
back =
372382
Tooltip.tooltip
373-
(Button.buttonIcon (ChangePerspective (Codebase codebaseHash)) Icon.arrowLeftUp |> Button.small |> Button.view)
374-
(text ("You're currently viewing a subset of " ++ context ++ " (" ++ fqnText ++ "), click to view everything."))
375-
|> Tooltip.withArrow Tooltip.TopRight
383+
(Button.icon (ChangePerspective (Codebase codebaseHash)) Icon.arrowLeftUp |> Button.small |> Button.view)
384+
(Tooltip.Text ("You're currently viewing a subset of " ++ context ++ " (" ++ fqnText ++ "), click to view everything."))
385+
|> Tooltip.withArrow Tooltip.End
376386
|> Tooltip.view
377387
in
378388
header

src/Definition/Doc.elm

+12-3
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,11 @@ view refToMsg toggleFoldMsg docFoldToggles document =
375375
hr [] []
376376

377377
Tooltip triggerContent tooltipContent ->
378-
Tooltip.tooltip (viewAtCurrentSectionLevel triggerContent) (viewAtCurrentSectionLevel tooltipContent) |> Tooltip.withArrow Tooltip.TopLeft |> Tooltip.view
378+
Tooltip.tooltip
379+
(viewAtCurrentSectionLevel triggerContent)
380+
(Tooltip.Rich (viewAtCurrentSectionLevel tooltipContent))
381+
|> Tooltip.withArrow Tooltip.Start
382+
|> Tooltip.view
379383

380384
Aside d ->
381385
aside [] [ viewAtCurrentSectionLevel d ]
@@ -435,7 +439,12 @@ view refToMsg toggleFoldMsg docFoldToggles document =
435439
)
436440

437441
Span docs ->
438-
span [] (List.map viewAtCurrentSectionLevel (mergeWords docs))
442+
case docs of
443+
[ d ] ->
444+
viewAtCurrentSectionLevel d
445+
446+
ds ->
447+
span [ class "span" ] (List.map viewAtCurrentSectionLevel (mergeWords ds))
439448

440449
BulletedList items ->
441450
let
@@ -585,7 +594,7 @@ view refToMsg toggleFoldMsg docFoldToggles document =
585594
span [ class "source rich embed-inline" ] [ UI.inlineCode [] (viewSyntax syntax) ]
586595

587596
Join docs ->
588-
span [] (List.map viewAtCurrentSectionLevel (mergeWords docs))
597+
span [ class "join" ] (List.map viewAtCurrentSectionLevel (mergeWords docs))
589598

590599
UntitledSection docs ->
591600
section [] (List.map (viewSectionContent viewAtCurrentSectionLevel) docs)

src/Perspective.elm

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ type Perspective
1010
| Namespace { codebaseHash : Hash, fqn : FQN }
1111

1212

13+
toNamespacePerspective : Perspective -> FQN -> Perspective
14+
toNamespacePerspective perspective fqn_ =
15+
Namespace { codebaseHash = codebaseHash perspective, fqn = fqn_ }
16+
17+
1318
codebaseHash : Perspective -> Hash
1419
codebaseHash perspective =
1520
case perspective of

src/Route.elm

+6-2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ toUrlString route =
160160
HashQualified fqn h ->
161161
NEL.toList (FQN.toUrlSegments fqn) ++ [ Hash.toUrlString h ]
162162

163+
namespaceSuffix =
164+
";"
165+
166+
-- used to mark the end of a namespace FQN
163167
perspectiveParamsToPath pp includeNamespacesSuffix =
164168
case pp of
165169
ByCodebase Relative ->
@@ -170,14 +174,14 @@ toUrlString route =
170174

171175
ByNamespace Relative fqn ->
172176
if includeNamespacesSuffix then
173-
"latest" :: "-" :: NEL.toList (FQN.segments fqn)
177+
"latest" :: NEL.toList (FQN.segments fqn) ++ [ namespaceSuffix ]
174178

175179
else
176180
"latest" :: NEL.toList (FQN.segments fqn)
177181

178182
ByNamespace (Absolute hash) fqn ->
179183
if includeNamespacesSuffix then
180-
[ Hash.toUrlString hash, "namespaces" ] ++ NEL.toList (FQN.segments fqn) ++ [ "-" ]
184+
[ Hash.toUrlString hash, "namespaces" ] ++ NEL.toList (FQN.segments fqn) ++ [ namespaceSuffix ]
181185

182186
else
183187
[ Hash.toUrlString hash, "namespaces" ] ++ NEL.toList (FQN.segments fqn)

src/UI/Button.elm

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module UI.Button exposing
33
, Size(..)
44
, Type(..)
55
, button
6-
, buttonIcon
7-
, buttonIconThenLabel
86
, danger
97
, default
8+
, icon
9+
, iconThenLabel
1010
, large
1111
, link
1212
, linkIcon
@@ -59,17 +59,17 @@ button clickMsg label =
5959
}
6060

6161

62-
buttonIcon : msg -> I.Icon msg -> Button msg
63-
buttonIcon msg icon_ =
62+
icon : msg -> I.Icon msg -> Button msg
63+
icon msg icon_ =
6464
{ action = OnClick msg
6565
, content = Icon icon_
6666
, type_ = Default
6767
, size = Medium
6868
}
6969

7070

71-
buttonIconThenLabel : msg -> I.Icon msg -> String -> Button msg
72-
buttonIconThenLabel msg icon_ label =
71+
iconThenLabel : msg -> I.Icon msg -> String -> Button msg
72+
iconThenLabel msg icon_ label =
7373
{ action = OnClick msg
7474
, content = IconThenLabel icon_ label
7575
, type_ = Default

src/UI/Icon.elm

+29
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ folderOutlined =
247247
[ path [ fill "currentColor", fillRule "evenodd", d "M2 2C1.44772 2 1 2.44772 1 3V11.5C1 12.0523 1.44772 12.5 2 12.5H12C12.5523 12.5 13 12.0523 13 11.5V4.5C13 3.94772 12.5523 3.5 12 3.5H7.83333C7.61696 3.5 7.40643 3.42982 7.23333 3.3L5.76667 2.2C5.59357 2.07018 5.38304 2 5.16667 2H4.5H2ZM2.5 4.5C2.22386 4.5 2 4.72386 2 5V11C2 11.2761 2.22386 11.5 2.5 11.5H11.5C11.7761 11.5 12 11.2761 12 11V5C12 4.72386 11.7761 4.5 11.5 4.5H2.5Z" ] [] ]
248248

249249

250+
intoFolder : Icon msg
251+
intoFolder =
252+
Icon
253+
"into-folder"
254+
[]
255+
[ path [ fill "currentColor", d "M0.46875 7.35795C0.209867 7.35795 0 7.56782 0 7.8267V7.8267C0 8.08559 0.209867 8.29545 0.46875 8.29545H5.40213C5.62485 8.29545 5.7364 8.56474 5.5789 8.72223L4.63211 9.66903C4.45124 9.8499 4.45219 10.1435 4.63425 10.3231V10.3231C4.81462 10.5012 5.10489 10.5002 5.2841 10.321L7.42539 8.17972C7.62044 7.98467 7.62068 7.6685 7.42592 7.47315L5.29195 5.33273C5.10918 5.1494 4.81202 5.15013 4.63015 5.33436V5.33436C4.4498 5.51705 4.45112 5.81118 4.6331 5.99224L5.57631 6.93073C5.73441 7.08804 5.62301 7.35795 5.39998 7.35795H0.46875Z" ] []
256+
, path [ fill "currentColor", d "M2.5 12H12.5C12.7761 12 13 11.7761 13 11.5V4C13 3.72386 12.7761 3.5 12.5 3.5H7.83333C7.40059 3.5 6.97953 3.35964 6.63333 3.1L5.43333 2.2C5.26024 2.07018 5.0497 2 4.83333 2H2.5C2.22386 2 2 2.22386 2 2.5L2 5C2 5.27614 1.77614 5.5 1.5 5.5C1.22386 5.5 1 5.27614 1 5V2C1 1.44772 1.44772 1 2 1H5.16667C5.38304 1 5.59357 1.07018 5.76667 1.2L7.23333 2.3C7.40643 2.42982 7.61696 2.5 7.83333 2.5H13C13.5523 2.5 14 2.94772 14 3.5V12C14 12.5523 13.5523 13 13 13H2C1.44772 13 1 12.5523 1 12V10.5C1 10.2239 1.22386 10 1.5 10C1.77614 10 2 10.2239 2 10.5L2 11.5C2 11.7761 2.22386 12 2.5 12Z" ] []
257+
]
258+
259+
250260
hash : Icon msg
251261
hash =
252262
Icon
@@ -278,6 +288,16 @@ dot =
278288
Icon "dot" [] [ circle [ fill "currentColor", cx "7", cy "7", r "2" ] [] ]
279289

280290

291+
dots : Icon msg
292+
dots =
293+
Icon "dots"
294+
[]
295+
[ circle [ fill "currentColor", cx "11", cy "7", r "1" ] []
296+
, circle [ fill "currentColor", cx "7", cy "7", r "1" ] []
297+
, circle [ fill "currentColor", cx "3", cy "7", r "1" ] []
298+
]
299+
300+
281301
dash : Icon msg
282302
dash =
283303
Icon "dash" [] [ rect [ fill "currentColor", Attrs.x "3", y "5", width "8", height "4", rx "2" ] [] ]
@@ -288,6 +308,15 @@ github =
288308
Icon "github" [] [ path [ fill "currentColor", fillRule "evenodd", d "M6.99945 1C3.68664 1 1 3.68627 1 7.00019C1 9.6511 2.71902 11.8998 5.10326 12.6932C5.40345 12.7484 5.51285 12.5632 5.51285 12.404C5.51285 12.2619 5.50769 11.8843 5.50474 11.3837C3.83581 11.7462 3.48368 10.5793 3.48368 10.5793C3.21075 9.88609 2.81736 9.70156 2.81736 9.70156C2.2726 9.32954 2.85862 9.3369 2.85862 9.3369C3.46085 9.37926 3.77761 9.95534 3.77761 9.95534C4.3128 10.8721 5.18208 10.6073 5.5239 10.4537C5.57841 10.0662 5.73348 9.80174 5.90475 9.65183C4.57248 9.50045 3.1717 8.98551 3.1717 6.68636C3.1717 6.03146 3.4056 5.49553 3.7894 5.07637C3.72752 4.92462 3.52162 4.31428 3.84833 3.48847C3.84833 3.48847 4.35185 3.32714 5.49811 4.10359C5.97658 3.97026 6.49004 3.90396 7.00018 3.90138C7.50996 3.90396 8.02305 3.97026 8.50226 4.10359C9.64778 3.32714 10.1506 3.48847 10.1506 3.48847C10.478 4.31428 10.2721 4.92462 10.2106 5.07637C10.5951 5.49553 10.8272 6.03146 10.8272 6.68636C10.8272 8.99141 9.4242 9.4986 8.08788 9.64704C8.30299 9.83232 8.49489 10.1984 8.49489 10.7583C8.49489 11.5602 8.48752 12.2073 8.48752 12.404C8.48752 12.5646 8.59581 12.7514 8.90006 12.6928C11.2825 11.8976 13 9.65036 13 7.00019C13 3.68627 10.3134 1 6.99945 1Z" ] [] ]
289309

290310

311+
download : Icon msg
312+
download =
313+
Icon "download"
314+
[]
315+
[ path [ fill "currentColor", d "M7.47142 1.74148C7.47142 1.48259 7.26155 1.27273 7.00267 1.27273C6.74378 1.27273 6.53392 1.48259 6.53392 1.74148L6.53392 7.67486C6.53392 7.89758 6.26463 8.00912 6.10714 7.85163L4.16035 5.90484C3.97947 5.72396 3.68592 5.72492 3.50623 5.90697C3.3282 6.08735 3.32915 6.37762 3.50836 6.55683L6.64951 9.69798C6.84462 9.89309 7.1609 9.89326 7.35622 9.69837L10.4967 6.5649C10.68 6.38198 10.6792 6.08473 10.4949 5.90279C10.3122 5.72244 10.0181 5.72362 9.83691 5.90543L7.89847 7.85C7.7411 8.00788 7.47142 7.89642 7.47142 7.67351L7.47142 1.74148Z" ] []
316+
, rect [ fill "currentColor", Attrs.x "3", y "11", width "8", height "1", rx "0.5" ] []
317+
]
318+
319+
291320
list : Icon msg
292321
list =
293322
Icon "list"

0 commit comments

Comments
 (0)