-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7995f77
commit 094fb0d
Showing
8 changed files
with
39 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
Pkmds.Web/Components/BoxSlotComponent.razor → ...Web/Components/PokemonSlotComponent.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
@inherits BasePkmdsComponent | ||
@implements IDisposable | ||
|
||
<MudPaper Elevation="3" | ||
@onclick="SetSelectedPokemon" | ||
@onclick="HandleClick" | ||
Width="68px" | ||
Height="68px" | ||
Class="@SpriteHelper.GetSpriteCssClass(Pokemon)" | ||
Style="@Style"> | ||
Style="@GetStyle()"> | ||
<img class="pkm-sprite" src="@(Pokemon is { Species: > 0 } ? SpriteHelper.GetPokemonSpriteFilename(Pokemon) : null)" /> | ||
</MudPaper> |
19 changes: 12 additions & 7 deletions
19
...eb/Components/PartySlotComponent.razor.cs → .../Components/PokemonSlotComponent.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
namespace Pkmds.Web.Components; | ||
|
||
public partial class PartySlotComponent : IDisposable | ||
public partial class PokemonSlotComponent | ||
{ | ||
[Parameter, EditorRequired] | ||
public int SlotNumber { get; set; } | ||
|
||
[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<string>? 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); | ||
} |