0.0.1 • Published 2 years ago

get-alert v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Get Alert

Installation

npm i get-alert

UsageExample

import OkPopup from 'get-alert';

function App(){

    return(
        <div>
        <OkPopup 
        heading={'success'}
        text={'alert text here'}
        fun={} 
        />
        </div>
    )
}

All Props

PropsUse
headingAlert Heading or Title
textAlert message text
funfunction to be executed on clicking ok
import AlertPopup from 'get-alert';

function App(){

    return(
        <div>
        <AlertPopup 
        heading={'success'}
        text={'alert text here'}
        btn_text={'Ok'}
        fun={} 
        cancel={} 
        />
        </div>
    )
}

All Props

PropsUse
headingAlert Heading or Title
textAlert message text
btn_texttext to be appear on the button
funfunction to be executed on clicking ok
cancelfunction to be executed on clicking cancel

One Example for Usage

import {useState} from 'react';
import AlertPopup from 'get-alert';

function App(){

    const [showAlert, set_ShowAlert] = useState(false);

    const ShowAlertPopup=()=>{
    set_ShowAlert(true);
    }

    return(
        <div>
        <button onClick={ShowAlertPopup()}>Show Alert </button>
        {showAlert?
        <AlertPopup 
        heading={'success'}
        text={'alert text here'}
        btn_text={'Ok'}
        fun={} 
        cancel={} 
        />
        :null}
        </div>
    )
}

Same Example for both the popups. Basically I have used conditional rendering here, as you can see there is a variable 'showAlert' if it becomes true then Alert will appear on the screen. But by default popup will not be appear at the center of the screen you have to style according to your use.

Author


THANK YOU