Skip to content

Commit

Permalink
Update to .NET 7 RC 2
Browse files Browse the repository at this point in the history
Fix rtl (Design Token type was wrong)
  • Loading branch information
vnbaaij committed Oct 11, 2022
1 parent 34ab2c7 commit 7d38729
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 66 deletions.
4 changes: 2 additions & 2 deletions examples/FluentUI.Demo.Client/FluentUI.Demo.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-rc.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-rc.1.*" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-rc.2.*" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/FluentUI.Demo.Shared/FluentUI.Demo.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-rc.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-rc.2.*" />
</ItemGroup>

<ItemGroup>
Expand Down
142 changes: 85 additions & 57 deletions examples/FluentUI.Demo.Shared/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,115 @@
using Microsoft.Fast.Components.FluentUI.DesignTokens;
using Microsoft.JSInterop;

namespace FluentUI.Demo.Shared
namespace FluentUI.Demo.Shared;

public partial class MainLayout : IAsyncDisposable
{
public partial class MainLayout : IAsyncDisposable
{
[Inject]
private IJSRuntime JSRuntime { get; set; } = default!;
private string? selectValue;

[Inject]
private NavigationManager NavigationManager { get; set; } = default!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = default!;

[Inject]
private BaseLayerLuminance BaseLayerLuminance { get; set; } = default!;
[Inject]
private NavigationManager NavigationManager { get; set; } = default!;

ElementReference container;
[Inject]
private BaseLayerLuminance BaseLayerLuminance { get; set; } = default!;

private IJSObjectReference? module;
bool menuchecked = true;
[Inject]
private AccentBaseColor AccentBaseColor { get; set; } = default!;

ErrorBoundary? errorBoundary;
[Inject]
private Direction Direction { get; set; } = default!;

LocalizationDirection dir;
float baseLayerLuminance = 1;

protected override void OnInitialized()
{
NavigationManager.LocationChanged += LocationChanged;
base.OnInitialized();
}
ElementReference container;

protected override void OnParametersSet()
{
errorBoundary?.Recover();
}
private IJSObjectReference? module;
bool menuchecked = true;

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
module = await JSRuntime.InvokeAsync<IJSObjectReference>("import",
"./_content/FluentUI.Demo.Shared/Shared/MainLayout.razor.js");
}
await BaseLayerLuminance.SetValueFor(container, baseLayerLuminance);
//await DesignTokens.Direction.SetValueFor(container, dir.ToString());
}
ErrorBoundary? errorBoundary;

public async Task SwitchDirection()
{
dir = dir == LocalizationDirection.rtl ? LocalizationDirection.ltr : LocalizationDirection.rtl;
await JSRuntime.InvokeVoidAsync("switchDirection", dir.ToString());
}
LocalizationDirection dir;
float baseLayerLuminance = 0.98f;

public void SwitchTheme()
{
baseLayerLuminance = baseLayerLuminance == 0.15f ? 0.98f : 0.15f;
}
protected override void OnInitialized()
{
NavigationManager.LocationChanged += LocationChanged;
base.OnInitialized();
}

private void HandleChecked()
protected override void OnParametersSet()
{
errorBoundary?.Recover();
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
menuchecked = !menuchecked;
module = await JSRuntime.InvokeAsync<IJSObjectReference>("import",
"./_content/FluentUI.Demo.Shared/Shared/MainLayout.razor.js");
}
await BaseLayerLuminance.SetValueFor(container, baseLayerLuminance);
}

private async void LocationChanged(object? sender, LocationChangedEventArgs e)
public async Task SwitchDirection()
{
dir = dir == LocalizationDirection.rtl ? LocalizationDirection.ltr : LocalizationDirection.rtl;
await Direction.SetValueFor(container, dir.ToAttributeValue());
await JSRuntime.InvokeVoidAsync("switchDirection", dir.ToString());
}

public async void SwitchTheme()
{
baseLayerLuminance = baseLayerLuminance == 0.15f ? 0.98f : 0.15f;

await module!.InvokeVoidAsync("switchHighlightStyle", baseLayerLuminance == 0.15f ? true : false);
}

private void HandleChecked()
{
menuchecked = !menuchecked;
}

private async void HandleColorChange(ChangeEventArgs args)
{
string? value = args.Value?.ToString();
if (!string.IsNullOrEmpty(value))
{
if (e.IsNavigationIntercepted)
if (value != "default")
{
bool mobile = await module!.InvokeAsync<bool>("isDevice");

if (mobile)
{
menuchecked = false;
StateHasChanged();
}
selectValue = (string)args.Value;
await AccentBaseColor.SetValueFor(container, args.Value.ToString()!.ToSwatch());
}
else
{
selectValue = "default";
await AccentBaseColor.DeleteValueFor(container);
}
}
}

async ValueTask IAsyncDisposable.DisposeAsync()
private async void LocationChanged(object? sender, LocationChangedEventArgs e)
{
if (e.IsNavigationIntercepted)
{
if (module is not null)
bool mobile = await module!.InvokeAsync<bool>("isDevice");

if (mobile)
{
await module.DisposeAsync();
menuchecked = false;
StateHasChanged();
}
}
}

async ValueTask IAsyncDisposable.DisposeAsync()
{
if (module is not null)
{
await module.DisposeAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class DesignTokenConstants
{
// General tokens
public const string direction = "FluentUI.LocalizationDirection";
public const string direction = "string";
public const string disabledOpacity = "float?";

// Density tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Title>Microsoft Fluent UI Web Components for Blazor</Title>
<Description>A set of Blazor components wrapping Microsoft’s official Fluent UI Web Components. They implement the latest state of the Fluent design language, are built on FAST and work in every major browser.</Description>
<SignAssembly>true</SignAssembly>
<PackageVersion>1.6.0-rc.1</PackageVersion>
<ReleaseVersion>1.6.0-rc.1</ReleaseVersion>
<PackageVersion>1.6.0-rc.2</PackageVersion>
<ReleaseVersion>1.6.0-rc.2</ReleaseVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down Expand Up @@ -61,9 +61,9 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-rc.1.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0-rc.1.*" />
<PackageReference Include="System.Text.Json" Version="7.0.0-rc.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0-rc.2.*" />
<PackageReference Include="System.Text.Json" Version="7.0.0-rc.2.*" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 7d38729

Please sign in to comment.