From ce3795bb50147f948902e749cd2a65e35277c491 Mon Sep 17 00:00:00 2001 From: KIT! Date: Fri, 9 Aug 2024 15:46:55 +0200 Subject: [PATCH] Fixed some text display stuff Don't break Access codes into groups of 4 if they aren't a multiple of 4 or if they aren't hexadecimal only (This is useful if a user only uses a nickname as an access code and not a card id) Changed color of is-current-user on the leaderboard so text is legible in dark mode. Made Leaderboard useable on mobile as well by removing responsive breakpoints. --- TaikoWebUI/Components/Song/SongLeaderboardCard.razor | 2 +- TaikoWebUI/Components/UserCard.razor | 11 +++++++++-- TaikoWebUI/Pages/AccessCode.razor | 11 +++++++++-- TaikoWebUI/Utilities/StringUtil.cs | 5 +++++ TaikoWebUI/wwwroot/style.overrides.css | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor index 0334fbe..846f061 100644 --- a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor +++ b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor @@ -45,7 +45,7 @@ } else { - + @Localizer["Rank"] @Localizer["Player"] diff --git a/TaikoWebUI/Components/UserCard.razor b/TaikoWebUI/Components/UserCard.razor index 993e3a7..7651016 100644 --- a/TaikoWebUI/Components/UserCard.razor +++ b/TaikoWebUI/Components/UserCard.razor @@ -90,9 +90,16 @@ @if (User.AccessCodes.Count > 0) { - @foreach (var digitGroup in StringUtil.SplitIntoGroups(User.AccessCodes[0], 4)) + @if (User.AccessCodes[0].Length % 4 == 0 && StringUtil.OnlyHexInString(User.AccessCodes[0])) { - @digitGroup + foreach (var digitGroup in StringUtil.SplitIntoGroups(User.AccessCodes[0], 4)) + { + @digitGroup + } + } + else + { + @User.AccessCodes[0] } } else { diff --git a/TaikoWebUI/Pages/AccessCode.razor b/TaikoWebUI/Pages/AccessCode.razor index 44aa18f..88f26b7 100644 --- a/TaikoWebUI/Pages/AccessCode.razor +++ b/TaikoWebUI/Pages/AccessCode.razor @@ -54,9 +54,16 @@
-                                                @foreach (var digitGroup in StringUtil.SplitIntoGroups(accessCode, 4))
+                                                @if (accessCode.Length % 4 == 0 && StringUtil.OnlyHexInString(accessCode))
                                                 {
-                                                @digitGroup
+                                                    foreach (var digitGroup in StringUtil.SplitIntoGroups(accessCode, 4))
+                                                    {
+                                                        @digitGroup
+                                                    }
+                                                }
+                                                else
+                                                {
+                                                    @accessCode
                                                 }
                                             
diff --git a/TaikoWebUI/Utilities/StringUtil.cs b/TaikoWebUI/Utilities/StringUtil.cs index 53abedb..8895eb0 100644 --- a/TaikoWebUI/Utilities/StringUtil.cs +++ b/TaikoWebUI/Utilities/StringUtil.cs @@ -16,5 +16,10 @@ } return groups; } + + public bool OnlyHexInString(string test) + { + return System.Text.RegularExpressions.Regex.IsMatch(test, @"\A\b[0-9a-fA-F]+\b\Z"); + } } } \ No newline at end of file diff --git a/TaikoWebUI/wwwroot/style.overrides.css b/TaikoWebUI/wwwroot/style.overrides.css index f839783..f0d83e2 100644 --- a/TaikoWebUI/wwwroot/style.overrides.css +++ b/TaikoWebUI/wwwroot/style.overrides.css @@ -56,7 +56,7 @@ } tr.is-current-user { - background-color: #d6e5f8 !important; + background-color: #8c9eff75 !important } tr.is-current-user td,