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
26 changes: 19 additions & 7 deletions examples/Demo/FluentUI.Demo.Client/Layout/DemoMainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Title="Open or hide the console" />
</FluentLayoutItem>

<FluentLayout @ref="@_layout" Style="@(_consoleLogOpened ? "height: calc(100vh - 230px); width: 100vw;" : "height: calc(100vh - 80px); width: 100vw;")">
<FluentLayout @ref="@_layout" @key="@GetLayoutKey()" Style="@(_consoleLogOpened ? "height: calc(100vh - 230px); width: 100vw;" : "height: calc(100vh - 80px); width: 100vw;")">

@{
var menuHeight = _consoleLogOpened ? "calc(100vh - 90px - 150px)" : "calc(100vh - 90px)";
Expand All @@ -41,13 +41,25 @@
<DemoNavMenu />
</FluentLayoutItem>

<FluentLayoutItem Area="@LayoutArea.Content">
@Body
</FluentLayoutItem>
@if (IsHomePage())
{
<FluentLayoutItem Area="@LayoutArea.Content">
<div class="demo-home">
<div>@Body</div>
<div><DemoAsidePanel Page="@Navigation.ToBaseRelativePath(Navigation.Uri)" /></div>
</div>
</FluentLayoutItem>
}
else
{
<FluentLayoutItem Area="@LayoutArea.Content">
@Body
</FluentLayoutItem>

<FluentLayoutItem Area="@LayoutArea.Aside" Width="240px" Sticky="true">
<DemoAsidePanel Page="@Navigation.ToBaseRelativePath(Navigation.Uri)" />
</FluentLayoutItem>
<FluentLayoutItem Area="@LayoutArea.Aside" Width="240px" Sticky="true">
<DemoAsidePanel Page="@Navigation.ToBaseRelativePath(Navigation.Uri)" />
</FluentLayoutItem>
}

</FluentLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,16 @@ protected override void OnInitialized()
return ValueTask.CompletedTask;
});
}

private bool IsHomePage()
{
if (Navigation.Uri == Navigation.BaseUri)
{
return true;
}

return false;
}

private string GetLayoutKey() => IsHomePage() ? "Home" : string.Empty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.demo-home {
display: flex;
}

@media (max-width: 1280px) {
.demo-home {
flex-direction: column;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div>
<ul>
@foreach (var page in DocViewerService.Pages.Where(i => !i.Hidden).OrderBy(i => i.Title))
@foreach (var page in DocViewerService.Pages.Where(i => !i.Hidden).OrderBy(i => i.Route))
{
<li>
<a href="@(page.Route)">@(page.Title)</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

Expand Down Expand Up @@ -59,6 +59,22 @@ public static bool IsNullable(this Type type)
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}

/// <summary>
/// Checks if the specified member is or return a nullable value type.
/// </summary>
/// <param name="member">Member to check.</param>
/// <returns>True if the type is nullable like int?</returns>
public static bool IsNullable(this MemberInfo member)
{
return member switch
{
MethodInfo method => !method.ReturnType.IsValueType && (new NullabilityInfoContext().Create(method.ReturnParameter).ReadState is NullabilityState.Nullable),
PropertyInfo property => !property.PropertyType.IsValueType && (new NullabilityInfoContext().Create(property).WriteState is NullabilityState.Nullable),
FieldInfo field => !field.FieldType.IsValueType && (new NullabilityInfoContext().Create(field).WriteState is NullabilityState.Nullable),
_ => false
};
}

/// <summary>
/// Convert type to the proper type _name.
/// Optional <paramref _name="typeNameConverter"/> function can convert type names to strings
Expand Down Expand Up @@ -92,7 +108,9 @@ public static string ToNameString(this Type type, Func<Type, string>? typeNameCo
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name</returns>
public static string ToNameString(this Type type, Func<Type, Queue<string?>?, string>? typeNameConverter,
public static string ToNameString(
this Type type,
Func<Type, Queue<string?>?, string>? typeNameConverter,
bool invokeTypeNameConverterForGenericType = false)
{
return type.ToNameString(null, typeNameConverter, invokeTypeNameConverterForGenericType);
Expand All @@ -116,7 +134,9 @@ public static string ToNameString(this Type type, Func<Type, Queue<string?>?, st
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full list of parameter types and their names</returns>
public static string ToParametersString(this MethodBase methodInfo, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToParametersString(
this MethodBase methodInfo,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
var parameters = methodInfo.GetParameters();
Expand Down Expand Up @@ -145,7 +165,9 @@ public static string ToParametersString(this MethodBase methodInfo, Func<Type, Q
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name of the parameter</returns>
public static string ToTypeNameString(this ParameterInfo parameterInfo, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToTypeNameString(
this ParameterInfo parameterInfo,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
if (parameterInfo.ParameterType.IsByRef)
Expand Down Expand Up @@ -179,12 +201,14 @@ public static string ToTypeNameString(this ParameterInfo parameterInfo, Func<Typ
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name of the return value</returns>
public static string ToTypeNameString(this MethodInfo methodInfo, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToTypeNameString(
this MethodInfo methodInfo,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
return methodInfo.ReturnType.ToNameStringWithValueTupleNames(
methodInfo.ReturnParameter?.GetCustomAttribute<TupleElementNamesAttribute>()?.TransformNames, typeNameConverter,
invokeTypeNameConverterForGenericType);
invokeTypeNameConverterForGenericType) + (IsNullable(methodInfo) ? "?" : string.Empty);
}

/// <summary>
Expand All @@ -204,12 +228,14 @@ public static string ToTypeNameString(this MethodInfo methodInfo, Func<Type, Que
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name of the property</returns>
public static string ToTypeNameString(this PropertyInfo propertyInfo, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToTypeNameString(
this PropertyInfo propertyInfo,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
return propertyInfo.PropertyType.ToNameStringWithValueTupleNames(
propertyInfo.GetCustomAttribute<TupleElementNamesAttribute>()?.TransformNames, typeNameConverter,
invokeTypeNameConverterForGenericType);
invokeTypeNameConverterForGenericType) + (IsNullable(propertyInfo) ? "?" : string.Empty);
}

/// <summary>
Expand All @@ -229,12 +255,14 @@ public static string ToTypeNameString(this PropertyInfo propertyInfo, Func<Type,
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name of the field</returns>
public static string ToTypeNameString(this FieldInfo fieldInfo, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToTypeNameString(
this FieldInfo fieldInfo,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
return fieldInfo.FieldType.ToNameStringWithValueTupleNames(
fieldInfo.GetCustomAttribute<TupleElementNamesAttribute>()?.TransformNames, typeNameConverter,
invokeTypeNameConverterForGenericType);
invokeTypeNameConverterForGenericType) + (IsNullable(fieldInfo) ? "?" : string.Empty);
}

/// <summary>
Expand All @@ -255,7 +283,10 @@ public static string ToTypeNameString(this FieldInfo fieldInfo, Func<Type, Queue
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full _name of the specified type</returns>
public static string ToNameStringWithValueTupleNames(this Type type, IList<string?>? tupleNames, Func<Type, Queue<string?>?, string>? typeNameConverter = null,
public static string ToNameStringWithValueTupleNames(
this Type type,
IList<string?>? tupleNames,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
var tq = tupleNames == null ? null : new Queue<string?>(tupleNames);
Expand All @@ -282,14 +313,18 @@ public static string ToNameStringWithValueTupleNames(this Type type, IList<strin
/// ToNameString() to avoid infinite recursion.
/// This is an optional parameter with default value of false.</param>
/// <returns>Full type _name</returns>
public static string ToNameString(this Type type, Queue<string?>? tupleFieldNames, Func<Type, Queue<string?>?, string>? typeNameConverter = null, bool invokeTypeNameConverterForGenericType = false)
public static string ToNameString(
this Type type,
Queue<string?>? tupleFieldNames,
Func<Type, Queue<string?>?, string>? typeNameConverter = null,
bool invokeTypeNameConverterForGenericType = false)
{
if (type.IsByRef)
{
return "ref " + type.GetElementType()?.ToNameString(tupleFieldNames, typeNameConverter, invokeTypeNameConverterForGenericType);
}

var decoratedTypeName = type.IsGenericType || tupleFieldNames is null ? null : typeNameConverter?.Invoke(type, tupleFieldNames);
var decoratedTypeName = type.IsGenericType || tupleFieldNames is null ? null : typeNameConverter?.Invoke(type, tupleFieldNames);

if (decoratedTypeName != null && (tupleFieldNames == null || tupleFieldNames.Count == 0))
{
Expand All @@ -299,7 +334,7 @@ public static string ToNameString(this Type type, Queue<string?>? tupleFieldName
}

string? newTypeName = null;

if (KnownTypeNames.TryGetValue(type, out var value))
{
newTypeName = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs
}

var task = item.Action.Invoke();
task.ContinueWith(t =>
_ = task.ContinueWith(t =>
{
if (t.IsFaulted)
{
Expand All @@ -90,7 +90,7 @@ private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs
{
item.Status.SetResult();
}
});
}, TaskScheduler.Default);
}
}
}
Expand Down