Snackbar
TsgcHTMLComponent_Snackbar — renderizza una snackbar transitoria in stile Material con un link di azione, colore, posizione sullo schermo e occultamento automatico opzionali, in Delphi, C++ Builder e .NET.
TsgcHTMLComponent_Snackbar — renderizza una snackbar transitoria in stile Material con un link di azione, colore, posizione sullo schermo e occultamento automatico opzionali, in Delphi, C++ Builder e .NET.
Un componente snackbar che emette CSS dedicato più un blocco di markup posizionato. Imposta il messaggio, il colore e la posizione, quindi leggi la proprietà HTML — oppure chiama l’helper statico Build per una soluzione a riga singola.
TsgcHTMLComponent_Snackbar
Scoped CSS + snackbar markup
Delphi, C++ Builder, .NET
Chiama Build(message, color, actionText, position) per una snackbar rapida, oppure crea il componente, imposta ActionHref, AutoHide e Delay, quindi leggi 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
I membri che utilizzerai più spesso.
Message è il testo mostrato nella snackbar; SnackbarID assegna l’id dell’elemento usato per chiuderla da JavaScript.
ActionText aggiunge un pulsante di azione finale; imposta ActionHref per renderlo un link, altrimenti chiude la snackbar al clic.
Color accetta un TsgcHTMLColor (predefinito hcDark) e colora lo sfondo della snackbar.
Position la colloca con sbBottom, sbTop, sbBottomLeft, sbBottomRight, sbTopLeft o sbTopRight (TsgcHTMLSnackbarPosition).
AutoHide rimuove la snackbar dopo Delay millisecondi (predefinito 4000) tramite uno script di timeout emesso.
Build(message, color, actionText, position) restituisce una snackbar pronta; HTML emette il CSS dedicato, il markup a scorrimento e lo script di occultamento automatico.