tobento/js-notifier 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tobento/js-notifier

最新稳定版本:1.0.1

Composer 安装命令:

composer require tobento/js-notifier

包简介

Simple JavaScript notifier to show notifications.

README 文档

README

Simple JavaScript notifier to show notifications.

Table of Contents

Getting started

Browser support

Modern browser only.

Documentation

Basic Usage

1. Include CSS/JS

<link href="notifier.css" rel="stylesheet" type="text/css">

2. Import Notifier And Send A Notification

import notifier from "notifier.js";

const notification = notifier.send({
    status: 'success',
    title: 'Lorem',
    text: 'Lorem ipsum.',
});

Parameters

Parameter Value Description
action {title: "View ...", url: "https://example.com/slug", classes: ["button"]} You may set an action displayed using an a element.
autotimeout 5000, null If defined, the notification will be closed after the milliseconds passed.
classes ["notification", "notification-fade"] You may set custom CSS classes to the notification element.
icon "<svg ... /></svg>" You may add a custom icon.
id "ID" A unique notification id.
removeDelay 500 Milliseconds after the notification will be removed. You may change this value if you have a custom animation, other than fade in and out.
showCloseButton false If false close button will not be displayed at all.
showIcon false If false icon will not be displayed at all.
stack "name" A stack name. See stack section to learn more.
status "success", "error", "warning", "info" The notification status.
text "Lorem ipsum" A text to be displayed.
title "Lorem" A title to be displayed.

All parameters are optional but you must specify title or text at least.

Methods

import notifier from "notifier.js";

const notification = notifier.send({
    status: 'success',
    title: 'Lorem',
    autotimeout: null,
});

// close after 2000 milliseconds:
notification.close(2000);

Stacks

By default, notifications will be pushed to the default stack which will be positioned top right. You may create more stacks by the following way:

1. Create the CSS class

Name your class like .notification-stack-stack-name:

.notification-stack-secondary {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 50;
  width: 400px;
}

2. Define the stack within you notifiaction

import notifier from "notifier.js";

const notification = notifier.send({
    stack: 'secondary',
    title: 'Lorem',
});

Credits

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-28