2.0.1 • Published 1 year ago

alertforall v2.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

AlertforAll

Version: 2.0.1

Warning: it is not compatible with version 1.x.x

Github BUG or INFO

AlertforAll is a very lightweight library compatible with many javascript and typescript frameworks.

Installation

USING NPM:
$ npm install alertforall
USING YARN:
 $ yarn add alertforall

Starting

After installing the module as described above, you need to import it to your project.

import AlertforAll,{Alert,Toast} from 'alertforall'
const AlertforAll = require('alertforall') 

example

here is an example to show an alert with automatic closure

  import {Alert} from 'alertforall'

  Alert.type2({TitleMsg:'This is an Alert from AlertforAll'})

screen type1

or

  import {Alert} from 'alertforall'

  Alert.type2({TitleMsg:'Do you want to save?', Btn_Confirm:'Yes', Btn_Cancel:'No'})

screen type1

You can also call the function directly to perform some configurations
import AlertforAll from 'alertforall'

const setting = {
  isDark:true,
  buttonConfirmColor:'orange',
  buttonCancelColor:'aqua'
}

const Alert= AlertforAll(setting)

Alert.type2({TitleMsg:'Do you want to save?', Btn_Confirm:'Yes', Btn_Cancel:'No'})

Promises for slightly more advanced codes are also accepted.

AlertforAll(setting).type1({TitleMsg:'Do you want to save?', Btn_Confirm:'Yes', Btn_Cancel:'No'})
.then((response)=>{console.log(response)})
.catch((error)=>{console.log(response)})

Promises are currently only available for Alert types, and return boolean values ​​or strings as per type4.

screen type1

Toast

In addition to the Alerts we also show some very useful Toasts for mobile devices

import AlertforAll,{Toast} from 'alertforall'

AlertforAll(Setting).frame2({TitleMsg:'An error occurred, please try again later',Ico:'Error'})

alternative

import AlertforAll,{Toast} from 'alertforall'

Toast.frame2({TitleMsg:'An error occurred, please try again later',Ico:'Error'})

Toasts still don't accept promises

screen frame2

The different forms

NAMECALL METHODACCEPTED VALUESREQUIRED
type1()Alert.type1() or AlertforAll().type1()TitleMsg:string TextMsg:string Btn_Confirm:string Btn_Cancel:string Btn_Third:string(only android)TitleMsg: required Btn_Confirm & Btn_Cancel: not necessary, if missing activate the third button Btn_Third:only on android, it activates either as a third button or automatically as a single button.
type2()Alert.type2() or AlertforAll().type2()TitleMsg:string TextMsg:string Btn_Confirm:string Btn_Cancel:stringTitleMsg: required Btn_Confirm & Btn_Cancel: not necessary, if not present the default 3s automatic closing is activated.
type3()Alert.type3() or AlertforAll().type3()TitleMsg:string Btn_Cancel:string TextMsg:string Ico: 'Success','Error','Warning','Info','Question'TitleMsg: required Btn_Cancel: not necessary, if not present the default 3s automatic closing is activated. TextMsg:not necessary Ico:not neccessary, default 'success'
frame1()Toast.frame1() or AlertforAll().frame1()TitleMsg:stringTitleMsg: required
frame2()Toast.frame2() or AlertforAll().frame2()TitleMsg:string Ico:'Success','Error','Warning','Info'TitleMsg: required Ico:not neccessary, default 'Success'

The various settings

NAME SETTCALL METHODACCEPTED VALUESDEFAULT
delaytype2() type3() frame1() frame2()Number ms3000
devicetype1()'ios','android'android'
isDarktype1() type2() type3() frame1() frame2()Booleanfalse
positiontype2() type3()'top','center',bottom''top'
colortype2() type3() frame1()hex value '#000''#eee' or '#333'
textCancelColortype2() type2() type3()hex value '#000'#fff
textConfirmColortype2()hex value '#000'#fff
buttonConfirmColortype2()hex value '#000'#60b558
buttonCancelColortype2() type2() type3()hex value '#000#d86060
positionHorizontal positionVerticalframe1() frame2()'start''center''end''center 'end'
fontSizeframe1() frame2()string px '12px''14px'
fontWeightframe1() frame2()string number '600''500'
const object={
 delay:5000, // number-default 3000(3s)
 isDark:false, // boolean-default false
 position:'top', // 'top''center''bottom'-default 'center' 
 ... 
}

AlertforAll(object).prototype()  // with changes applied

AlertforAll().prototype() // standard without modifications

library created for personal projects but made available for other programmers.

Library written by Giacomo Mattina. First released version 6/29/2024

2.0.1

1 year ago

2.0.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago