0.1.0 • Published 12 months ago

@mizuka/messagejs v0.1.0

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

alt text

šŸ”— Table of Contents


šŸ“ Overview

If you don't want to introduce the entire component library, but still need a simple page message prompt


šŸ‘¾ Features

  • Zero Dependencies
  • Pure Javascript
  • Lightweight
  • Easy to use

šŸ“ Project Structure

└── messagejs/
    ā”œā”€ā”€ LICENSE
    ā”œā”€ā”€ demo.ts
    ā”œā”€ā”€ doc
    │   └── vitepress.config.js
    ā”œā”€ā”€ index.html
    ā”œā”€ā”€ package.json
    ā”œā”€ā”€ pnpm-lock.yaml
    ā”œā”€ā”€ public
    │   └── vite.svg
    ā”œā”€ā”€ src
    │   ā”œā”€ā”€ const.ts
    │   ā”œā”€ā”€ index.ts
    │   ā”œā”€ā”€ style.ts
    │   ā”œā”€ā”€ typescript.svg
    │   └── vite-env.d.ts
    ā”œā”€ā”€ tsconfig.json
    └── vite.config.js

šŸš€ Getting Started

āš™ļø Installation

Install messagejs using one of the following methods:

Using npm Ā 

npm install @mizuka/messagejs --save

-Usage

Run messagejs using the following command: Using npm Ā 

import { Message } from "@mizuka/messagejs";

function showMessage(
  type: "success" | "error" | "info" | "warning" | "loading"
): Message {
  const result = Message[type](getMessage(), {
    showClose: isShowClose(),
  });
  return result;
}

OPTIONS

Property NameTypeDescription
messagestring | (() => string)The message text to be displayed. It can be a string or a function that returns a string.
typeMessageTypeThe type of the message. It can be one of the following: "success", "error", "info", "warning", "loading". The default value is "info".
iconstringThe SVG icon to be displayed. It should be a string representing the SVG code.
dangerouslyUseHTMLStringbooleanA boolean value indicating whether the message property should be treated as HTML. The default value is false.
customClassstringA string representing the custom class name to be added to the message container.
durationnumberThe duration for which the message should be displayed in milliseconds. If set to 0, the message will not auto-close. The default value is 3000.
showClosebooleanA boolean value indicating whether the close button should be displayed. The default value is false.
centerbooleanA boolean value indicating whether the message text should be centered. The default value is false.
onClose(instance: Message) => voidA callback function that is called when the message is closed. It takes the Message instance as a parameter.
offsetnumberThe offset from the top of the page where the message should be displayed. The default value is 40.
appendToHTMLElementThe HTML element where the message should be appended. The default value is document.body.

Other Example

if you want change the max size display of the message sametime, you can use the following code:

import { Message } from "@mizuka/messagejs";

Message.manager.max = 10; // default 3

if you want change the margin between messages , you can use the following code:

import { Message } from "@mizuka/messagejs";

Message.manager.margin = 8; // default 16

šŸ“Œ Project Roadmap

  • Task 1: basic implement

šŸ”° Contributing


šŸŽ— License

This project is protected under the MIT License. For more details, refer to the LICENSE file.


0.1.0

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago