1.5.4 • Published 4 years ago

dile-modal v1.5.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Moved

This package has moved and is now available at @dile/dile-modal. Please update your dependencies. This repository is no longer maintained.

dile-modal

This is a Web Component to implement a modal box, based on LitElement.

Go to demos page

Use

Install it from npm:

npm i dile-modal

Place the script In your HTML page or include the dile-modal.js file in your JS bundle. After that you can use the dile-modal tag, like this:

<dile-modal id="myModal">
  <p>
    Lorem, ipsum dolor sit...
  </p>
</dile-modal> 

Whatever you place inside the <dile-modal> tag will be the content displayed when the modal box opens.

When needed, you may use the open() method to open the modal box interface, and close() to close it.

document.getElementById("myModal").open();

Other posibility in order to open or close the modal box is to set the boolean opened attribute.

Properties

  • opened: Bolean property used to change the modal state, false is closed / true means open.
  • showCloseIcon: Boolean property to tell the modal box you want a close icon to be displayed.
  • blocking: Boolean property to configure the modal box as a bloking interface. If true the modal box blocks the screen. That is, when you click in the background layer, the modal box do not close.

Methods

  • open: Use it to open the modal box
  • close: Use it to close the modal box

Events

  • dile-modal-closed: Dispatched when the modal box becomes closed, in case you are called the close() method, or clicked in the background modal, or by the close icon.
  • dile-modal-background-closed: Dispatched when the modal box is closed because the user clicks in the background layer.

Style customization

You can customize the modal box interface by using the CSS custom properties bellow.

Custom propertyDescriptionDefault
--dile-modal-background-colorModal layer background colorrgba(30,30,30, 0.8)
--dile-modal-z-indexModal layer z-index100
--dile-modal-content-z-indexContent layer z-index101
--dile-modal-widthContent layer width280px
--dile-modal-min-widthContent layer min width250px
--dile-modal-max-widthContent layer max width100vw
--dile-modal-heightConten layer heightauto
--dile-modal-min-heightContent layer max heightauto
--dile-modal-max-heightContent layer max height100vh
--dile-modal-content-background-colorContent layer background color#fff
--dile-modal-content-paddingContent layer padding1em
--dile-modal-border-radiusContent layer border radius15px
--dile-modal-content-shadow-displacementcontent layer shadow offset6px
--dile-modal-content-shadow-blurContent layer shadow blur16px
--dile-modal-content-shadow-colorContent layer shadow color#000
--dile-modal-close-icon-colorClose icon color#888
--dile-modal-close-icon-sizeClose icon size24px
--dile-modal-animation-durationDuration of the opacity modal animation0.3s
--dile-modal-close-icon-topTop position applied to the close icon5px
--dile-modal-close-icon-rightRight position applied to the close icon18px
1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago