@@ -40,17 +40,23 @@ type WorkspaceItem
40
40
}
41
41
42
42
43
+ type alias WithDoc =
44
+ { doc : Maybe Doc }
45
+
46
+
43
47
type alias TermDetailWithDoc =
44
- TermDetail { doc : Maybe Doc }
48
+ TermDetail WithDoc
45
49
46
50
47
51
type alias TypeDetailWithDoc =
48
- TypeDetail { doc : Maybe Doc }
52
+ TypeDetail WithDoc
49
53
50
54
51
55
type Item
52
56
= TermItem TermDetailWithDoc
53
57
| TypeItem TypeDetailWithDoc
58
+ -- TODO: DataConstructorItem and AbilityConstructorItem are currently not
59
+ -- rendered separate from TypeItem
54
60
| DataConstructorItem DataConstructorDetail
55
61
| AbilityConstructorItem AbilityConstructorDetail
56
62
@@ -66,6 +72,27 @@ type Msg
66
72
| FindWithinNamespace FQN
67
73
68
74
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
+
69
96
reference : WorkspaceItem -> Reference
70
97
reference item =
71
98
case item of
@@ -99,6 +126,23 @@ isDocItem item =
99
126
False
100
127
101
128
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
+
102
146
103
147
-- VIEW
104
148
@@ -289,7 +333,6 @@ viewItem :
289
333
-> Html Msg
290
334
viewItem ref data isFocused =
291
335
let
292
- -- TODO: Support zoom level on the source
293
336
( zoomClass, infoZoomToggle, sourceZoomToggle ) =
294
337
case data. zoom of
295
338
Far ->
@@ -304,52 +347,51 @@ viewItem ref data isFocused =
304
347
attrs =
305
348
[ class zoomClass, classList [ ( " focused" , isFocused ) ] ]
306
349
350
+ sourceConfig =
351
+ Source . Rich ( OpenReference ref)
352
+
307
353
viewDoc_ doc =
308
354
doc
309
355
|> Maybe . map ( viewDoc ref data. docFoldToggles)
310
356
|> Maybe . withDefault UI . nothing
311
357
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
314
366
in
315
367
case data. item of
316
368
TermItem ( Term h category detail) ->
317
369
viewClosableRow
318
370
ref
319
371
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)
325
374
326
375
TypeItem ( Type h category detail) ->
327
376
viewClosableRow
328
377
ref
329
378
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)
335
381
336
382
DataConstructorItem ( DataConstructor h detail) ->
337
383
viewClosableRow
338
384
ref
339
385
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 )
344
388
345
389
AbilityConstructorItem ( AbilityConstructor h detail) ->
346
390
viewClosableRow
347
391
ref
348
392
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 )
353
395
354
396
355
397
view : WorkspaceItem -> Bool -> Html Msg
0 commit comments