# Code

## Props

<table><thead><tr><th>Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>-HTML tags<br>-Custom Components<br><em>(ModalBody, ModalFooter)</em></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>commland</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>title</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>show</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>cancelAction</td><td>Function</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

{% hint style="info" %}
commland prop is used to adjust the Alert component to the Commland UI-Shell automatically.
{% endhint %}

### Where to Insert This Component?

This component is supposed to overlay all the content inside the application. Knowing that it can be inserted wherever the developer wants, it should not be affected by the rest of content structure.&#x20;

To keep a better order, it is recommended to insert this component at the beginning or at the end of the HTML structure in the React componen.

### CancelAction

This is a prop made to allow to users the action of canceling or closing a modal at pressing the Esc key, clicking on the exit button or in the overlayed backgorund.

If this prop is not facilitated by the developers, then the modal is going to be blocked, forcing the users to interact only with the Buttons in the Modal footer to close the modal.

### Children

To generate the structure required for the component, the developer is able to insert the following components as children elements:

#### ModalBody

In here, the developer can insert all the HTML tags and Components needed.

<table><thead><tr><th width="163.7588075896112">Props</th><th width="414.7376821119017">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>HTML tags and Custom Components</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>paddingDisabled</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

{% hint style="info" %}
paddingDisabled prop removes the default padding applied to the ModalBody. This can be useful when the internal structure of the modal is using its own column system or if it requires something more customized.
{% endhint %}

#### ModalFooter

<table><thead><tr><th width="163.7588075896112">Props</th><th width="414.7376821119017">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>SDS Button Components</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr></tbody></table>

#### Example

```tsx
import React, {useState} from 'react';
import {
    Modal, 
    ModalBody, 
    ModalFooter, 
    Text,
    Button} from '@2600hz/sds-react-components';

const Example = ()=>{
    //STATE
    const [show, setShow] = useState(false);
    
    //ACTIONS
    const closeModal = ()=>{
        setShow(false);
    }
    
    const openModal = ()=>{
        setShow(true);
    }
    
    const customAction = ()=>{
        console.log('Do something');
        closeModal();
    }

    //CONTENT
    return(
        <>
            <Modal title='Lorem Ipsum' show={show} cancelAction={closeModal}>
                <ModalBody>
                    <Text.p>Some random text...</Text.p>
                </ModalBody>
                <ModalFooter>
                    <Button type='Ghost' onClick={closeModal}>Cancel</Button>
                    <Button type='Primary' onClick={customAction}>Action</Button>
                </ModalFooter>
            </Modal>
            <div className='content'>
                <Button onClick={openModal}>Open Modal</Button>
            </div>
        </>
    )
}
```

## Components Dependency

For this component elaboration there were used the following internal components:

* ModalBody
* ModalFooter
* [Telicon](https://2600hz.gitbook.io/sds/sds-components/simple-components/telicon)
* [Button](https://2600hz.gitbook.io/sds/sds-components/simple-components/button)

## Live Demo <a href="#live-demo" id="live-demo"></a>

For detailed code usage documentation, see the Storybooks for each framework below.​

### React <a href="#react" id="react"></a>

{% embed url="<https://sipster-react-component-storybook.netlify.app/?path=%2Fstory%2Fgeneral-components-modal--modal>" %}
