-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Hero editor component in Blazor
- Loading branch information
Showing
5 changed files
with
59 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
div { | ||
display: inline-block; | ||
border: 2px solid black; | ||
background: #eee; | ||
border: 2px solid #55328c; | ||
background: #f0eaf7; | ||
padding: 1em; | ||
margin: 1em; | ||
background-image: url("assets/blazor-icon.png"); | ||
background-repeat: no-repeat; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="container"> | ||
<div><span>id: </span>@Hero.id</div> | ||
<div> | ||
<label for="hero-name">Hero name: </label> | ||
<input id="hero-name" @bind="newName" placeholder="Hero name" @bind:event="oninput" @onkeyup="UpdateHero" /> | ||
</div> | ||
</div> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public Hero Hero { get; set; } = new(0, ""); | ||
|
||
[Parameter] | ||
public EventCallback<Hero> HeroChanged { get; set; } | ||
|
||
private string newName = ""; | ||
|
||
|
||
protected override void OnParametersSet() { | ||
newName = Hero.name; | ||
} | ||
|
||
private async Task UpdateHero() { | ||
Hero = Hero with { name = newName }; | ||
await HeroChanged.InvokeAsync(Hero); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
div.container { | ||
display: inline-block; | ||
border: 2px solid #55328c; | ||
background: #f0eaf7; | ||
padding: 30px; | ||
margin: 1em; | ||
background-image: url("assets/blazor-icon.png"); | ||
background-repeat: no-repeat; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.