Skip to content

Commit

Permalink
Added new Show methods without title parameter (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissainty authored Oct 2, 2023
1 parent 671cd33 commit 91ea15a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Blazored.Modal/BlazoredModalInstance.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ else
@if (!HideHeader)
{
<div class="bm-header">
<h3 class="bm-title">@Title</h3>
@if (!string.IsNullOrWhiteSpace(Title))
{
<h3 class="bm-title">@Title</h3>
}
@if (!HideCloseButton)
{
<button type="button" class="bm-close" aria-label="close" @onclick="() => CancelAsync()" @attributes="@_closeBtnAttributes">
<button type="button" class="bm-close" aria-label="close" @onclick="() => CancelAsync()" @attributes="@_closeBtnAttributes">
<span>&times;</span>
</button>
}
Expand Down
20 changes: 20 additions & 0 deletions src/Blazored.Modal/Services/IModalService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ public interface IModalService
/// Shows a modal containing the specified <typeparamref name="TComponent"/>.
/// </summary>
IModalReference Show<TComponent>() where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="options"/>.
/// </summary>
/// <param name="options">Options to configure the modal.</param>
IModalReference Show<TComponent>(ModalOptions options) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="parameters"/>.
/// </summary>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
IModalReference Show<TComponent>(ModalParameters parameters) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="parameters"/>
/// and <paramref name="options"/>.
/// </summary>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
IModalReference Show<TComponent>(ModalParameters parameters, ModalOptions options) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="title"/> .
Expand Down
23 changes: 23 additions & 0 deletions src/Blazored.Modal/Services/ModalService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ public class ModalService : IModalService
public IModalReference Show<T>() where T : IComponent
=> Show<T>(string.Empty, new ModalParameters(), new ModalOptions());

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="options"/>.
/// </summary>
/// <param name="options">Options to configure the modal.</param>
public IModalReference Show<TComponent>(ModalOptions options) where TComponent : IComponent
=> Show<TComponent>("", new ModalParameters(), options);

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="parameters"/>.
/// </summary>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
public IModalReference Show<TComponent>(ModalParameters parameters) where TComponent : IComponent
=> Show<TComponent>("", parameters, new ModalOptions());

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="parameters"/>
/// and <paramref name="options"/>.
/// </summary>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
public IModalReference Show<TComponent>(ModalParameters parameters, ModalOptions options) where TComponent : IComponent
=> Show<TComponent>("", parameters, options);

/// <summary>
/// Shows the modal with the component type using the specified title.
/// </summary>
Expand Down

0 comments on commit 91ea15a

Please sign in to comment.