0.2.9 • Published 1 year ago

@tourmalinecore/react-tc-modal v0.2.9

Weekly downloads
2
License
MIT
Repository
-
Last release
1 year ago

Tourmaline Core react modal component

Modal dialog component for React.JS

Demo

Instalation

The package can be installed via npm:

npm install @tourmalinecore/react-tc-modal --save

Or via yarn:

yarn add @tourmalinecore/react-tc-modal

Do not forget to import styles if you want to use the default styling.

should be imported once in your root component

import '@tourmalinecore/react-tc-modal/es/index.css';
import '@tourmalinecore/react-tc-ui-kit/es/index.css';

NOTE: You may want to re-style on your own. In that case you don't have to import the styles.

Examples

Simple Message:

import React from 'react';
import { Modal } from '@tourmalinecore/react-tc-modal';

function MessageModal({}){
  return (
    <Modal
      title="Important message!"
      content="You are now reading an important message."
      showApply={false}
      onCancel={false}
    />
  );
}

Confimation:

function ConfimationModal({onConfirm, onCancel, onClose}){
  return (
    <Modal
      className="confirm-modal" 
      title="Confirmation"
      content="Are you sure you want to continue?"
      onApply={onConfirm}
      applyText="Confirm"
      onCancel={onCancel}
      cancelText="Cancel"
      onClose={onClose}
    />
  );
}

Form:

const [name, setName] = useState('');

return ( 
  <Modal
    className="confirm-modal" 
    title="Registration"
    subtitle="Fill the form to complete the registration"
    content={(
      <div> 
        <input 
          type="text" 
          name="name" 
          value={name} 
          onChange={(e) => setName(e.target.value)} 
        />
      </div>
    )}
    onApply={sendForm}
    applyText="Register"
    onCancel={onCancel}
    cancelText="Cancel"
  />
);

Configuration

NameTypeDefaultDescription
styleObject{}Additional style
classNameString""Additional classname
customHeaderFunction(onClose) => JSXReplaces title and subtitle container
titleString / JSXnullModal's title
subtitleString / JSXnullModal's subtitle
contentString / JSXnullModal's content
languageString / Object"en"en/ru or Object, see example here(TODO file link)
iconJSX() => {}Heading title icon
overlayBooleantrue
maxWidthInt600Max width for modal body, pass null for no style
noPaddingBodyBooleanfalseDetermines should modal body have padding
portalTargetObjectdocument.bodyPortal target
parentOpenClassNameString"tc-modal-opened"ClassName for portalTarget on modal opened
onCloseFunction() => {}Triggered when modal closed
isLoadingBooleanfalseIf true, dispalays loader on the buttons
showApplyBooleantrueShow the Apply button
onApplyFunction() => {}OnClick handler for the Apply button
applyTextString"Apply"Text for the Apply button
showCancelBooleantrueShow the Cancel button
onCancelFunction() => {}OnClick handler for the Cancel button
cancelTextString"Cancel"Text for the Cancel button
isButtonsDisabledBooleanfalseDisabled state for both Cancel and Apply buttons
0.2.10-alpha.21

1 year ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago