1.0.14 • Published 1 year ago

react-add-modal v1.0.14

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

react-add-modal

Este This modal was develop to support the open source community and also to use on my personal projetos.

Installation

i gonna use npm for this exemple, but you also can use yarn to install. First of all, let's install the modal as a Production Dependency. Open the terminal and run the following command:

npm install react-add-modal --save

Usage

Now you need to import the modal on your react component, and set two obrigatory properties:

  • visible: boolean
  • dismissible: boolean

And you alse need to set the title and description to your modal using this two properties:

  • title: string
  • description: string

(You can find more information about the all properties bellow)

See the exemple bello:

import { useState } from 'react'
import { Modal } from 'react-add-modal'

export const Component = () => {
  const [isModalVisible, setIsModalVisible] = useState(false)

  return (
    <div>
      <Modal 
        visible={isModalVisible}
        dismissible={true}
        title="I am a title"
        description="This is the description for the modal"
      />
    </div>
  )
}

Customizations

Use with children

To use the component with children you must just open and close the modal tags, and pass a children on it,you can pass anithhing as a children, a component, text or a simple html tag. After using a children, the default title is not gonna be present on the modal anymore. See the exemple bellow:

<Modal visible={isModalVisible} dismissible={true}>
  <p>i am a children</p>
</Modal>

Custom position

there is a property called customPosition that you can use to render your modal on whhere you want:

  • "default"
  • "topLeft"
  • "topRight"
  • "bottomLeft"
  • "bottomRight"

See the exemple bellow:

  dismissible={true}
  customPosition="topLeft"
>
  <p>i am a children</p>
</Modal>

That was the basic for customize your modal, now you can see all the properties, and how to use each one:

PropertyTypeHow to use
titlestringtitle="This is a title"
descriptionstringdescription="I am a description"
customPositionvariantPositionTypescustomPosition="topLeft" \ "topRight" \ "bottomLeft" \ "bottomRight"
onClosefunctiononClose={() => console.log("Pass your function")}
onConfirmfunctiononConfirm={() => console.log("Pass your function")}
classNamestringclassName="my-custom-class-name"
visiblebooleanvisible={true}
dismissiblebooleandismissible={true}
stylesOverlayReact.CSSPropertiesstylesOverlay={{backgroundColor: 'black'}}
stylesWrapperReact.CSSPropertiesstylesOverlay={{backgroundColor: 'blue'}}
stylesContainerReact.CSSPropertiesstylesOverlay={{width: '400px'}}
stylesModalReact.CSSPropertiesstylesOverlay={{borderRadius: '30px'}}

Contributing

André Ferreira

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago