Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/BootstrapBlazor.Server/Components/Components/MaskDemo.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div style="background-color: #ffffff" class="row">
<div class="col-12">
<h3>MaskDemo</h3>
</div>
<div class="col-12">
<Button Text="Close" OnClick="() => { OnCloseAsync?.Invoke(); }"></Button>
</div>
</div>
@code {
[CascadingParameter]
private Func<Task>? OnCloseAsync { get; set; }
}
4 changes: 4 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Masks.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@
<Mask @ref="CustomMask1"></Mask>
<Mask @ref="CustomMask2"></Mask>
</DemoBlock>

<DemoBlock Title="代码关闭弹窗">
<Button Text="Show" OnClick="ShowCloseMask"></Button>
</DemoBlock>
8 changes: 8 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Masks.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ await MaskService.Show(new MaskOption()
await MaskService.Close(CustomMask1);
await MaskService.Close(CustomMask2);
}

private async Task ShowCloseMask()
{
await MaskService.Show(new MaskOption()
{
ChildContent = BootstrapDynamicComponent.CreateComponent<MaskDemo>().Render()
});
}
}
4 changes: 3 additions & 1 deletion src/BootstrapBlazor/Components/Mask/Mask.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
@if (_options is { ChildContent: not null })
{
<div class="bb-mask-content">
@_options.ChildContent
<CascadingValue Value="CloseAsync" IsFixed="true">
@_options.ChildContent
</CascadingValue>
</div>
}
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/BootstrapBlazor/Components/Mask/Mask.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ private Task Show(MaskOption? option)
StateHasChanged();
return Task.CompletedTask;
}

private Task CloseAsync()
{
return Show(null);
}
}
Loading