Skip to content

Commit

Permalink
Output styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqimbasher committed May 30, 2024
1 parent 425a8d1 commit 23f6b3c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ output-pane {
}

.empty-collection {
@extend %null;
color: white;
background-color: $table-info-header-bg-color;
padding: 0.25rem 0.2rem;
display: inline-block;
}

.group {
Expand Down Expand Up @@ -112,14 +115,6 @@ output-pane {
}
}

td {
img,
audio,
video {
margin: 5px 0;
}
}

&.titled {
border-left: 2px orange solid;
margin-top: 0.5rem;
Expand Down Expand Up @@ -160,6 +155,7 @@ output-pane {
}

th {
font-weight: 600;
line-height: 1;
padding: 3px 5px;
color: white;
Expand Down Expand Up @@ -189,14 +185,8 @@ output-pane {
top: -4px; // An extra -1 to account for border of info header
}

td {
line-height: $font-size + 5;
padding: 0 5px;

> table {
margin-top: 4px !important;
margin-bottom: 4px !important;
}
td > table {
margin: 3px !important;
}

tbody td {
Expand All @@ -208,7 +198,7 @@ output-pane {
}

.property-name {
font-weight: bold;
font-weight: 600;
}

.collapse-actionable {
Expand Down
14 changes: 10 additions & 4 deletions src/External/O2Html/Converters/CollectionHtmlConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public override bool CanConvert(Type type)
SerializationScope serializationScope,
HtmlSerializer htmlSerializer)
{
return Convert(obj, type, serializationScope, htmlSerializer).node;
var result = Convert(obj, type, serializationScope, htmlSerializer);

if (result.collectionLength == 0 && serializationScope.Depth > 0 && htmlSerializer.SerializerOptions.DoNotSerializeNonRootEmptyCollections)
{
return new EmptyCollection(type).AddClass(htmlSerializer.SerializerOptions.CssClasses.EmptyCollection);
}

return result.node;
}

public override void WriteHtmlWithinTableRow<T>(
Expand All @@ -41,7 +48,7 @@ public override bool CanConvert(Type type)

var result = Convert(obj, type, serializationScope, htmlSerializer);

if (result.collectionLength == 0 && htmlSerializer.SerializerOptions.DoNotSerializeNonRootEmptyCollections)
if (result.collectionLength == 0 && serializationScope.Depth > 0 && htmlSerializer.SerializerOptions.DoNotSerializeNonRootEmptyCollections)
{
td.AddChild(new EmptyCollection(type).AddClass(htmlSerializer.SerializerOptions.CssClasses.EmptyCollection));
}
Expand Down Expand Up @@ -138,7 +145,7 @@ protected virtual (Node node, int? collectionLength) Convert<T>(T obj, Type type
{
keyValueStr = keyValue.ToString();
}
else if( typeCategory == TypeCategory.Collection)
else if (typeCategory == TypeCategory.Collection)
{
keyValueStr = keyValue.GetType().GetReadableName();
}
Expand Down Expand Up @@ -167,7 +174,6 @@ protected virtual (Node node, int? collectionLength) Convert<T>(T obj, Type type

keyValueStr += "}";
}

}

keyValueStr = keyValueStr == null
Expand Down
2 changes: 1 addition & 1 deletion src/External/O2Html/Dom/Elements/EmptyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public EmptyCollection() : base("span")

public EmptyCollection(Type collectionType) : base("span")
{
this.AddEscapedText($"0 items ({collectionType.GetReadableName()})");
this.AddEscapedText("(0 items)");
}
}

0 comments on commit 23f6b3c

Please sign in to comment.