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

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.

Clase de componente

TsgcHTMLComponent_Snackbar

Renderiza

CSS con ámbito + marcado del snackbar

Lenguajes

Delphi, C++ Builder, .NET

Créalo en una línea, o configúralo por completo

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

Propiedades y métodos clave

Los miembros que más vas a usar.

Contenido

Message es el texto que se muestra en el snackbar; SnackbarID asigna el id del elemento usado para descartarlo desde JavaScript.

Acción

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

Color toma un TsgcHTMLColor (por defecto hcDark) y tiñe el fondo del snackbar.

Posición

Position lo coloca con sbBottom, sbTop, sbBottomLeft, sbBottomRight, sbTopLeft o sbTopRight (TsgcHTMLSnackbarPosition).

Ocultación automática

AutoHide elimina el snackbar tras Delay milisegundos (por defecto 4000) mediante un script de timeout emitido.

Ayudante estático y salida

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.

Sigue explorando

Todos los componentes sgcHTMLExplora la matriz completa de más de 60 componentes.
Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos demo 60.HTML.
PreciosLicencias Single, Team y Site con código fuente completo.

¿Listo para empezar?

Descarga la prueba gratuita y empieza a crear interfaces web en Delphi, C++ Builder y .NET.