Snackbar
TsgcHTMLComponent_Snackbar — renderiza un snackbar transitorio estilo Material con un enlace de acción opcional, color, posición en pantalla y ocultación automática, en Delphi, C++ Builder y .NET.
TsgcHTMLComponent_Snackbar — renderiza un snackbar transitorio estilo Material con un enlace de acción opcional, color, posición en pantalla y ocultación automática, en Delphi, C++ Builder y .NET.
Un componente snackbar que emite CSS con ámbito más un bloque de marcado posicionado. Define el mensaje, el color y la posición, y luego lee la propiedad HTML — o llama al ayudante estático Build para una sola línea.
TsgcHTMLComponent_Snackbar
CSS con ámbito + marcado del snackbar
Delphi, C++ Builder, .NET
Llama a Build(message, color, actionText, position) para un snackbar rápido, o crea el componente, define ActionHref, AutoHide y Delay, y luego lee 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
Los miembros que más vas a usar.
Message es el texto que se muestra en el snackbar; SnackbarID asigna el id del elemento usado para descartarlo desde JavaScript.
ActionText añade un botón de acción al final; define ActionHref para convertirlo en un enlace, de lo contrario descarta el snackbar al hacer clic.
Color toma un TsgcHTMLColor (por defecto hcDark) y tiñe el fondo del snackbar.
Position lo coloca con sbBottom, sbTop, sbBottomLeft, sbBottomRight, sbTopLeft o sbTopRight (TsgcHTMLSnackbarPosition).
AutoHide elimina el snackbar tras Delay milisegundos (por defecto 4000) mediante un script de timeout emitido.
Build(message, color, actionText, position) devuelve un snackbar listo; HTML emite el CSS con ámbito, el marcado de entrada deslizante y el script de ocultación automática.