Skip to content

Commit 0118f20

Browse files
committed
Add keyboard shortcut tooltip to search button
1 parent c74f34a commit 0118f20

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

src/UnisonShare/Page/CodePage.elm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ viewContent appContext perspective content =
732732
PageContent.oneColumn [ Html.map WorkspacePanesMsg (WorkspacePanes.view cfg workspace) ]
733733

734734

735-
viewSidebar : Model -> Sidebar Msg
736-
viewSidebar model =
735+
viewSidebar : AppContext -> Model -> Sidebar Msg
736+
viewSidebar appContext model =
737737
let
738738
codebaseTree =
739739
Just { codebaseTree = model.codebaseTree, codebaseTreeMsg = CodebaseTreeMsg }
@@ -749,6 +749,7 @@ viewSidebar model =
749749
FQNSet.empty
750750
in
751751
CodePageContent.viewSidebar
752+
appContext.operatingSystem
752753
model.config.perspective
753754
{ upOneLevelMsg = UpOneLevel
754755
, showFinderModalMsg = ShowFinderModal
@@ -783,7 +784,7 @@ view appContext toMsg model =
783784
PerspectivePage _ ->
784785
( PageLayout.sidebarLeftContentLayout
785786
appContext.operatingSystem
786-
(Sidebar.map toMsg (viewSidebar model))
787+
(Sidebar.map toMsg (viewSidebar appContext model))
787788
content
788789
PageFooter.pageFooter
789790
|> PageLayout.withSidebarToggle model.sidebarToggled
@@ -793,7 +794,7 @@ view appContext toMsg model =
793794
WorkspacePage _ ->
794795
( PageLayout.sidebarEdgeToEdgeLayout
795796
appContext.operatingSystem
796-
(Sidebar.map toMsg (viewSidebar model))
797+
(Sidebar.map toMsg (viewSidebar appContext model))
797798
content
798799
PageFooter.pageFooter
799800
|> PageLayout.withSidebarToggle model.sidebarToggled

src/UnisonShare/Page/CodePageContent.elm

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ import Html exposing (Html, div, h3, text)
1818
import Html.Attributes exposing (class, classList)
1919
import Http
2020
import Lib.HttpApi as HttpApi
21+
import Lib.OperatingSystem exposing (OperatingSystem(..))
2122
import RemoteData exposing (RemoteData(..), WebData)
2223
import UI
2324
import UI.Button as Button
2425
import UI.Card as Card
2526
import UI.Click as Click
2627
import UI.ErrorCard as ErrorCard
2728
import UI.Icon as Icon
29+
import UI.KeyboardShortcut as KeyboardShortcut
30+
import UI.KeyboardShortcut.Key as Key exposing (Key(..))
2831
import UI.Placeholder as Placeholder
2932
import UI.Sidebar as Sidebar exposing (Sidebar)
3033
import UI.Tooltip as Tooltip
@@ -182,7 +185,8 @@ viewPerspectiveHeader changePerspectiveToNamespaceMsg upOneLevelMsg perspective
182185

183186

184187
viewSidebar :
185-
Perspective
188+
OperatingSystem
189+
-> Perspective
186190
->
187191
{ upOneLevelMsg : msg
188192
, showFinderModalMsg : msg
@@ -191,14 +195,33 @@ viewSidebar :
191195
-> FQNSet
192196
-> Maybe { codebaseTree : CodebaseTree.Model, codebaseTreeMsg : CodebaseTree.Msg -> msg }
193197
-> Sidebar msg
194-
viewSidebar perspective cfg openDefinitions codebaseTree =
198+
viewSidebar os perspective cfg openDefinitions codebaseTree =
195199
let
196200
perspectiveHeader =
197201
viewPerspectiveHeader
198202
cfg.changePerspectiveToNamespaceMsg
199203
cfg.upOneLevelMsg
200204
perspective
201205

206+
searchShortcuts =
207+
case os of
208+
MacOS ->
209+
[ KeyboardShortcut.Chord Meta (K Key.Lower)
210+
, KeyboardShortcut.single ForwardSlash
211+
]
212+
213+
_ ->
214+
[ KeyboardShortcut.Chord Ctrl (K Key.Lower)
215+
, KeyboardShortcut.single ForwardSlash
216+
]
217+
218+
searchButtonTooltip =
219+
div [ class "sidebar-search_tooltip" ]
220+
[ KeyboardShortcut.viewShortcuts
221+
(KeyboardShortcut.init os)
222+
searchShortcuts
223+
]
224+
202225
codeSection =
203226
Maybe.map
204227
(\c ->
@@ -211,6 +234,11 @@ viewSidebar perspective cfg openDefinitions codebaseTree =
211234
)
212235
]
213236
|> Sidebar.sectionWithTitleButton (Button.iconThenLabel cfg.showFinderModalMsg Icon.browse "Search" |> Button.small)
237+
|> Sidebar.sectionWithTitleButtonTooltip
238+
(Tooltip.tooltip (Tooltip.rich searchButtonTooltip)
239+
|> Tooltip.withPosition Tooltip.Below
240+
|> Tooltip.withArrow Tooltip.End
241+
)
214242
|> Sidebar.sectionWithScrollable
215243
|> Sidebar.sectionWithStickyHeader
216244
)

src/css/unison-share/page/code-page.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@
9595
height: initial;
9696
}
9797

98+
.code-page .sidebar .sidebar-section_header .tooltip.below .tooltip-bubble {
99+
min-width: auto;
100+
width: max-content;
101+
top: 2.25rem;
102+
right: -4.5rem;
103+
}
104+
98105
.code-page .perspective-tree-divider {
99106
display: flex;
100107
flex-grow: 1;

0 commit comments

Comments
 (0)