@@ -40,17 +40,23 @@ type WorkspaceItem
4040 }
4141
4242
43+ type alias WithDoc =
44+ { doc : Maybe Doc }
45+
46+
4347type alias TermDetailWithDoc =
44- TermDetail { doc : Maybe Doc }
48+ TermDetail WithDoc
4549
4650
4751type alias TypeDetailWithDoc =
48- TypeDetail { doc : Maybe Doc }
52+ TypeDetail WithDoc
4953
5054
5155type Item
5256 = TermItem TermDetailWithDoc
5357 | TypeItem TypeDetailWithDoc
58+ -- TODO: DataConstructorItem and AbilityConstructorItem are currently not
59+ -- rendered separate from TypeItem
5460 | DataConstructorItem DataConstructorDetail
5561 | AbilityConstructorItem AbilityConstructorDetail
5662
@@ -66,6 +72,27 @@ type Msg
6672 | FindWithinNamespace FQN
6773
6874
75+ fromItem : Reference -> Item -> WorkspaceItem
76+ fromItem ref item =
77+ let
78+ zoom =
79+ -- Doc items always have docs
80+ if isDocItem item then
81+ Medium
82+
83+ else if hasDoc item then
84+ Medium
85+
86+ else
87+ Near
88+ in
89+ Success ref
90+ { item = item
91+ , zoom = zoom
92+ , docFoldToggles = Doc . emptyDocFoldToggles
93+ }
94+
95+
6996reference : WorkspaceItem -> Reference
7097reference item =
7198 case item of
@@ -99,6 +126,23 @@ isDocItem item =
99126 False
100127
101128
129+ hasDoc : Item -> Bool
130+ hasDoc item =
131+ let
132+ hasDoc_ details =
133+ MaybeE . isJust details. doc
134+ in
135+ case item of
136+ TermItem ( Term _ _ d) ->
137+ hasDoc_ d
138+
139+ TypeItem ( Type _ _ d) ->
140+ hasDoc_ d
141+
142+ _ ->
143+ False
144+
145+
102146
103147-- VIEW
104148
@@ -289,7 +333,6 @@ viewItem :
289333 -> Html Msg
290334viewItem ref data isFocused =
291335 let
292- -- TODO: Support zoom level on the source
293336 ( zoomClass, infoZoomToggle, sourceZoomToggle ) =
294337 case data. zoom of
295338 Far ->
@@ -304,52 +347,51 @@ viewItem ref data isFocused =
304347 attrs =
305348 [ class zoomClass, classList [ ( " focused" , isFocused ) ] ]
306349
350+ sourceConfig =
351+ Source . Rich ( OpenReference ref)
352+
307353 viewDoc_ doc =
308354 doc
309355 |> Maybe . map ( viewDoc ref data. docFoldToggles)
310356 |> Maybe . withDefault UI . nothing
311357
312- sourceConfig =
313- Source . Rich ( OpenReference ref)
358+ viewContent doc =
359+ [ viewSource data. zoom sourceZoomToggle sourceConfig data. item
360+ , ( UI . nothing, viewBuiltin data. item )
361+ , ( UI . nothing, viewDoc_ doc )
362+ ]
363+
364+ viewInfo_ hash_ info cat =
365+ viewInfo data. zoom infoZoomToggle hash_ info cat
314366 in
315367 case data. item of
316368 TermItem ( Term h category detail) ->
317369 viewClosableRow
318370 ref
319371 attrs
320- ( viewInfo data. zoom infoZoomToggle h detail. info ( Category . Term category))
321- [ ( UI . nothing, viewDoc_ detail. doc )
322- , ( UI . nothing, viewBuiltin data. item )
323- , viewSource data. zoom sourceZoomToggle sourceConfig data. item
324- ]
372+ ( viewInfo_ h detail. info ( Category . Term category))
373+ ( viewContent detail. doc)
325374
326375 TypeItem ( Type h category detail) ->
327376 viewClosableRow
328377 ref
329378 attrs
330- ( viewInfo data. zoom infoZoomToggle h detail. info ( Category . Type category))
331- [ ( UI . nothing, viewDoc_ detail. doc )
332- , ( UI . nothing, viewBuiltin data. item )
333- , viewSource data. zoom sourceZoomToggle sourceConfig data. item
334- ]
379+ ( viewInfo_ h detail. info ( Category . Type category))
380+ ( viewContent detail. doc)
335381
336382 DataConstructorItem ( DataConstructor h detail) ->
337383 viewClosableRow
338384 ref
339385 attrs
340- ( viewInfo data. zoom infoZoomToggle h detail. info ( Category . Type Type . DataType ))
341- [ ( UI . nothing, viewBuiltin data. item )
342- , viewSource data. zoom sourceZoomToggle sourceConfig data. item
343- ]
386+ ( viewInfo_ h detail. info ( Category . Type Type . DataType ))
387+ ( viewContent Nothing )
344388
345389 AbilityConstructorItem ( AbilityConstructor h detail) ->
346390 viewClosableRow
347391 ref
348392 attrs
349- ( viewInfo data. zoom infoZoomToggle h detail. info ( Category . Type Type . AbilityType ))
350- [ ( UI . nothing, viewBuiltin data. item )
351- , viewSource data. zoom sourceZoomToggle sourceConfig data. item
352- ]
393+ ( viewInfo_ h detail. info ( Category . Type Type . AbilityType ))
394+ ( viewContent Nothing )
353395
354396
355397view : WorkspaceItem -> Bool -> Html Msg
0 commit comments