Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
yagizhanNY committed May 29, 2023
1 parent 7556438 commit 896446e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
6 changes: 4 additions & 2 deletions SiemensIXBlazor/Components/Toast/Toast.razor.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.JSInterop;
using Newtonsoft.Json;
using SiemensIXBlazor.Objects;

namespace SiemensIXBlazor.Components
{
public partial class Toast
{
public async void ShowToast(string message, string messageSeverity)
public async void ShowToast(ToastConfig config)
{
await JSRuntime.InvokeVoidAsync("showMessage", message, messageSeverity);
await JSRuntime.InvokeVoidAsync("showMessage", JsonConvert.SerializeObject(config));
}
}
}
24 changes: 24 additions & 0 deletions SiemensIXBlazor/Objects/ToastConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using Newtonsoft.Json;

namespace SiemensIXBlazor.Objects
{
public class ToastConfig
{
[JsonProperty("autoClose")]
public bool AutoClose { get; set; } = true;
[JsonProperty("autoCloseDelay")]
public int AutoCloseDelay { get; set; } = 5000;
[JsonProperty("icon")]
public string? Icon { get; set; }
[JsonProperty("iconColor")]
public string? IconColor { get; set; }
[JsonProperty("message")]
public string? Message { get; set; }
[JsonProperty("title")]
public string? Title { get; set; }
[JsonProperty("type")]
public string Type { get; set; } = "info";
}
}

8 changes: 3 additions & 5 deletions SiemensIXBlazor/SiemensIXBlazor_NpmJS/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { toast } from "@siemens/ix"
defineCustomElements();

// toast
window.showMessage = (message, type) => {
toast({
message: message,
type: type
});
window.showMessage = (config) => {
const toastConfig = JSON.parse(config);
toast(toastConfig);
}
2 changes: 1 addition & 1 deletion SiemensIXBlazor/wwwroot/js/siemens-ix/index.bundle.js

Large diffs are not rendered by default.

0 comments on commit 896446e

Please sign in to comment.