Toast
TsgcHTMLComponent_Toast — Delphi、C++ Builder、.NET で、タイトル、本文、タイムスタンプ、色、自動非表示を備え、位置指定されたコンテナによって画面に配置される Bootstrap 5 トースト通知をレンダリングします。
TsgcHTMLComponent_Toast — Delphi、C++ Builder、.NET で、タイトル、本文、タイムスタンプ、色、自動非表示を備え、位置指定されたコンテナによって画面に配置される Bootstrap 5 トースト通知をレンダリングします。
Bootstrap 5 の toast マークアップを出力するトーストコンポーネントです。タイトル、本文、色を設定してから、HTML プロパティを読み取ります — または、静的な Build ヘルパーを呼び出し、位置指定された BuildContainer でトーストを包みます。
TsgcHTMLComponent_Toast
Bootstrap 5 のトーストマークアップ
Delphi, C++ Builder, .NET
手軽なトーストには Build(title, body, color, timestamp) を呼び出して BuildContainer(toasts, position) で包むか、コンポーネントを作成して AutoHide と Delay を設定してから、HTML を読み取ります。
uses
sgcHTML_Enums, sgcHTML_Component_Toast;
// One-line static helper (primary form):
var
vToast: string;
begin
vToast := TsgcHTMLComponent_Toast.Build('Saved',
'Your changes were stored.', hcSuccess, 'just now');
WebModule.Response := TsgcHTMLComponent_Toast.BuildContainer(vToast,
tpTopEnd);
end;
// Or configure it fully:
var
oToast: TsgcHTMLComponent_Toast;
begin
oToast := TsgcHTMLComponent_Toast.Create(nil);
try
oToast.ToastID := 'saveToast';
oToast.Title := 'Saved';
oToast.Body := 'Your changes were stored.';
oToast.ColorStyle := hcSuccess;
oToast.Timestamp := 'just now';
oToast.AutoHide := True;
oToast.Delay := 4000;
WebModule.Response := oToast.HTML; // Bootstrap toast markup
finally
oToast.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Toast.hpp
// One-line static helper (primary form):
String toast = TsgcHTMLComponent_Toast::Build("Saved",
"Your changes were stored.", hcSuccess, "just now");
String html = TsgcHTMLComponent_Toast::BuildContainer(toast, tpTopEnd);
// Or configure it fully:
TsgcHTMLComponent_Toast *oToast = new TsgcHTMLComponent_Toast(NULL);
try
{
oToast->ToastID = "saveToast";
oToast->Title = "Saved";
oToast->Body = "Your changes were stored.";
oToast->ColorStyle = hcSuccess;
oToast->Timestamp = "just now";
oToast->AutoHide = true;
oToast->Delay = 4000;
String body = oToast->HTML; // Bootstrap toast markup
}
__finally
{
delete oToast;
}
using esegece.sgcWebSockets;
// One-line static helper (primary form):
string toast = TsgcHTMLComponent_Toast.Build("Saved",
"Your changes were stored.", TsgcHTMLColor.hcSuccess, "just now");
string html = TsgcHTMLComponent_Toast.BuildContainer(toast,
TsgcHTMLToastPosition.tpTopEnd);
// Or configure it fully:
var t = new TsgcHTMLComponent_Toast();
t.ToastID = "saveToast";
t.Title = "Saved";
t.Body = "Your changes were stored.";
t.ColorStyle = TsgcHTMLColor.hcSuccess;
t.Timestamp = "just now";
t.AutoHide = true;
t.Delay = 4000;
string body = t.HTML; // Bootstrap toast markup
最もよく使うメンバーです。
Title はヘッダーテキストを、Body はメッセージを、Timestamp は小さな時刻ラベルを、Icon はタイトルの前のインラインアイコンを設定します。
ColorStyle は TsgcHTMLColor(hcSuccess や hcDanger など)を取ります。Color は生の Bootstrap カラー名の文字列を受け取ります。
AutoHide は、Delay ミリ秒(既定値 5000)後にトーストを自動的に閉じます。固定したままにするには AutoHide を False に設定します。
ToastID は要素 id を割り当て、JavaScript から特定のトーストを表示または非表示にできるようにします。
Build(title, body, color, timestamp) は 1 つのトーストを返します。BuildContainer(toasts, position) は、それらを固定された toast-container(TsgcHTMLToastPosition)で包みます。
HTML は完全な Bootstrap トーストのマークアップを返します — そのまま配信するか、ページテンプレートの BodyContent に割り当てます。