Snackbar

TsgcHTMLComponent_Snackbar — Delphi、C++ Builder、.NET で、任意のアクションリンク、色、画面位置、自動非表示を備えた Material スタイルの一時的なスナックバーをレンダリングします。

TsgcHTMLComponent_Snackbar

スコープ付き CSS と位置指定されたマークアップブロックを出力するスナックバーコンポーネントです。メッセージ、色、位置を設定してから、HTML プロパティを読み取ります — または、静的な Build ヘルパーを呼び出して一行で記述します。

コンポーネントクラス

TsgcHTMLComponent_Snackbar

レンダリング内容

スコープ付き CSS + スナックバーマークアップ

言語

Delphi, C++ Builder, .NET

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

手軽なスナックバーには Build(message, color, actionText, position) を呼び出すか、コンポーネントを作成して ActionHrefAutoHideDelay を設定してから、HTML を読み取ります。

uses
  sgcHTML_Enums, sgcHTML_Component_Snackbar;

// One-line static helper (primary form):
var
  vHTML: string;
begin
  vHTML := TsgcHTMLComponent_Snackbar.Build('Message sent.',
    hcSuccess, 'Undo', sbBottomRight);
  WebModule.Response := vHTML;
end;

// Or configure it fully:
var
  oSB: TsgcHTMLComponent_Snackbar;
begin
  oSB := TsgcHTMLComponent_Snackbar.Create(nil);
  try
    oSB.Message := 'Message sent.';
    oSB.Color := hcSuccess;
    oSB.Position := sbBottomRight;
    oSB.ActionText := 'Undo';
    oSB.ActionHref := '/undo';
    oSB.AutoHide := True;
    oSB.Delay := 4000;

    WebModule.Response := oSB.HTML;   // scoped CSS + snackbar markup
  finally
    oSB.Free;
  end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Snackbar.hpp

// One-line static helper (primary form):
String html = TsgcHTMLComponent_Snackbar::Build("Message sent.",
  hcSuccess, "Undo", sbBottomRight);

// Or configure it fully:
TsgcHTMLComponent_Snackbar *oSB = new TsgcHTMLComponent_Snackbar(NULL);
try
{
  oSB->Message = "Message sent.";
  oSB->Color = hcSuccess;
  oSB->Position = sbBottomRight;
  oSB->ActionText = "Undo";
  oSB->ActionHref = "/undo";
  oSB->AutoHide = true;
  oSB->Delay = 4000;

  String html = oSB->HTML;   // scoped CSS + snackbar markup
}
__finally
{
  delete oSB;
}
using esegece.sgcWebSockets;

// One-line static helper (primary form):
string html = TsgcHTMLComponent_Snackbar.Build("Message sent.",
    TsgcHTMLColor.hcSuccess, "Undo", TsgcHTMLSnackbarPosition.sbBottomRight);

// Or configure it fully:
var sb = new TsgcHTMLComponent_Snackbar();
sb.Message = "Message sent.";
sb.Color = TsgcHTMLColor.hcSuccess;
sb.Position = TsgcHTMLSnackbarPosition.sbBottomRight;
sb.ActionText = "Undo";
sb.ActionHref = "/undo";
sb.AutoHide = true;
sb.Delay = 4000;

string html = sb.HTML;   // scoped CSS + snackbar markup

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

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

Content

Message はスナックバーに表示されるテキストです。SnackbarID は、JavaScript からそれを閉じるために使われる要素 id を割り当てます。

Action

ActionText は末尾のアクションボタンを追加します。ActionHref を設定するとリンクになり、設定しない場合はクリックでスナックバーが閉じます。

Color

ColorTsgcHTMLColor(既定値 hcDark)を取り、スナックバーの背景に色を付けます。

Position

Position は、sbBottomsbTopsbBottomLeftsbBottomRightsbTopLeftsbTopRightTsgcHTMLSnackbarPosition)でそれを配置します。

Auto-hide

AutoHide は、出力されるタイムアウトスクリプトを介して、Delay ミリ秒(既定値 4000)後にスナックバーを取り除きます。

Static helper & output

Build(message, color, actionText, position) はすぐに使えるスナックバーを返します。HTML は、スコープ付き CSS、スライドインのマークアップ、自動非表示スクリプトを出力します。

さらに詳しく

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

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

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