1.1.0 • Published 3 years ago

tnw-modal-library v1.1.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

tnw-modal-library

Made with create-react-library

NPM JavaScript Style Guide

Install

npm install --save tnw-modal-library --force

Usage

import React from 'react';
import { Modal, useModal } from 'tnw-modal-library';
import 'tnw-modal-library/dist/index.css';

const containerStyle = {
  height: '50vh',
  display: 'flex',
  flexDirection: 'column',
  justifyContent: 'center',
  alignItems: 'center'
};

const toggleButtonStyle = {
  backgroundColor: 'turquoise',
  cursor: 'pointer',
  padding: '1rem 2rem',
  textTransform: 'uppercase',
  border: 'none'
};

const App = () => {
  const { isShowing, toggle } = useModal();
  const title = 'Title';
  const message = 'Show modal!';
  return (
    <div style={containerStyle}>
      <h1>My own React Modal</h1>
      <button style={toggleButtonStyle} onClick={toggle}>
        Toggle Modal
      </button>
      <Modal
        isShowing={isShowing}
        close={toggle}
        title={title}
        message={message}
      />
    </div>
  );
};

export default App;

License

© thucnhi-wiedenhofer

1.1.0

3 years ago

1.0.0

3 years ago