21 lines
697 B
C#
21 lines
697 B
C#
namespace Htmx.ApiDemo.Templates.Components;
|
|
|
|
/// <summary>
|
|
/// Fixed viewport container for toast notifications.
|
|
/// Place once in the page (or layout). Toasts appear via window.showToast() from components.js.
|
|
/// </summary>
|
|
public sealed class ToastViewport : ToastViewportBase
|
|
{
|
|
private readonly byte[] _idData;
|
|
private readonly byte[] _toastsData;
|
|
|
|
public ToastViewport(string id = "toast-viewport")
|
|
{
|
|
_idData = id.ToUtf8Bytes();
|
|
_toastsData = [];
|
|
}
|
|
|
|
protected override void RenderId(HtmxRenderContext ctx) => ctx.Writer.WriteUtf8(_idData);
|
|
protected override void RenderToasts(HtmxRenderContext ctx) => ctx.Writer.WriteUtf8(_toastsData);
|
|
}
|