NetcodeHub.Packages.Components.Modal
1.0.1
dotnet add package NetcodeHub.Packages.Components.Modal --version 1.0.1
NuGet\Install-Package NetcodeHub.Packages.Components.Modal -Version 1.0.1
<PackageReference Include="NetcodeHub.Packages.Components.Modal" Version="1.0.1" />
paket add NetcodeHub.Packages.Components.Modal --version 1.0.1
#r "nuget: NetcodeHub.Packages.Components.Modal, 1.0.1"
// Install NetcodeHub.Packages.Components.Modal as a Cake Addin #addin nuget:?package=NetcodeHub.Packages.Components.Modal&version=1.0.1 // Install NetcodeHub.Packages.Components.Modal as a Cake Tool #tool nuget:?package=NetcodeHub.Packages.Components.Modal&version=1.0.1
Install the package
*NetcodeHub.Packages.Components.Modal *
Add JS reference to the application's App.razor file
*<script src="_content/NetcodeHub.Packages.Components.Modal/modal.js"></script>*
Add Namespace
*@using NetcodeHub.Packages.Components.Modal*
<button class="btn btn-info" @onclick="ShowConfirmation">Show Confirmation</button>
<br />
Confirmation : @Confirm
Use the Confirmation Component**
<NetcodeHubConfirmation @ref="confirmation"
Instruction="@Instruction"
Action="Handle"
BootstrapClass="border-danger"
CustomStyle="width:300px;" />
@code
{
// Confirmation Modal Component
NetcodeHubConfirmation confirmation;
public bool Confirm { get; set; }
string Instruction = "Are you sure you wanna do this?";
async Task Handle()
{
Confirm = true;
await Close();
}
async Task Open() => await confirmation.OpenConfirmation();
async Task Close() => await confirmation!.CloseConfirmation();
}
Use the Modal Component**
<button class="btn btn-success mt-3" @onclick="OpenModal">Open modal</button>
<br />
<NetcodeHubModal @bind-Open="IsOpen"
Actions="ButtonActions"
BootstrapClass="border-success rounded p-2 ml-2 mr-2"
CustomStyle="min-width:300px; max-width:500px;">
<ContentTemplate>
<div class="card ">
<div class="card-header">Modal Header</div>
<div class="card-body">
<p class="text-muted">
The component was built using modal dialog. We are manipulating it using CSS and JS,
This element provides what we want to display a modal and get a return value of type string.
</p>
</div>
</div>
</ContentTemplate>
<ButtonTemplate>
<div class="card border-0">
<div class="card-body">
<div class="d-flex justify-content-center align-content-center">
<button class="btn btn-danger" value="cancel">Cancel</button>
<button class="btn btn-success" value="save" style="margin-left:10px">Save</button>
</div>
</div>
</div>
</ButtonTemplate>
</NetcodeHubModal>
@code{
// NetcodeHub Modal Component
public bool IsOpen { get; set; }
void OpenModal() => IsOpen = true;
void ButtonActions(string action)
{
if (action == "save")
{
// do something
OpenModal();
}
else if (action == "cancel")
{
// default will close the modal
// you can also do something
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Flexible and Customizable Modal Dialog:
Introduced a new modal dialog component for Blazor applications.
Allows developers to define both the content and buttons within the dialog.
Parameter-Based Control:
@bind-Open: Binds the modal's open state to a boolean property.
Actions: Defines actions to be taken when buttons within the modal are clicked.
BootstrapClass: Allows for Bootstrap-based styling with custom classes.
CustomStyle: Provides a way to apply custom CSS styles to the modal.
Content and Button Templates:
ContentTemplate: Allows developers to specify the content of the modal.
ButtonTemplate: Allows developers to define custom buttons within the modal.
Event Callbacks:
Supports event callbacks to handle actions such as opening and closing the modal, and button clicks.