@@ -5,15 +5,15 @@ import Definition.AbilityConstructor exposing (AbilityConstructor(..), AbilityCo
5
5
import Definition.Category as Category exposing (Category )
6
6
import Definition.DataConstructor exposing (DataConstructor (..) , DataConstructorDetail , DataConstructorSource (..) )
7
7
import Definition.Doc as Doc exposing (Doc (..) , DocFoldToggles )
8
- import Definition.Info as Info
8
+ import Definition.Info as Info exposing ( Info )
9
9
import Definition.Reference as Reference exposing (Reference (..) )
10
10
import Definition.Source as Source
11
11
import Definition.Term as Term exposing (Term (..) , TermCategory , TermDetail , TermSignature (..) , TermSource (..) )
12
12
import Definition.Type as Type exposing (Type (..) , TypeCategory , TypeDetail , TypeSource (..) )
13
13
import FullyQualifiedName as FQN exposing (FQN )
14
- import Hash
14
+ import Hash exposing ( Hash )
15
15
import 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 )
17
17
import Html.Attributes exposing (class , classList , id , title )
18
18
import Html.Events exposing (onClick )
19
19
import Http
@@ -22,7 +22,7 @@ import List.Nonempty as NEL
22
22
import Maybe.Extra as MaybeE
23
23
import String.Extra exposing (pluralize )
24
24
import UI
25
- import UI.Icon as Icon
25
+ import UI.Icon as Icon exposing ( Icon )
26
26
import UI.Tooltip as Tooltip
27
27
import Util
28
28
import Workspace.Zoom exposing (Zoom (..) )
@@ -136,22 +136,18 @@ viewBuiltin item =
136
136
UI . nothing
137
137
138
138
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 =
147
146
let
148
147
namespace =
149
148
case info. namespace of
150
149
Just ns ->
151
- div [ class " namespace" ]
152
- [ span [ class " separator in" ] [ text " in" ]
153
- , text ns
154
- ]
150
+ viewMenuItem Icon . folderOutlined ( FQN . toString ns)
155
151
156
152
Nothing ->
157
153
UI . nothing
@@ -166,21 +162,35 @@ viewNames onClick_ info category =
166
162
div [] ( List . map ( \ n -> div [] [ text ( FQN . toString n) ] ) info. otherNames)
167
163
168
164
otherNamesLabel =
169
- text ( pluralize " other name..." " other names..." numOtherNames)
165
+ pluralize " other name..." " other names..." numOtherNames
170
166
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
175
170
176
171
else
177
172
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
178
181
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
184
194
]
185
195
186
196
@@ -267,44 +277,44 @@ viewItem closeMsg toOpenReferenceMsg toUpdateZoomMsg toggleFoldMsg ref data isFo
267
277
|> Maybe . withDefault UI . nothing
268
278
in
269
279
case data. item of
270
- TermItem ( Term _ category detail) ->
280
+ TermItem ( Term h category detail) ->
271
281
viewClosableRow
272
282
closeMsg
273
283
ref
274
284
attrs
275
- ( viewNames docZoomMsg detail. info ( Category . Term category))
285
+ ( viewInfo docZoomMsg h detail. info ( Category . Term category))
276
286
[ ( UI . nothing, viewDoc_ detail. doc )
277
287
, ( UI . nothing, viewBuiltin data. item )
278
288
, viewSource toOpenReferenceMsg data. item
279
289
]
280
290
281
- TypeItem ( Type _ category detail) ->
291
+ TypeItem ( Type h category detail) ->
282
292
viewClosableRow
283
293
closeMsg
284
294
ref
285
295
attrs
286
- ( viewNames docZoomMsg detail. info ( Category . Type category))
296
+ ( viewInfo docZoomMsg h detail. info ( Category . Type category))
287
297
[ ( UI . nothing, viewDoc_ detail. doc )
288
298
, ( UI . nothing, viewBuiltin data. item )
289
299
, viewSource toOpenReferenceMsg data. item
290
300
]
291
301
292
- DataConstructorItem ( DataConstructor _ detail) ->
302
+ DataConstructorItem ( DataConstructor h detail) ->
293
303
viewClosableRow
294
304
closeMsg
295
305
ref
296
306
attrs
297
- ( viewNames docZoomMsg detail. info ( Category . Type Type . DataType ))
307
+ ( viewInfo docZoomMsg h detail. info ( Category . Type Type . DataType ))
298
308
[ ( UI . nothing, viewBuiltin data. item )
299
309
, viewSource toOpenReferenceMsg data. item
300
310
]
301
311
302
- AbilityConstructorItem ( AbilityConstructor _ detail) ->
312
+ AbilityConstructorItem ( AbilityConstructor h detail) ->
303
313
viewClosableRow
304
314
closeMsg
305
315
ref
306
316
attrs
307
- ( viewNames docZoomMsg detail. info ( Category . Type Type . AbilityType ))
317
+ ( viewInfo docZoomMsg h detail. info ( Category . Type Type . AbilityType ))
308
318
[ ( UI . nothing, viewBuiltin data. item )
309
319
, viewSource toOpenReferenceMsg data. item
310
320
]
0 commit comments