Toast

TsgcHTMLComponent_Toast — Delphi、C++ Builder、.NET で、タイトル、本文、タイムスタンプ、色、自動非表示を備え、位置指定されたコンテナによって画面に配置される Bootstrap 5 トースト通知をレンダリングします。

TsgcHTMLComponent_Toast

Bootstrap 5 の toast マークアップを出力するトーストコンポーネントです。タイトル、本文、色を設定してから、HTML プロパティを読み取ります — または、静的な Build ヘルパーを呼び出し、位置指定された BuildContainer でトーストを包みます。

コンポーネントクラス

TsgcHTMLComponent_Toast

レンダリング内容

Bootstrap 5 のトーストマークアップ

言語

Delphi, C++ Builder, .NET

一行で構築するか、完全に設定する

手軽なトーストには Build(title, body, color, timestamp) を呼び出して BuildContainer(toasts, position) で包むか、コンポーネントを作成して AutoHideDelay を設定してから、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

主なプロパティとメソッド

最もよく使うメンバーです。

Content

Title はヘッダーテキストを、Body はメッセージを、Timestamp は小さな時刻ラベルを、Icon はタイトルの前のインラインアイコンを設定します。

Color

ColorStyleTsgcHTMLColorhcSuccesshcDanger など)を取ります。Color は生の Bootstrap カラー名の文字列を受け取ります。

Auto-hide

AutoHide は、Delay ミリ秒(既定値 5000)後にトーストを自動的に閉じます。固定したままにするには AutoHideFalse に設定します。

Identity

ToastID は要素 id を割り当て、JavaScript から特定のトーストを表示または非表示にできるようにします。

Static helpers

Build(title, body, color, timestamp) は 1 つのトーストを返します。BuildContainer(toasts, position) は、それらを固定された toast-containerTsgcHTMLToastPosition)で包みます。

Output

HTML は完全な Bootstrap トーストのマークアップを返します — そのまま配信するか、ページテンプレートの BodyContent に割り当てます。

さらに詳しく

すべての sgcHTML コンポーネント60 以上のコンポーネントの全機能マトリックスを閲覧できます。
無料体験版のダウンロード30 日間の体験版には 60.HTML デモプロジェクトが付属します。
価格完全なソースコード付きの Single、Team、Site ライセンス。

始める準備はできましたか?

無料体験版をダウンロードして、Delphi、C++ Builder、.NET で Web UI の構築を始めましょう。