@@ -5,15 +5,15 @@ import Definition.AbilityConstructor exposing (AbilityConstructor(..), AbilityCo
55import Definition.Category as Category exposing (Category )
66import Definition.DataConstructor exposing (DataConstructor (..) , DataConstructorDetail , DataConstructorSource (..) )
77import Definition.Doc as Doc exposing (Doc (..) , DocFoldToggles )
8- import Definition.Info as Info
8+ import Definition.Info as Info exposing ( Info )
99import Definition.Reference as Reference exposing (Reference (..) )
1010import Definition.Source as Source
1111import Definition.Term as Term exposing (Term (..) , TermCategory , TermDetail , TermSignature (..) , TermSource (..) )
1212import Definition.Type as Type exposing (Type (..) , TypeCategory , TypeDetail , TypeSource (..) )
1313import FullyQualifiedName as FQN exposing (FQN )
14- import Hash
14+ import Hash exposing ( Hash )
1515import HashQualified as HQ exposing (HashQualified (..) )
16- import Html exposing (Attribute , Html , a , div , h3 , header , section , span , strong , text )
16+ import Html exposing (Attribute , Html , a , div , h3 , header , label , section , span , strong , text )
1717import Html.Attributes exposing (class , classList , id , title )
1818import Html.Events exposing (onClick )
1919import Http
@@ -22,7 +22,7 @@ import List.Nonempty as NEL
2222import Maybe.Extra as MaybeE
2323import String.Extra exposing (pluralize )
2424import UI
25- import UI.Icon as Icon
25+ import UI.Icon as Icon exposing ( Icon )
2626import UI.Tooltip as Tooltip
2727import Util
2828import Workspace.Zoom exposing (Zoom (..) )
@@ -136,22 +136,18 @@ viewBuiltin item =
136136 UI . nothing
137137
138138
139- {- | TODO: Some of this that isn't Workspace specific might be moved into Definition.Info
140- -}
141- viewNames :
142- msg
143- -> { a | name : String , namespace : Maybe String , otherNames : List FQN }
144- -> Category
145- -> Html msg
146- viewNames onClick_ info category =
139+ viewMenuItem : Icon msg -> String -> Html msg
140+ viewMenuItem icon label_ =
141+ div [ class " menu-item" ] [ Icon . view icon, label [] [ text label_ ] ]
142+
143+
144+ viewMenuItems : Hash -> Info -> Html msg
145+ viewMenuItems hash_ info =
147146 let
148147 namespace =
149148 case info. namespace of
150149 Just ns ->
151- div [ class " namespace" ]
152- [ span [ class " separator in" ] [ text " in" ]
153- , text ns
154- ]
150+ viewMenuItem Icon . folderOutlined ( FQN . toString ns)
155151
156152 Nothing ->
157153 UI . nothing
@@ -166,21 +162,35 @@ viewNames onClick_ info category =
166162 div [] ( List . map ( \ n -> div [] [ text ( FQN . toString n) ] ) info. otherNames)
167163
168164 otherNamesLabel =
169- text ( pluralize " other name..." " other names..." numOtherNames)
165+ pluralize " other name..." " other names..." numOtherNames
170166 in
171- div []
172- [ span [ class " separator" ] [ text " •" ]
173- , span [ class " other-names" ] [ Tooltip . tooltip otherNamesLabel otherNamesTooltipContent |> Tooltip . withArrow Tooltip . TopLeft |> Tooltip . view ]
174- ]
167+ Tooltip . tooltip ( viewMenuItem Icon . tagsOutlined otherNamesLabel) otherNamesTooltipContent
168+ |> Tooltip . withArrow Tooltip . TopLeft
169+ |> Tooltip . view
175170
176171 else
177172 UI . nothing
173+
174+ formatHash h =
175+ h |> Hash . toString |> String . dropLeft 1 |> String . left 8
176+
177+ hash =
178+ Tooltip . tooltip ( viewMenuItem Icon . hash ( formatHash hash_)) ( text ( Hash . toString hash_))
179+ |> Tooltip . withArrow Tooltip . TopLeft
180+ |> Tooltip . view
178181 in
179- div [ class " names" , onClick onClick_ ]
180- [ Icon . view Icon . caretRight
181- , Icon . view ( Category . icon category)
182- , h3 [ class " name" ] [ text info. name ]
183- , div [ class " info" ] [ namespace, otherNames ]
182+ div [ class " menu-items" ] [ hash, namespace, otherNames ]
183+
184+
185+ viewInfo : msg -> Hash -> Info -> Category -> Html msg
186+ viewInfo onClick_ hash info category =
187+ div [ class " info" ]
188+ [ a [ class " toggle-zoom" , onClick onClick_ ]
189+ [ Icon . view Icon . caretRight
190+ , Icon . view ( Category . icon category)
191+ , h3 [ class " name" ] [ text info. name ]
192+ ]
193+ , viewMenuItems hash info
184194 ]
185195
186196
@@ -267,44 +277,44 @@ viewItem closeMsg toOpenReferenceMsg toUpdateZoomMsg toggleFoldMsg ref data isFo
267277 |> Maybe . withDefault UI . nothing
268278 in
269279 case data. item of
270- TermItem ( Term _ category detail) ->
280+ TermItem ( Term h category detail) ->
271281 viewClosableRow
272282 closeMsg
273283 ref
274284 attrs
275- ( viewNames docZoomMsg detail. info ( Category . Term category))
285+ ( viewInfo docZoomMsg h detail. info ( Category . Term category))
276286 [ ( UI . nothing, viewDoc_ detail. doc )
277287 , ( UI . nothing, viewBuiltin data. item )
278288 , viewSource toOpenReferenceMsg data. item
279289 ]
280290
281- TypeItem ( Type _ category detail) ->
291+ TypeItem ( Type h category detail) ->
282292 viewClosableRow
283293 closeMsg
284294 ref
285295 attrs
286- ( viewNames docZoomMsg detail. info ( Category . Type category))
296+ ( viewInfo docZoomMsg h detail. info ( Category . Type category))
287297 [ ( UI . nothing, viewDoc_ detail. doc )
288298 , ( UI . nothing, viewBuiltin data. item )
289299 , viewSource toOpenReferenceMsg data. item
290300 ]
291301
292- DataConstructorItem ( DataConstructor _ detail) ->
302+ DataConstructorItem ( DataConstructor h detail) ->
293303 viewClosableRow
294304 closeMsg
295305 ref
296306 attrs
297- ( viewNames docZoomMsg detail. info ( Category . Type Type . DataType ))
307+ ( viewInfo docZoomMsg h detail. info ( Category . Type Type . DataType ))
298308 [ ( UI . nothing, viewBuiltin data. item )
299309 , viewSource toOpenReferenceMsg data. item
300310 ]
301311
302- AbilityConstructorItem ( AbilityConstructor _ detail) ->
312+ AbilityConstructorItem ( AbilityConstructor h detail) ->
303313 viewClosableRow
304314 closeMsg
305315 ref
306316 attrs
307- ( viewNames docZoomMsg detail. info ( Category . Type Type . AbilityType ))
317+ ( viewInfo docZoomMsg h detail. info ( Category . Type Type . AbilityType ))
308318 [ ( UI . nothing, viewBuiltin data. item )
309319 , viewSource toOpenReferenceMsg data. item
310320 ]
0 commit comments