diff --git a/Pkmds.Web/Components/BoxGrid.razor b/Pkmds.Web/Components/BoxGrid.razor
index 9f6c3afd..060c35e0 100644
--- a/Pkmds.Web/Components/BoxGrid.razor
+++ b/Pkmds.Web/Components/BoxGrid.razor
@@ -10,8 +10,9 @@
-
+ Pokemon="@pkm"
+ OnSlotClick="@(() => SetSelectedPokemon(pkm, BoxNumber, slotNum))"
+ GetStyleFunction="@(() => GetStyle(slotNum))" />
}
}
diff --git a/Pkmds.Web/Components/BoxGrid.razor.cs b/Pkmds.Web/Components/BoxGrid.razor.cs
index b3b2ae5c..9967750f 100644
--- a/Pkmds.Web/Components/BoxGrid.razor.cs
+++ b/Pkmds.Web/Components/BoxGrid.razor.cs
@@ -8,7 +8,15 @@ public partial class BoxGrid : IDisposable
[Parameter, EditorRequired]
public int BoxNumber { get; set; }
- private string BoxGridClass => AppState.SaveFile?.BoxSlotCount == 20 ? "box-grid-20" : "box-grid-30";
+ private string BoxGridClass =>
+ AppState.SaveFile?.BoxSlotCount == 20 ? "box-grid-20" : "box-grid-30";
+
+ private void SetSelectedPokemon(PKM? pokemon, int boxNumber, int slotNumber) =>
+ AppService.SetSelectedBoxPokemon(pokemon, boxNumber, slotNumber);
+
+ private string GetStyle(int slotNumber) => AppState.SelectedBoxSlotNumber == slotNumber
+ ? "border: 4px solid orange; border-radius: 6px;"
+ : string.Empty;
protected override void OnInitialized() =>
RefreshService.OnAppStateChanged += StateHasChanged;
diff --git a/Pkmds.Web/Components/BoxSlotComponent.razor.cs b/Pkmds.Web/Components/BoxSlotComponent.razor.cs
index 00445178..b46d67b7 100644
--- a/Pkmds.Web/Components/BoxSlotComponent.razor.cs
+++ b/Pkmds.Web/Components/BoxSlotComponent.razor.cs
@@ -1,26 +1,7 @@
namespace Pkmds.Web.Components;
-public partial class BoxSlotComponent : IDisposable
+public class BoxSlotComponent : PokemonSlotComponent
{
[Parameter, EditorRequired]
public int BoxNumber { get; set; }
-
- [Parameter, EditorRequired]
- public int SlotNumber { get; set; }
-
- [Parameter, EditorRequired]
- public PKM? Pokemon { get; set; }
-
- private string Style => AppState.SelectedBoxSlotNumber == SlotNumber
- ? "border: 4px solid orange; border-radius: 6px;"
- : string.Empty;
-
- protected override void OnInitialized() =>
- RefreshService.OnAppStateChanged += StateHasChanged;
-
- public void Dispose() =>
- RefreshService.OnAppStateChanged -= StateHasChanged;
-
- private void SetSelectedPokemon() =>
- AppService.SetSelectedBoxPokemon(Pokemon, BoxNumber, SlotNumber);
}
diff --git a/Pkmds.Web/Components/PartyGrid.razor b/Pkmds.Web/Components/PartyGrid.razor
index 919b0a30..bb432873 100644
--- a/Pkmds.Web/Components/PartyGrid.razor
+++ b/Pkmds.Web/Components/PartyGrid.razor
@@ -16,8 +16,10 @@
var slotNum = i;
PKM? pkm = i < AppState.SaveFile.PartyCount ? AppState.SaveFile.PartyData[slotNum] : null;
-
+
}
diff --git a/Pkmds.Web/Components/PartyGrid.razor.cs b/Pkmds.Web/Components/PartyGrid.razor.cs
index 2e587f19..ebb0fbe5 100644
--- a/Pkmds.Web/Components/PartyGrid.razor.cs
+++ b/Pkmds.Web/Components/PartyGrid.razor.cs
@@ -2,6 +2,13 @@ namespace Pkmds.Web.Components;
public partial class PartyGrid
{
+ private void SetSelectedPokemon(PKM? pokemon, int slotNumber) =>
+ AppService.SetSelectedPartyPokemon(pokemon, slotNumber);
+
+ private string GetStyle(int slotNumber) => AppState.SelectedPartySlotNumber == slotNumber
+ ? "border: 4px solid orange; border-radius: 6px;"
+ : string.Empty;
+
protected override void OnInitialized()
{
RefreshService.OnAppStateChanged += StateHasChanged;
diff --git a/Pkmds.Web/Components/PartySlotComponent.razor b/Pkmds.Web/Components/PartySlotComponent.razor
deleted file mode 100644
index 62d57b2e..00000000
--- a/Pkmds.Web/Components/PartySlotComponent.razor
+++ /dev/null
@@ -1,10 +0,0 @@
-@inherits BasePkmdsComponent
-
-
-
-
diff --git a/Pkmds.Web/Components/BoxSlotComponent.razor b/Pkmds.Web/Components/PokemonSlotComponent.razor
similarity index 77%
rename from Pkmds.Web/Components/BoxSlotComponent.razor
rename to Pkmds.Web/Components/PokemonSlotComponent.razor
index 62d57b2e..42741d01 100644
--- a/Pkmds.Web/Components/BoxSlotComponent.razor
+++ b/Pkmds.Web/Components/PokemonSlotComponent.razor
@@ -1,10 +1,11 @@
@inherits BasePkmdsComponent
+@implements IDisposable
+ Style="@GetStyle()">
diff --git a/Pkmds.Web/Components/PartySlotComponent.razor.cs b/Pkmds.Web/Components/PokemonSlotComponent.razor.cs
similarity index 50%
rename from Pkmds.Web/Components/PartySlotComponent.razor.cs
rename to Pkmds.Web/Components/PokemonSlotComponent.razor.cs
index a37548be..15122816 100644
--- a/Pkmds.Web/Components/PartySlotComponent.razor.cs
+++ b/Pkmds.Web/Components/PokemonSlotComponent.razor.cs
@@ -1,6 +1,6 @@
namespace Pkmds.Web.Components;
-public partial class PartySlotComponent : IDisposable
+public partial class PokemonSlotComponent
{
[Parameter, EditorRequired]
public int SlotNumber { get; set; }
@@ -8,16 +8,21 @@ public partial class PartySlotComponent : IDisposable
[Parameter, EditorRequired]
public PKM? Pokemon { get; set; }
- private string Style => AppState.SelectedPartySlotNumber == SlotNumber
- ? "border: 4px solid orange; border-radius: 6px;"
- : string.Empty;
+ [Parameter, EditorRequired]
+ public EventCallback OnSlotClick { get; set; }
+
+ [Parameter, EditorRequired]
+ public Func? GetStyleFunction { get; set; }
+
+ private async Task HandleClick() =>
+ await OnSlotClick.InvokeAsync();
+
+ private string GetStyle() =>
+ GetStyleFunction?.Invoke() ?? string.Empty;
protected override void OnInitialized() =>
RefreshService.OnAppStateChanged += StateHasChanged;
public void Dispose() =>
RefreshService.OnAppStateChanged -= StateHasChanged;
-
- private void SetSelectedPokemon() =>
- AppService.SetSelectedPartyPokemon(Pokemon, SlotNumber);
}