Skip to content

Commit

Permalink
change namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Hope-Parnell committed Oct 28, 2024
1 parent a2b42a0 commit 2de9186
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 62 deletions.
4 changes: 3 additions & 1 deletion src/AstroPanda.Blazor.Toolkit/Components/ContextMenu.razor
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>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components;

namespace AstroPanda.Blazor.Toolkit.Components
namespace AstroPanda.Blazor.Toolkit
{
public partial class ContextMenu
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<CascadingValue Value="this" IsFixed="true">

@namespace AstroPanda.Blazor.Toolkit

<CascadingValue Value="this" IsFixed="true">
@foreach (var item in _contextMenus)
{
@item.Content
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using AstroPanda.Blazor.Toolkit.Services;
using BlazorComponentBus;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using AstroPanda.Blazor.Toolkit.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit;

public class ContextMenuReference : IContextMenuReference
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using AstroPanda.Blazor.Toolkit.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit;

public class ContextMenuService : IContextMenuService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit;

public interface IContextMenuReference
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit;

public interface IContextMenuService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit

public interface IPersistentStateService<T>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Blazored.LocalStorage;

namespace AstroPanda.Blazor.Toolkit.Services;
namespace AstroPanda.Blazor.Toolkit

public class PersistentStateService<T> : IPersistentStateService<T> where T: new()
{
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorToolkit.Wasm/Components/ExampleContextMenu.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using AstroPanda.Blazor.Toolkit.Services
@using AstroPanda.Blazor.Toolkit
<MudPaper>
<MudButton OnClick="Close">Close</MudButton>
</MudPaper>
Expand Down
2 changes: 0 additions & 2 deletions src/BlazorToolkit.Wasm/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@inherits LayoutComponentBase
@using AstroPanda.Blazor.Toolkit
@using AstroPanda.Blazor.Toolkit.Services
@using BlazorToolkit.Wasm.Components
@using AstroPanda.Blazor.Toolkit.Components
@using MudBlazor

<MyMudThemeProvider />
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorToolkit.Wasm/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/"
@using AstroPanda.Blazor.Toolkit.Components
@using AstroPanda.Blazor.Toolkit

<PageTitle>Home</PageTitle>

Expand Down

0 comments on commit 2de9186

Please sign in to comment.