Code Monkey home page Code Monkey logo

dile-confirm's Introduction

dile-confirm

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

Let's go to DEMOS page!

Use

Install it from npm:

npm i dile-confirm

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

<dile-confirm id="myModal">
  <p>
    Delete this file?
  </p>
</dile-confirm> 

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

In addition, the confirm box display two buttons inside the modal interface:

  • Cancel button: pressing it, the confirm box closes and dispatchs the dile-confirm-cancelled event
  • Accept button: pressing it, the confirm box closes and dispatchs the dile-confirm-accepted event

Properties

  • opened: Bolean property used to change the confirm modal state, false is closed / true means open.
  • cancelLabel: The text to the cancel button.
  • acceptLabel: The text to the accept button.
  • blocking: Click on the background layer do not closes the confirm box.

Methods

  • open: Use it to open the modal confirm box
  • close: Use it to close the modal confirm box
  • accept: Closes the modal box and dispatch dile-confirm-accepted event
  • cancel: Closes the modal box and dispatch dile-confirm-cancelled event

Custom events

  • dile-confirm-cancelled: Dispatched when the confirm box is cancelled. This occurs when the user press the cancel button or closes the modal box cliking outside.
  • dile-confirm-accepted: Dispatched when the confirm box is accepted. This occurs when the user press the accept button.

Style customization

These are the dile-confirm CSS custom properties. (But remember, you can customize the modal box interface also by using the CSS custom properties of the dile-modal component)

Custom property Description Default
--dile-confirm-accept-button-color Accept button background color #007bff
--dile-confirm-cancel-button-color Cancel button background color #dc3545
--dile-confirm-accept-text-button-color Accept button text color #fff
--dile-confirm-cancel-text-button-color Cancel button text color #fff
--dile-confirm-border-radius-button Button border radius 5px
--dile-confirm-padding-button Button padding 7px
--dile-confirm-font-size-button Button font size 1em
--dile-confirm-buttons-text-align Buttons element text align right
--dile-confirm-text-transform Button text transformation uppercase
--dile-confirm-buttons-margin-top Confirm buttons section margin-top 10px
--dile-confirm-buttons-margin-bottom Confirm buttons section margin-bottom 10px
--dile-confirm-buttons-margin-left Confirm buttons section margin-left 0
--dile-confirm-buttons-margin-right Confirm buttons section margin-right 0

dile-confirm's People

Contributors

midesweb avatar

Stargazers

Erik Ramírez Zúñiga avatar Belousov Vladimir avatar beeman avatar  avatar

Watchers

 avatar James Cloos avatar

dile-confirm's Issues

Would like to see TypeScript example.

Hi. Tnx for sharing this. Learning from it. :)
Want to adopt this for components written in TypeScript, but till now no luck. Missing something.
Will update this if will find a solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.