Skip to content

Commit 2d5a86c

Browse files
rueckstiesskangas
authored andcommitted
simplified and covered array > array case
1 parent be1a12a commit 2d5a86c

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

src/document-list/document-list-item.jade

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
1-
mixin jsprimitive(value, _type)
2-
if _type === 'Date'
3-
- value = moment(value).format('LLL')
4-
.document-property-value(title=value)= value
1+
mixin jsvalue(value, _type)
2+
if _type === 'Array'
3+
- value = 'Array[' + value.length + ']'
4+
.document-property-type-label= value
5+
else if _type === 'Object'
6+
- value = 'Object'
7+
.document-property-type-label= value
8+
else
9+
if _type === 'Date'
10+
- value = moment(value).format('LLL')
11+
.document-property-value(title=value)= value
512

613
mixin jsarray(items)
714
ol.document-property-body
815
each item in items
916
+jsproperty(null, item)
10-
17+
1118
mixin jsproperty(key, value)
1219
- _type = getType(value)
13-
- is_expandable = _type === 'Object' || _type === 'Array'
14-
if !is_expandable
15-
if key
16-
li.document-property
17-
.document-property-key= key
18-
+jsprimitive(value, _type)
19-
else
20-
li.document-property-array-item
21-
+jsprimitive(value, _type)
22-
else if _type === 'Array'
23-
li.document-property-array
24-
.document-property-header
20+
li(class='document-property #{_type.toLowerCase()}')
21+
.document-property-header
22+
if _type === 'Array' || _type === 'Object'
2523
.caret
26-
if key
27-
.document-property-key= key
28-
| :
29-
.document-property-type-label Array[#{value.length}]
24+
if key
25+
.document-property-key= key
26+
|:
27+
+jsvalue(value, _type)
28+
if _type === 'Array'
3029
+jsarray(value)
31-
else
32-
li.document-property-object
33-
.document-property-header
34-
.caret
35-
if key
36-
.document-property-key= key
37-
| :
38-
.document-property-type-label Object
30+
if _type === 'Object'
3931
+jsobject(value)
4032

41-
4233
mixin jsobject(obj)
4334
ol.document-property-body
4435
for value, key in obj

src/document-list/index.less

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ol.document-list {
4444
}
4545
}
4646

47-
li.document-property-array, li.document-property-object {
47+
li.document-property.array, li.document-property.object {
4848
display: block;
4949
padding-top: 4px;
5050

@@ -70,13 +70,13 @@ ol.document-list {
7070
display: inline-block;
7171
}
7272
}
73-
ol.document-property-body {
73+
ol.document-property.body {
7474
margin-left: 5px;
7575
padding-left: -5px;
7676
border-left: 1px dotted @gray5;
7777
display: none;
7878
}
79-
ol.document-property-body > a ~ ol {
79+
ol.document-property.body > a ~ ol {
8080
padding-left: 12px;
8181
display: none;
8282
}
@@ -86,7 +86,7 @@ ol.document-list {
8686
.caret-down;
8787
}
8888
}
89-
> ol.document-property-body {
89+
> ol.document-property.body {
9090
display: block;
9191
}
9292
}

0 commit comments

Comments
 (0)