Skip to content

Commit

Permalink
Merge pull request #470 from Bram1903/fix_culture_fontsize_bug
Browse files Browse the repository at this point in the history
Resolve Font Size Adjustment Discrepancy Across Cultures
  • Loading branch information
neozhu authored Aug 9, 2023
2 parents 9ef9486 + 4628bab commit a971143
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CleanArchitecture.Blazor.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>CleanArchitecture.Blazor.Solution.Template</id>
<version>1.0.0-preview.9</version>
<version>1.0.0-preview.10</version>
<title>Clean Architecture Blazor Solution Template</title>
<authors>hl.z</authors>
<description>Clean Architecture Blazor Solution Template for .NET 7.</description>
<summary>
A Clean Architecture Blazor Server Solution Template for creating a Single-Page Application (SPA) with ASP.NET Core.
</summary>
<releaseNotes>
1.0.0-preview.10
- Resolved font size adjustment discrepancy across cultures
1.0.0-preview.9
- 🍒 Improve Specification Query
</releaseNotes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Blazor.Server.UI.Services;
using Blazor.Server.UI.Services.Layout;
using Blazor.Server.UI.Services.UserPreferences;
Expand Down Expand Up @@ -76,8 +77,7 @@ public async Task ToggleDarkLightMode(DarkLightMode mode )
}
private async Task ChangedFontSize(ChangeEventArgs args)
{
UserPreferences.DefaultFontSize = double.Parse(args?.Value?.ToString() ?? "0");
UserPreferences.DefaultFontSize = double.Parse(args?.Value?.ToString() ?? "0", NumberStyles.Float, CultureInfo.InvariantCulture);
await UserPreferencesChanged.InvokeAsync(UserPreferences);
}

}
5 changes: 3 additions & 2 deletions src/Blazor.Server.UI/Services/Layout/LayoutService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Blazor.Server.UI.Services.UserPreferences;

namespace Blazor.Server.UI.Services.Layout;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void SetDarkMode(bool value)
CurrentTheme.Palette.Secondary = SecondaryColor;
CurrentTheme.PaletteDark.Secondary = SecondaryColor;
CurrentTheme.LayoutProperties.DefaultBorderRadius = BorderRadius + "px";
CurrentTheme.Typography.Default.FontSize = DefaultFontSize + "rem";
CurrentTheme.Typography.Default.FontSize = DefaultFontSize.ToString("0.0000", CultureInfo.InvariantCulture) + "rem";
}
else
{
Expand Down Expand Up @@ -170,7 +171,7 @@ public async Task UpdateUserPreferences(UserPreferences.UserPreferences preferen
CurrentTheme.Palette.Secondary = SecondaryColor;
CurrentTheme.PaletteDark.Secondary = SecondaryColor;
CurrentTheme.LayoutProperties.DefaultBorderRadius = BorderRadius + "px";
CurrentTheme.Typography.Default.FontSize = DefaultFontSize+"rem";
CurrentTheme.Typography.Default.FontSize = DefaultFontSize.ToString("0.0000", CultureInfo.InvariantCulture) + "rem";
await _userPreferencesService.SaveUserPreferences(_userPreferences);
OnMajorUpdateOccured();
}
Expand Down

0 comments on commit a971143

Please sign in to comment.