-
Notifications
You must be signed in to change notification settings - Fork 0
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
a2b42a0
commit 2de9186
Showing
14 changed files
with
60 additions
and
62 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,4 +1,6 @@ | ||
<div class="context-menu" tabindex="0" style="transform: translateX(min(@(X)px, calc(100vw - 100%))) | ||
@namespace AstroPanda.Blazor.Toolkit | ||
|
||
<div class="context-menu" tabindex="0" style="transform: translateX(min(@(X)px, calc(100vw - 100%))) | ||
translateY(min(@(Y)px, calc(100vh - 100%))); z-index: 1405;" @onclick="Close"> | ||
@Content | ||
</div> |
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
5 changes: 4 additions & 1 deletion
5
src/AstroPanda.Blazor.Toolkit/Components/ContextMenuProvider.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
86 changes: 42 additions & 44 deletions
86
src/AstroPanda.Blazor.Toolkit/Components/ContextMenuProvider.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,51 +1,49 @@ | ||
using Microsoft.AspNetCore.Components.Routing; | ||
using Microsoft.AspNetCore.Components; | ||
using AstroPanda.Blazor.Toolkit.Services; | ||
|
||
namespace AstroPanda.Blazor.Toolkit.Components | ||
namespace AstroPanda.Blazor.Toolkit; | ||
|
||
public partial class ContextMenuProvider : IDisposable | ||
{ | ||
public partial class ContextMenuProvider : IDisposable | ||
[Inject] | ||
private IContextMenuService _contextMenuService { get; set; } | ||
|
||
[Inject] | ||
private NavigationManager _navigationManager { get; set; } | ||
|
||
private List<ContextMenuReference> _contextMenus { get; set; } = new List<ContextMenuReference>(); | ||
|
||
|
||
protected override void OnInitialized() | ||
{ | ||
((ContextMenuService)_contextMenuService).OnInstanceAdded += AddInstance; | ||
((ContextMenuService)_contextMenuService).OnInstanceCloseRequested += CloseAll; | ||
|
||
if (_navigationManager != null) | ||
_navigationManager.LocationChanged += HandleLocationChanged; | ||
} | ||
|
||
private void AddInstance(ContextMenuReference contextMenu) | ||
{ | ||
_contextMenus.Clear(); | ||
_contextMenus.Add(contextMenu); | ||
StateHasChanged(); | ||
} | ||
|
||
public void CloseAll() | ||
{ | ||
_contextMenus.Clear(); | ||
StateHasChanged(); | ||
} | ||
|
||
private void HandleLocationChanged(object sender, LocationChangedEventArgs args) | ||
{ | ||
CloseAll(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
[Inject] | ||
private IContextMenuService _contextMenuService { get; set; } | ||
|
||
[Inject] | ||
private NavigationManager _navigationManager { get; set; } | ||
|
||
private List<ContextMenuReference> _contextMenus { get; set; } = new List<ContextMenuReference>(); | ||
|
||
|
||
protected override void OnInitialized() | ||
{ | ||
((ContextMenuService)_contextMenuService).OnInstanceAdded += AddInstance; | ||
((ContextMenuService)_contextMenuService).OnInstanceCloseRequested += CloseAll; | ||
|
||
if (_navigationManager != null) | ||
_navigationManager.LocationChanged += HandleLocationChanged; | ||
} | ||
|
||
private void AddInstance(ContextMenuReference contextMenu) | ||
{ | ||
_contextMenus.Clear(); | ||
_contextMenus.Add(contextMenu); | ||
StateHasChanged(); | ||
} | ||
|
||
public void CloseAll() | ||
{ | ||
_contextMenus.Clear(); | ||
StateHasChanged(); | ||
} | ||
|
||
private void HandleLocationChanged(object sender, LocationChangedEventArgs args) | ||
{ | ||
CloseAll(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (_navigationManager != null) | ||
_navigationManager.LocationChanged -= HandleLocationChanged; | ||
} | ||
if (_navigationManager != null) | ||
_navigationManager.LocationChanged -= HandleLocationChanged; | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
src/AstroPanda.Blazor.Toolkit/Extensions/ServiceCollectionExtensions.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
5 changes: 2 additions & 3 deletions
5
src/AstroPanda.Blazor.Toolkit/Services/ContextMenu/ContextMenuReference.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
5 changes: 2 additions & 3 deletions
5
src/AstroPanda.Blazor.Toolkit/Services/ContextMenu/ContextMenuService.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
2 changes: 1 addition & 1 deletion
2
src/AstroPanda.Blazor.Toolkit/Services/ContextMenu/IContextMenuReference.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
2 changes: 1 addition & 1 deletion
2
src/AstroPanda.Blazor.Toolkit/Services/ContextMenu/IContextMenuService.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
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
2 changes: 1 addition & 1 deletion
2
src/AstroPanda.Blazor.Toolkit/Services/PeristentStateService.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
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