-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allows showing a dialog by only providing a RenderFragment. (#1496
) * feat: allows showing a dialog by only providing a RenderFragment. * Fix PR comments. * Added a unit test for the dialog service to show a dialog based on a RenderFragment. * Updated the RenderFragment dialog example to demonstrate data binding. --------- Co-authored-by: Vincent Baaij <[email protected]>
- Loading branch information
1 parent
b2578b2
commit 144c17e
Showing
8 changed files
with
113 additions
and
2 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
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
23 changes: 23 additions & 0 deletions
23
examples/Demo/Shared/Pages/Dialog/Examples/RenderFragmentAsDialog.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@inject IDialogService _dialogService | ||
|
||
<FluentButton OnClick="OpenDialog" Appearance="Appearance.Accent">Open dialog</FluentButton> | ||
|
||
@code { | ||
private async Task OpenDialog() | ||
{ | ||
var text = string.Empty; | ||
var dialogInstance = await _dialogService.ShowDialogAsync(@<div> | ||
<FluentTextField @bind-Value=text Label="Enter a value:" /> | ||
</div> | ||
, new DialogParameters | ||
{ | ||
Title = "Render Fragment Content", | ||
}); | ||
|
||
var result = await dialogInstance.Result; | ||
if (!result.Cancelled) | ||
{ | ||
await _dialogService.ShowSuccessAsync($"You entered: {text}", "Success"); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Core/Components/Dialog/ContentComponents/RenderFragmentDialog.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@implements IDialogContentComponent<RenderFragment> | ||
|
||
@Content | ||
|
||
@code { | ||
[Parameter, EditorRequired] | ||
public required RenderFragment Content { get; set; } | ||
} |
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
20 changes: 20 additions & 0 deletions
20
tests/Core/Dialog/FluentDialogServiceTests.FluentDialog_RenderFragment.verified.razor.html
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
<fluent-dialog id="xxx" class="fluent-dialog-main prevent-scroll" style="position: absolute; z-index: 999; top: 50%; left: 50%; --dialog-width: 500px; --dialog-height: unset;" modal="true" trap-focus="true" blazor:ondialogdismiss="1" b-dsxskpj5rr="" blazor:elementreference=""> | ||
<div class="stack-horizontal fluent-dialog-header" style="justify-content: start; align-items: start; column-gap: 10px; row-gap: 10px; width: 100%;" b-0nr62qx0mz=""> | ||
<div style="width: 100%;"> | ||
<h4 typo="pane-header" class="fluent-typography" b-1nnnfjehkp="">Render Fragment Example</h4> | ||
</div> | ||
<fluent-button type="button" aria-label="Close" title="Close" appearance="stealth" blazor:onclick="2" b-x1200685t0="" blazor:elementreference="xxx"> | ||
<svg style="width: 16px; fill: var(--accent-fill-rest);" focusable="false" viewBox="0 0 24 24" aria-hidden="true" blazor:onclick="5"> | ||
<path d="m4.4 4.55.07-.08a.75.75 0 0 1 .98-.07l.08.07L12 10.94l6.47-6.47a.75.75 0 1 1 1.06 1.06L13.06 12l6.47 6.47c.27.27.3.68.07.98l-.07.08a.75.75 0 0 1-.98.07l-.08-.07L12 13.06l-6.47 6.47a.75.75 0 0 1-1.06-1.06L10.94 12 4.47 5.53a.75.75 0 0 1-.07-.98l.07-.08-.07.08Z"></path> | ||
</svg> | ||
</fluent-button> | ||
</div> | ||
<div> | ||
This is from a render fragment | ||
</div> | ||
<div class="stack-horizontal fluent-dialog-footer" style="justify-content: end; align-items: end; column-gap: 10px; row-gap: 10px; width: 100%;" b-0nr62qx0mz=""> | ||
<fluent-button type="button" aria-label="OK" title="OK" appearance="accent" blazor:onclick="3" b-x1200685t0="" blazor:elementreference="xxx">OK</fluent-button> | ||
<fluent-button type="button" aria-label="Cancel" title="Cancel" appearance="neutral" blazor:onclick="4" b-x1200685t0="" blazor:elementreference="xxx">Cancel</fluent-button> | ||
</div> | ||
</fluent-dialog> |
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