Skip to content

Commit 42e0445

Browse files
pmi24dvoituron
andauthored
[FluentToast] Add Class & Style properties (#4170)
* Add class parameter to FluentToast via ToastParameters * Add style parameter to FluentToast via ToastParameters * Remove access modifiers from interface properties --------- Co-authored-by: Denis Voituron <dvoituron@outlook.com>
1 parent af66f64 commit 42e0445

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/Core/Components/Toast/FluentToast.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@namespace Microsoft.FluentUI.AspNetCore.Components
66

77
<CascadingValue Value="this" IsFixed="true">
8-
<div class="fluent-toast" id="@Id" tabindex="0" >
8+
<div class="@Class" style="@Style" id="@Id" tabindex="0">
99
<FluentStack Orientation="Orientation.Horizontal" Width="100%" VerticalAlignment="VerticalAlignment.Center" HorizontalGap="8">
1010
@if (_parameters.Icon is not null)
1111
{
@@ -29,7 +29,7 @@
2929
break;
3030
case ToastTopCTAType.Action:
3131
<FluentAnchor title="@_parameters.TopAction"
32-
Href="#"
32+
Href="#"
3333
Style="font-size: 14px; font-weight:400;"
3434
Appearance="Appearance.Hypertext"
3535
@onfocusin="@PauseTimeout"
@@ -63,7 +63,7 @@
6363
@if (_parameters.SecondaryAction is not null)
6464
{
6565
<FluentAnchor title="@_parameters.SecondaryAction"
66-
Href="#"
66+
Href="#"
6767
Style="font-size: 14px; font-weight:400;"
6868
Appearance="Appearance.Hypertext"
6969
@onfocusin="@PauseTimeout"

src/Core/Components/Toast/FluentToast.razor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// ------------------------------------------------------------------------
44

55
using Microsoft.AspNetCore.Components;
6+
using Microsoft.FluentUI.AspNetCore.Components.Utilities;
67

78
namespace Microsoft.FluentUI.AspNetCore.Components;
89

@@ -23,6 +24,10 @@ public partial class FluentToast : FluentComponentBase, IDisposable
2324
protected override async Task OnInitializedAsync()
2425
{
2526
_parameters = Instance.Parameters;
27+
28+
Class = new CssBuilder("fluent-toast").AddClass(_parameters.Class).Build();
29+
Style = new StyleBuilder(_parameters.Style).Build();
30+
2631
ToastContext!.Register(this);
2732

2833
if (_parameters.Timeout.HasValue && _parameters.Timeout == 0)

src/Core/Components/Toast/Parameters/IToastParameters.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ public interface IToastParameters
1010
{
1111
string? Id { get; set; }
1212
ToastIntent Intent { get; set; }
13-
(Icon Value, Color Color)? Icon { get; set; }
1413
string? Title { get; set; }
1514

15+
(Icon Value, Color Color)? Icon { get; set; }
16+
string? Style { get; set; }
17+
string? Class { get; set; }
18+
1619
ToastTopCTAType TopCTAType { get; set; }
1720
string? TopAction { get; set; }
1821
EventCallback<ToastResult>? OnTopAction { get; set; }

src/Core/Components/Toast/Parameters/ToastParameters.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class ToastParameters : ComponentParameters, IToastParameters
1717
public EventCallback<ToastResult>? OnTopAction { get; set; } = default!;
1818

1919
public (Icon Value, Color Color)? Icon { get; set; }
20+
public string? Style { get; set; }
21+
public string? Class { get; set; }
22+
2023
public DateTime Timestamp { get; set; } = DateTime.Now;
2124
public int? Timeout { get; set; }
2225

0 commit comments

Comments
 (0)