-
Notifications
You must be signed in to change notification settings - Fork 467
[dev-v5] Add Toast #4584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[dev-v5] Add Toast #4584
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5ef0f8f
Initial Toast work
vnbaaij 692ab4e
Merge
vnbaaij deab381
Make it work with toast service
vnbaaij bf4f316
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij 75f495f
Big refactor. Use a FluentToast and FluentProgressToast as component …
vnbaaij 0ab98a5
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij 7a85d82
Refactoring again
vnbaaij de285b1
Make dismiss use close action
vnbaaij 623740e
Fix closing animation
vnbaaij 0a247af
Fix layout, styling and animations
vnbaaij 0b3f017
Implement action calbacks, add close reason, remove ToastResult, rena…
vnbaaij d6a5275
Implement queueing
vnbaaij 82c6326
Add more tests, some small refactoring
vnbaaij cc4fee6
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij c5b99d3
Add more tests, add xml comments, process Copilot review comments
vnbaaij 09ed468
Merge branch 'users/vnbaaij/dev-v5/toast-part1' of https://github.com…
vnbaaij efda6fc
Rename and remove parameters, adjust tests
vnbaaij c2b270e
Process Copilot recommendation
vnbaaij 77c6836
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij 9c65808
Finalize work, add docs and examples
vnbaaij 904ad41
Update tests
vnbaaij 934beb5
Added 1 new test and removed 1 obsolete test
vnbaaij 1bb96d8
Process Copilot comments
vnbaaij 57171c8
- Add `Inverted` parameter wit example, tests and docs
vnbaaij 6da5e66
Add and fix test
vnbaaij f731ac2
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
dvoituron affe63d
Delete AssemblyInfo.cs
vnbaaij 603533a
Use LibraryConfig for ToastProvider settings
vnbaaij 7549795
Remove a couple of toast now that provider doesn't have parameters an…
vnbaaij 0a23f74
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij 212f8ad
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij 252302d
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/toast-part1
vnbaaij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 88 additions & 19 deletions
107
...ples/Demo/FluentUI.Demo.Client/Documentation/Components/Toast/DebugPages/DebugToast.razor
This file contains hidden or 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 |
|---|---|---|
| @@ -1,32 +1,101 @@ | ||
| @page "/Toast/Debug/Service" | ||
| @page "/Toast/Debug/Service" | ||
| @inject IToastService ToastService | ||
|
|
||
| <FluentButton OnClick="@OpenToastAsync" | ||
| Appearance="ButtonAppearance.Primary"> | ||
| Open Toast | ||
| </FluentButton> | ||
| <FluentStack Orientation="Orientation.Vertical" VerticalGap="12"> | ||
| <FluentStack> | ||
| <FluentButton OnClick="@OpenToastAsync" Appearance="ButtonAppearance.Primary"> | ||
| Open confirmation toast | ||
| </FluentButton> | ||
| <FluentButton OnClick="@OpenDismissableToastAsync" Appearance="ButtonAppearance.Outline"> | ||
| Open communication toast | ||
| </FluentButton> | ||
| <FluentButton OnClick="@OpenProgressToastAsync" Appearance="ButtonAppearance.Subtle"> | ||
| Open progress toast | ||
| </FluentButton> | ||
| <FluentButton OnClick="@OpenProgressToast2Async" Appearance="ButtonAppearance.Subtle"> | ||
| Open determinate progress toast | ||
| </FluentButton> | ||
| </FluentStack> | ||
|
|
||
| <div style="font-size: var(--fontSizeBase200); color: var(--colorNeutralForeground2);"> | ||
| Last result: @_lastResult | ||
| </div> | ||
| </FluentStack> | ||
|
|
||
| @code | ||
| { | ||
| private async Task OpenToastAsync() | ||
| { | ||
| var result = await ToastService.ShowToastAsync<DebugToastContent>(options => | ||
| private string _lastResult = "(none)"; | ||
|
|
||
| private async Task OpenDismissableToastAsync() | ||
| { | ||
| var result = await ToastService.ShowToastAsync<FluentToast>(options => | ||
| { | ||
| options.Timeout = 70000; | ||
| options.Parameters[nameof(FluentToast.Intent)] = ToastIntent.Warning; | ||
| options.Parameters[nameof(FluentToast.Title)] = "Delete item?"; | ||
| options.Parameters[nameof(FluentToast.Body)] = "This action can't be undone."; | ||
| options.Parameters[nameof(FluentToast.QuickAction1)] = "Delete"; | ||
| options.Parameters[nameof(FluentToast.QuickAction2)] = "Cancel"; | ||
| options.Parameters[nameof(FluentToast.ShowDismissButton)] = true; | ||
| options.OnStateChange = (e) => | ||
| { | ||
| Console.WriteLine($"State changed: {e.State}"); | ||
| }; | ||
| }); | ||
|
|
||
| _lastResult = result.Cancelled ? "Confirmation: Cancelled" : "Confirmation: Ok"; | ||
| } | ||
|
|
||
| private async Task OpenToastAsync() | ||
| { | ||
| options.Parameters.Add(nameof(DebugToastContent.Name), "John"); | ||
| var result = await ToastService.ShowToastAsync<FluentToast>(options => | ||
| { | ||
| options.Timeout = 70000; | ||
| options.Parameters[nameof(FluentToast.Intent)] = ToastIntent.Info; | ||
| options.Parameters[nameof(FluentToast.Title)] = "Email sent"; | ||
| options.Parameters[nameof(FluentToast.Body)] = "Your message was delivered."; | ||
| options.Parameters[nameof(FluentToast.Subtitle)] = "Just now"; | ||
| options.Parameters[nameof(FluentToast.QuickAction1)] = "Undo"; | ||
| options.Parameters[nameof(FluentToast.QuickAction2)] = "Dismiss"; | ||
| options.Parameters[nameof(FluentToast.ShowDismissButton)] = false; | ||
| }); | ||
|
|
||
| options.OnStateChange = (e) => | ||
| { | ||
| Console.WriteLine($"State changed: {e.State}"); | ||
| }; | ||
| }); | ||
| _lastResult = result.Cancelled ? "Communication: Cancelled" : "Communication: Ok"; | ||
| } | ||
|
|
||
| if (result.Cancelled) | ||
| private async Task OpenProgressToastAsync() | ||
| { | ||
| Console.WriteLine($"Toast Canceled: {result.Value}"); | ||
| var result = await ToastService.ShowToastAsync<FluentProgressToast>(options => | ||
| { | ||
| options.Timeout = 0; | ||
| options.Parameters[nameof(FluentProgressToast.Intent)] = ToastIntent.Info; | ||
| options.Parameters[nameof(FluentProgressToast.Title)] = "Uploading"; | ||
| options.Parameters[nameof(FluentProgressToast.Body)] = "Please wait while your files are uploaded."; | ||
| options.Parameters[nameof(FluentProgressToast.Status)] = "Uploading 3 files..."; | ||
| options.Parameters[nameof(FluentProgressToast.Indeterminate)] = true; | ||
| options.Parameters[nameof(FluentProgressToast.QuickAction1)] = "Hide"; | ||
| options.Parameters[nameof(FluentProgressToast.QuickAction2)] = "Cancel"; | ||
| options.Parameters[nameof(FluentProgressToast.ShowDismissButton)] = false; | ||
| }); | ||
|
|
||
| _lastResult = result.Cancelled ? "Progress: Cancelled" : "Progress: Ok"; | ||
| } | ||
| else | ||
|
|
||
| private async Task OpenProgressToast2Async() | ||
| { | ||
| Console.WriteLine($"Toast Confirmed: {result.Value}"); | ||
| var result = await ToastService.ShowToastAsync<FluentProgressToast>(options => | ||
| { | ||
| options.Timeout = 0; | ||
| options.Parameters[nameof(FluentProgressToast.Intent)] = ToastIntent.Info; | ||
| options.Parameters[nameof(FluentProgressToast.Title)] = "Uploading"; | ||
| options.Parameters[nameof(FluentProgressToast.Body)] = "Please wait while your files are uploaded."; | ||
| options.Parameters[nameof(FluentProgressToast.Status)] = "Uploading 3 files..."; | ||
| options.Parameters[nameof(FluentProgressToast.Indeterminate)] = false; | ||
| options.Parameters[nameof(FluentProgressToast.QuickAction1)] = "Hide"; | ||
| options.Parameters[nameof(FluentProgressToast.QuickAction2)] = "Cancel"; | ||
| options.Parameters[nameof(FluentProgressToast.ShowDismissButton)] = false; | ||
| }); | ||
|
|
||
| _lastResult = result.Cancelled ? "Progress: Cancelled" : "Progress: Ok"; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
1 change: 1 addition & 0 deletions
1
...emo/FluentUI.Demo.Client/Documentation/Components/Toast/Examples/FluentToastDefault.razor
This file contains hidden or 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 @@ | ||
| | ||
25 changes: 25 additions & 0 deletions
25
examples/Demo/FluentUI.Demo.Client/Documentation/Components/Toast/FluentToast.md
This file contains hidden or 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,25 @@ | ||
| --- | ||
| title: Toast | ||
| route: /Toast | ||
| category: 20|Components | ||
| icon: FoodToast | ||
| --- | ||
|
|
||
| # Toast | ||
|
|
||
| The `FluentToast` component is a temporary notification that appears on the edge of the screen. | ||
|
|
||
| To display the `FluentToast` component, you need to set the `Opened` parameter to `true`. | ||
| This parameter is bindable, so you can control the visibility of the `FluentToast` from your code. | ||
|
|
||
| ## Examples | ||
|
|
||
|
|
||
| ### Default | ||
|
|
||
| {{ FluentToastDefault }} | ||
|
|
||
| ## API Documentation | ||
|
|
||
| {{ API Type=FluentToast }} | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.