-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from ofaruk84/ix-map-navigation-overlay
Map Navigation Overlay Component Implemented
- Loading branch information
Showing
5 changed files
with
106 additions
and
4 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
44 changes: 44 additions & 0 deletions
44
SiemensIXBlazor.Tests/MapNavigation/MapNavigationOverlayTest.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using SiemensIXBlazor.Components.MapNavigationOverlay; | ||
using System.ComponentModel; | ||
|
||
namespace SiemensIXBlazor.Tests.MapNavigation | ||
{ | ||
public class MapNavigationOverlayTest : TestContextBase | ||
{ | ||
[Fact] | ||
public void ComponentRendersWithParametersSetCorrectly() | ||
{ | ||
// Arrange | ||
var cut = RenderComponent<MapNavigationOverlay>(parameters => parameters | ||
.Add(p => p.Id, "testId") | ||
.Add(p => p.Name, "testApp") | ||
.Add(p => p.Icon, "testIcon") | ||
.Add(p => p.IconColor, "testColor")); | ||
|
||
// Assert | ||
cut.MarkupMatches( | ||
"<ix-map-navigation-overlay id=\"testId\" name=\"testApp\" icon=\"testIcon\" icon-color=\"testColor\" ></ix-map-navigation-overlay>"); | ||
|
||
} | ||
[Fact] | ||
public void EventCallbacksAreTriggeredCorrectly() | ||
{ | ||
// Arrange | ||
var isCloseButtonClicked = false; | ||
|
||
var cut = RenderComponent<MapNavigationOverlay>(parameters => parameters | ||
.Add(p => p.Id, "test-id") | ||
.Add(p => p.CloseButtonClickedEvent, EventCallback.Factory.Create(this, () => isCloseButtonClicked = true)) | ||
); | ||
|
||
|
||
// Act | ||
cut.InvokeAsync(() => cut.Instance.CloseClick()); | ||
|
||
// Assert | ||
Assert.True(isCloseButtonClicked); | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
SiemensIXBlazor/Components/MapNavigationOverlay/MapNavigationOverlay.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@using Microsoft.JSInterop; | ||
@inherits IXBaseComponent | ||
@inject IJSRuntime JSRuntime | ||
|
||
<ix-map-navigation-overlay @attributes=@UserAttributes | ||
class=@Class | ||
style="@Style" | ||
id=@Id | ||
name=@Name | ||
icon=@Icon | ||
icon-color=@IconColor> | ||
|
||
</ix-map-navigation-overlay> |
41 changes: 41 additions & 0 deletions
41
SiemensIXBlazor/Components/MapNavigationOverlay/MapNavigationOverlay.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.JSInterop; | ||
using SiemensIXBlazor.Interops; | ||
|
||
namespace SiemensIXBlazor.Components.MapNavigationOverlay | ||
{ | ||
public partial class MapNavigationOverlay | ||
{ | ||
[Parameter, EditorRequired] | ||
public string Id { get; set; } = string.Empty; | ||
[Parameter] | ||
public string? Name { get; set; } | ||
[Parameter] | ||
public string? Icon { get; set; } | ||
|
||
[Parameter] | ||
public string? IconColor { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback CloseButtonClickedEvent { get; set; } | ||
|
||
private BaseInterop _interop; | ||
|
||
protected async override Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
_interop = new(JSRuntime); | ||
|
||
await _interop.AddEventListener(this, Id, "closeClick", "CloseButtonClickedEvent"); | ||
} | ||
} | ||
|
||
|
||
[JSInvokable] | ||
public async Task CloseClick() | ||
{ | ||
await CloseButtonClickedEvent.InvokeAsync(); | ||
} | ||
} | ||
} |