7.0.0 • Published 3 days ago

cov-message-box v7.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

cov-message-box

COV Message Box component using Kendo React Dialog. Modelled after C# Message Box

NPM JavaScript Style Guide

Install

npm install --save cov-message-box

Properties

message

The message to be displayed. Can be plain text or formatted as HTML e.g. you can pass in

<h1>Are you sure?</h1>

title

The title displayed at the top of the message box

buttonsArray

An array of strings that are used to render the buttons

            buttonsArray={["Yes", "No", "Maybe", "Cancel"]}

onClose

The callback function to be called when the message box is closed

defaultButton

A string that must match one of the strings passed to buttonsArray. Will be rendered as a primary button

editorContentStyle

The message is displayed inside a kendo react editor component. This sets styles to the content element wrapper of the Editor.

editorStyle

Sets styles of the Editor.

dialogActionsBarStyle

Sets styles of the div around the DialogActionsBar For example to center all the buttons you can use this css

{ display: "flex", justifyContent: "center", alignContent: "center" }

width

The width of the message box

height

The height of the message box

Usage

import React, { useState } from "react";

import { MessageBox } from "cov-message-box";
import { Button } from "@progress/kendo-react-buttons";

function App() {
  const [displayMessageBox, setDisplayMessageBox] = useState(false);

  function onShowMessageBox(messageBoxResult) {
    setDisplayMessageBox(true);
  }
  function onMessageBoxClose(messageBoxResult) {
    setDisplayMessageBox(false);
    console.log(messageBoxResult);
    switch (messageBoxResult.toUpperCase()) {
      case "NO":
        //do your no logic
        alert("user picked NO");
        break;
      case "YES":
        //do your yes logic
        alert("user picked YES");
        break;

      default:
        alert(`ERROR. Not valid: ${messageBoxResult} `);
        break;
    }
  }

  return (
    <>
      <div>
        <Button id="cancel-btn" onClick={onShowMessageBox} className="ml-5 mt-5">
          Show Message Box
        </Button>
      </div>

      {displayMessageBox === true ? (
        <div>
          <MessageBox
            message={`Are you sure?`}
            title={"Confirm Your action"}
            buttonsArray={["Yes", "No", "Maybe", "Cancel"]}
            onClose={onMessageBoxClose}
            defaultButton={"Yes"}
            editorContentStyle={{ height: "100px" }}
            editorStyle={{ textAlign: "center" }}
          ></MessageBox>
        </div>
      ) : (
        ""
      )}
    </>
  );
}

export default App;

License

MIT © covnpmjs

7.1.0-beta.1

3 days ago

7.0.0

1 month ago

7.0.0-beta.2

2 months ago

6.0.1

4 months ago

6.0.0

4 months ago

6.0.0-beta.2

4 months ago

4.0.0-beta.1

9 months ago

4.0.0

9 months ago

3.0.0

2 years ago

3.0.0-beta.5

2 years ago

3.0.0-beta.4

2 years ago

3.0.0-beta.1

2 years ago

3.0.0-beta.2

2 years ago

2.0.0

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

1.0.0

2 years ago

1.0.0-beta.2

2 years ago