Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add tooltips for enum types showing enum constants #3172

Merged
merged 8 commits into from
Nov 3, 2021
13 changes: 9 additions & 4 deletions src/MudBlazor.Docs/Components/DocsApi.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
<MudChip Variant="Variant.Outlined" Color="Color.Secondary" Size="Size.Small">overridden</MudChip>
}
</MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Type"><div style="display: flex; flex-direction: row; align-items: center; white-space: nowrap;">@context.Type<DocsBinding IsTwoWay="@context.IsTwoWay" /></div></MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Type">
<div style="display: flex; flex-direction: row; align-items: center; white-space: nowrap;">
<DocsTypeInfo Type="@context.Type" />
<DocsBinding IsTwoWay="@context.IsTwoWay" />
</div>
</MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Default">
@if (PresentDefaultValue(context.Default).Contains("<path"))
{
Expand Down Expand Up @@ -75,7 +80,7 @@
</HeaderContent>
<RowTemplate>
<MudTd Class="docs-content-api-cell" DataLabel="Name"><CodeInline>@context.Name</CodeInline></MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Type"><div style="display: flex; flex-direction: row; align-items: center; white-space: nowrap;">@context.Type</div></MudTd>
<MudTd Class="docs-content-api-cell" DataLabel="Type"><div style="display: flex; flex-direction: row; align-items: center; white-space: nowrap;">@context.Type.ConvertToCSharpSource()</div></MudTd>
<MudTd Class="docs-content-api-cell docs-content-api-description" DataLabel="Description">@(HttpUtility.HtmlDecode(context.Description))</MudTd>
</RowTemplate>
</MudTable>
Expand Down Expand Up @@ -152,7 +157,7 @@
Default = string.Empty,
Description = GetDescription(Type, info),
IsTwoWay = CheckIsTwoWayEventCallback(info),
Type = info.PropertyType.ConvertToCSharpSource(),
Type = info.PropertyType,
};
}
}
Expand Down Expand Up @@ -207,7 +212,7 @@
Default = GetDefaultValue(info),
IsTwoWay = CheckIsTwoWayProperty(info),
Description = GetDescription(Type, info),
Type = info.PropertyType.ConvertToCSharpSource()
Type = info.PropertyType
};
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/MudBlazor.Docs/Components/DocsTypeInfo.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@if (NonnullableType.IsEnum)
{
<MudTooltip>
<ChildContent>@Type.ConvertToCSharpSource()</ChildContent>
<TooltipContent>
enumeration type
<MudText Align="Align.Left" Typo="Typo.body2">
@foreach (var name in Enum.GetNames(NonnullableType))
{
@(NonnullableType.Name + "." + name)<br />
}
</MudText>
</TooltipContent>
</MudTooltip>
}
else
{
@Type.ConvertToCSharpSource()
}

@code {
[Parameter] public Type Type { get; set; }

private Type NonnullableType => Nullable.GetUnderlyingType(Type) ?? Type;
}
5 changes: 3 additions & 2 deletions src/MudBlazor.Docs/Models/ApiProperty.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Reflection;
using System;
using System.Reflection;

namespace MudBlazor.Docs.Models
{
public class ApiProperty
{
public string Name { get; set; }
public string Type { get; set; }
public Type Type { get; set; }
iwis marked this conversation as resolved.
Show resolved Hide resolved
public PropertyInfo PropertyInfo { get; set; }
public string Description { get; set; }
public object Default { get; set; }
Expand Down