Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/MudBlazor.Markdown/Helpers/MudMarkdownStyling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,43 @@ public sealed class TableStyling
/// <summary>
/// If true, striped table rows will be used.
/// </summary>
/// <remarks>
/// Defaults to <c>true</c>.
/// </remarks>
public bool IsStriped { get; set; } = true;

/// <summary>
/// If true, table's cells will have left/right borders.
/// </summary>
/// <remarks>
/// Defaults to <c>true</c>.
/// </remarks>
public bool IsBordered { get; set; } = true;

/// <summary>
/// Child content of component.
/// </summary>
/// <remarks>
/// Defaults to <c>1</c>.
/// </remarks>
public int Elevation { set; get; } = 1;

/// <summary>
/// Minimum width (in pixels) for a table cell.<br/>
/// If <see langword="null" /> or negative the minimum width is not applied.
/// </summary>
/// <remarks>
/// Defaults to <c>null</c>.
/// </remarks>
public int? CellMinWidth { get; set; }

/// <summary>
/// Uses compact padding for all rows.
/// </summary>
/// <remarks>
/// Defaults to <c>false</c>.
/// </remarks>
public bool Dense { get; set; }
}

/// <summary>
Expand All @@ -52,6 +72,9 @@ public sealed class LinkStyling
/// <summary>
/// Underline style.
/// </summary>
/// <remarks>
/// Defaults to <c>Hover</c>.
/// </remarks>
public Underline Underline { get; set; } = Underline.Hover;
}

Expand Down
1 change: 1 addition & 0 deletions src/MudBlazor.Markdown/MudMarkdown.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ protected virtual void RenderTable(RenderTreeBuilder builder1, ref int elementIn
builder1.AddComponentParameter(elementIndex1++, nameof(MudSimpleTable.Striped), Styling.Table.IsStriped);
builder1.AddComponentParameter(elementIndex1++, nameof(MudSimpleTable.Bordered), Styling.Table.IsBordered);
builder1.AddComponentParameter(elementIndex1++, nameof(MudSimpleTable.Elevation), Styling.Table.Elevation);
builder1.AddComponentParameter(elementIndex1++, nameof(MudSimpleTable.Dense), Styling.Table.Dense);
builder1.AddComponentParameter(elementIndex1++, nameof(MudSimpleTable.ChildContent), (RenderFragment)(builder2 =>
{
var elementIndex2 = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/MudBlazor.Markdown/Resources/MudBlazor.Markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pre code.hljs {
margin: 1.25em 0;
}

.mud-markdown-body table p {
margin-bottom: 0 !important;
}

/* Link */
.mud-markdown-body .mud-link:hover {
cursor: pointer !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void RenderTableNotStriped()
using var fixture = CreateFixture(value, styling: styling);
fixture.MarkupMatches(expected);
}

[Fact]
public void RenderTableNotBordered()
{
Expand Down Expand Up @@ -163,12 +163,66 @@ public void RenderTableNoElevation()
using var fixture = CreateFixture(value, styling: styling);
fixture.MarkupMatches(expected);
}


[Fact]
public void RenderTableDense()
{
const string value =
"""
|Column1|Column2|Column3|
|-|-|-|
|cell1-1|cell1-2|cell1-3|
|cell2-1|cell2-2|cell2-3|
""";

const string expected =
"""
<article id:ignore class='mud-markdown-body'>
<div class='mud-table mud-simple-table mud-table-dense mud-table-bordered mud-table-striped mud-elevation-1' style='overflow-x: auto;'>
<div class='mud-table-container'>
<table>
<thead>
<tr>
<th><p class='mud-typography mud-typography-body1'>Column1</p></th>
<th><p class='mud-typography mud-typography-body1'>Column2</p></th>
<th><p class='mud-typography mud-typography-body1'>Column3</p></th>
</tr>
</thead>
<tbody>
<tr>
<td><p class='mud-typography mud-typography-body1'>cell1-1</p></td>
<td><p class='mud-typography mud-typography-body1'>cell1-2</p></td>
<td><p class='mud-typography mud-typography-body1'>cell1-3</p></td>
</tr>
<tr>
<td><p class='mud-typography mud-typography-body1'>cell2-1</p></td>
<td><p class='mud-typography mud-typography-body1'>cell2-2</p></td>
<td><p class='mud-typography mud-typography-body1'>cell2-3</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</article>
""";

var styling = new MudMarkdownStyling
{
Table =
{
Dense = true,
},
};

using var fixture = CreateFixture(value, styling: styling);
fixture.MarkupMatches(expected);
}

[Fact]
public void RenderLinkUnderlineAlways()
{
const string value = "[my link](https://www.mynihongo.org/)";

const string expected =
"""
<article id:ignore class='mud-markdown-body'>
Expand All @@ -185,16 +239,16 @@ public void RenderLinkUnderlineAlways()
Underline = Underline.Always,
},
};

using var fixture = CreateFixture(value, styling: styling);
fixture.MarkupMatches(expected);
}

[Fact]
public void RenderLinkUnderlineNone()
{
const string value = "[my link](https://www.mynihongo.org/)";

const string expected =
"""
<article id:ignore class='mud-markdown-body'>
Expand All @@ -211,7 +265,7 @@ public void RenderLinkUnderlineNone()
Underline = Underline.None,
},
};

using var fixture = CreateFixture(value, styling: styling);
fixture.MarkupMatches(expected);
}
Expand Down