JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q12021F
  • License MIT

A lightweight toast package in Js and CSS

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (toast-cg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Toast Class Documentation

    The Toast class is designed to create Neptune-style toasts, providing a visually appealing way to display messages on a web page. This documentation provides an overview of the class, its constructor, and usage examples.

    Class: Toast

    Description

    Create a new Neptune Toast with customizable configurations such as icon, message text, style, and position.

    Constructor

    javascriptCopy code

    const myToast = new Toast({ icon: "YOUR ICON", text: "Test Toast", style: "primary", position: "top-right" });

    Parameters

    • config (Object): An object containing the configuration options for the toast.

      • parent (String): (Optional) The class or id of the target element. If null, the toast will be appended to document.body.

      • icon (String): (Optional) The HTML or text content for the toast icon.

      • text (String): (Required) The message text to be displayed in the toast.

      • style (String): (Optional) The style of the toast, which can be one of the following: "primary", "accent", "information", "success", "warning", or "error".

      • position (String): (Optional) The position of the toast on the screen, which can be one of the following: "left-top", "left-bottom", "right-top", or "right-bottom".

    Example

    javascriptCopy code

    const myToast = new Toast({ icon: "YOUR ICON", text: "Test Toast", style: "primary", position: "top-right" });

    This example creates a new Toast instance with a specified icon, message text, style, and position.

    Toast Configuration

    • Icon: If an icon is provided, it will be displayed on the left side of the toast.

    • Message Text: The main content of the toast, displaying the message provided in the configuration.

    • Style: The style of the toast determines its appearance. Options include "primary", "accent", "information", "success", "warning", or "error".

    • Position: The position of the toast on the screen. Options include "left-top", "left-bottom", "right-top", or "right-bottom".

    Error Handling

    If the text parameter is not provided, an error message will be logged to the console, indicating that a message should be added to the toast.

    Usage

    To use the Toast class, instantiate it with a configuration object, specifying the desired icon, message text, style, and position. The toast will then be appended to the specified parent element or document.body if no parent is provided.