From 1b7a43e2ac1bb53e1e0e7c3d31296e87f659b145 Mon Sep 17 00:00:00 2001 From: Egamorf Date: Mon, 14 Apr 2025 21:03:34 +0200 Subject: [PATCH] Add style for game creation --- .../Games/Components/GameCreationForm.razor | 4 ++ .../Components/GameCreationForm.razor.css | 56 +++++++++++++-- .../Pages/Games/Components/GameValidation.cs | 15 ++-- .../Shared/Components/Popup/Popup.razor.cs | 6 +- .../Shared/Components/Select/Select.razor.cs | 3 +- .../CreateStaticResourceKey.cs | 4 ++ .../Constants/GlobalConstants.cs | 3 +- .../GameIdeas.WebAPI/Files/GameIdeas.fr.json | 69 ++++++++++--------- 8 files changed, 103 insertions(+), 57 deletions(-) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor index bfe8e8e..fe0612b 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor @@ -72,6 +72,9 @@
@ResourcesKey.Description :
+
+ +
+
\ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css index 9a7779e..cb261c1 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.css @@ -1,6 +1,7 @@ .game-form { display: flex; flex-direction: row; + justify-content: space-between; gap: 20px; } @@ -35,10 +36,14 @@ color: var(--white); } - ::deep input[type="date"]::-webkit-calendar-picker-indicator { - filter: invert(1); - cursor: pointer; - } +::deep input[type="date"]::-webkit-calendar-picker-indicator { + filter: invert(1); + cursor: pointer; +} + +::deep input[type="number"]::-webkit-inner-spin-button { + -webkit-appearance: none; +} ::deep textarea { resize: vertical; @@ -68,6 +73,43 @@ align-content: center; } -input[type="number"]::-webkit-inner-spin-button { - -webkit-appearance: none; -} \ No newline at end of file +.bottom-container { + margin-top: 8px; + height: 28px; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +::deep .invalid-content { + display: flex; + flex-wrap: wrap; + flex-shrink: 1; + margin: 0; + padding: 0; + list-style: none; + height: auto; + text-wrap: nowrap; +} + +::deep .invalid-content li { + margin-right: 8px; +} + +.buttons { + height: 100%; + display: flex; + flex-direction: row; + gap: 8px; +} + +.buttons button { + border: none; + outline: none; + background: var(--violet); + border-radius: var(--small-radius); + color: var(--white); + font-weight: bold; + padding: 0 10px; +} diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs index 69ce686..12eff58 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameValidation.cs @@ -1,5 +1,5 @@ using FluentValidation; -using GameIdeas.Shared.Constants; +using GameIdeas.Resources; using GameIdeas.Shared.Dto; namespace GameIdeas.BlazorApp.Pages.Games.Components; @@ -9,17 +9,10 @@ public class GameValidation : AbstractValidator public GameValidation() { RuleFor(g => g.Title) - .NotEmpty() - .NotNull() - .Matches(GlobalConstants.RegexName); - - RuleFor(g => g.ReleaseDate) - .NotEmpty() - .NotNull(); + .NotEmpty().WithMessage(ResourcesKey.InvalidTitle); RuleFor(g => g.Interest) - .NotNull() - .GreaterThanOrEqualTo(1) - .LessThanOrEqualTo(5); + .GreaterThanOrEqualTo(1).WithMessage(ResourcesKey.InvalidInterest) + .LessThanOrEqualTo(5).WithMessage(ResourcesKey.InvalidInterest); } } diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs index af8af70..c749d38 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Popup/Popup.razor.cs @@ -31,16 +31,18 @@ public partial class Popup { IsOpen = true; await BackdropFilter?.Show()!; - StateChanged?.Invoke(null, IsOpen); StateHasChanged(); + + StateChanged?.Invoke(null, IsOpen); } public async Task Close() { IsOpen = false; await BackdropFilter?.Hide()!; - StateChanged?.Invoke(null, IsOpen); StateHasChanged(); + + StateChanged?.Invoke(null, IsOpen); } private async Task HandleBackdropFilterClicked() diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs index 336911a..d243500 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs @@ -93,8 +93,7 @@ public partial class Select } private async Task HandleSubmitAdd() { - if (Regex.IsMatch(AddLabel, GlobalConstants.RegexName) && - Params.AddItem != null) + if (Params.AddItem != null) { Values ??= []; Values.Add(Params.AddItem(AddLabel)); diff --git a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs index 879572e..f39a66e 100644 --- a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs +++ b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs @@ -36,6 +36,8 @@ public class Translations (TranslationService translationService) public string ErrorFetchCategories => translationService.Translate(nameof(ErrorFetchCategories)); public string PlaceholderAdd => translationService.Translate(nameof(PlaceholderAdd)); public string ErrorCreateGame => translationService.Translate(nameof(ErrorCreateGame)); + public string InvalidTitle => translationService.Translate(nameof(InvalidTitle)); + public string InvalidInterest => translationService.Translate(nameof(InvalidInterest)); } public static class ResourcesKey @@ -80,4 +82,6 @@ public static class ResourcesKey public static string ErrorFetchCategories => _instance?.ErrorFetchCategories ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchCategories is not initialized."); public static string PlaceholderAdd => _instance?.PlaceholderAdd ?? throw new InvalidOperationException("ResourcesKey.PlaceholderAdd is not initialized."); public static string ErrorCreateGame => _instance?.ErrorCreateGame ?? throw new InvalidOperationException("ResourcesKey.ErrorCreateGame is not initialized."); + public static string InvalidTitle => _instance?.InvalidTitle ?? throw new InvalidOperationException("ResourcesKey.InvalidTitle is not initialized."); + public static string InvalidInterest => _instance?.InvalidInterest ?? throw new InvalidOperationException("ResourcesKey.InvalidInterest is not initialized."); } \ No newline at end of file diff --git a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs index 1d809f1..373c8b2 100644 --- a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs +++ b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs @@ -2,5 +2,6 @@ public class GlobalConstants { - public const string RegexName = @"[\w()\-_ ]*"; + } + \ No newline at end of file diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json b/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json index fa2f7c5..0dcf122 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json @@ -1,36 +1,37 @@ { - "GamesIdeas": "Game Ideas", - "ManualAdd": "Manuel", - "AutoAdd": "Automatique", - "Login": "Se connecter", - "Logout": "Se déconnecter", - "EnterUsername": "Nom d'utilisateur", - "EnterPassword": "Mot de passe", - "UserManager": "Gestion des utilisateurs", - "Filters": "Les filtres", - "LastAdd": "Les ajouts récents", - "Research": "Rechercher", - "Platforms": "Plateformes", - "Tags": "Genres", - "Publishers": "Editeurs", - "Developers": "Développeurs", - "StorageSize": "Taille d'espace", - "StorageSizeMo": "Taille d'espace en Mo", - "LastModification": "Dernière modifications", - "ReleaseDate": "Date de parution", - "Title": "Titre", - "Interest": "Intérêt", - "Properties": "Propriétés", - "Description": "Description", - "Save": "Enregister", - "Reset": "Annuler", - "ErrorWhenPostingData": "Erreur lors de la requête POST", - "ErrorWhenPutingData": "Erreur lors de la requête PUT", - "ErrorWhenDeletingData": "Erreur lors de la requête DELETE", - "ErrorWhenFetchingData": "Erreur lors de la requête GET", - "RequestFailedStatusFormat": "Erreur lors de la réponse, code {0}", - "ErrorFetchCategories": "Erreur lors de la récupération des catégories", - "PlaceholderAdd": "Ajouter un nouveau", - "ErrorCreateGame": "Erreur lors de la Création d'un jeu" - + "GamesIdeas": "Game Ideas", + "ManualAdd": "Manuel", + "AutoAdd": "Automatique", + "Login": "Se connecter", + "Logout": "Se déconnecter", + "EnterUsername": "Nom d'utilisateur", + "EnterPassword": "Mot de passe", + "UserManager": "Gestion des utilisateurs", + "Filters": "Les filtres", + "LastAdd": "Les ajouts récents", + "Research": "Rechercher", + "Platforms": "Plateformes", + "Tags": "Genres", + "Publishers": "Editeurs", + "Developers": "Développeurs", + "StorageSize": "Taille d'espace", + "StorageSizeMo": "Taille d'espace en Mo", + "LastModification": "Dernière modifications", + "ReleaseDate": "Date de parution", + "Title": "Titre", + "Interest": "Intérêt", + "Properties": "Propriétés", + "Description": "Description", + "Save": "Enregister", + "Reset": "Annuler", + "ErrorWhenPostingData": "Erreur lors de la requête POST", + "ErrorWhenPutingData": "Erreur lors de la requête PUT", + "ErrorWhenDeletingData": "Erreur lors de la requête DELETE", + "ErrorWhenFetchingData": "Erreur lors de la requête GET", + "RequestFailedStatusFormat": "Erreur lors de la réponse, code {0}", + "ErrorFetchCategories": "Erreur lors de la récupération des catégories", + "PlaceholderAdd": "Ajouter un nouveau", + "ErrorCreateGame": "Erreur lors de la Création d'un jeu", + "InvalidTitle": "Le titre est incorrect", + "InvalidInterest": "L'interêt est incorrect'" } \ No newline at end of file