3.1.0 • Published 4 years ago

@orcden/od-modal v3.1.0

Weekly downloads
1
License
MIT
Repository
bitbucket
Last release
4 years ago

A set of modals to display information to the user

<od-modal> is a simple component that can be given custom content. Can either hijack the user experience or not. <od-modal-alert> is a simple component that can be given custom content. It will hijack the user experience until the ok button is clicked. <od-modal-confirm> is a simple component that can be given custom message content. It will hijack the user experience until the ok button is clicked and return the users decision.

Installation

  • Install with npm
npm i @orcden/od-modal

Usage

import '@orcden/od-modal';
<od-modal id="modal" scoped><p>Test</p></od-modal>
<od-modal-alert id="alert" scoped><p>Test 2</p></od-modal-alert>
<od-modal-confirm id="confirm" scoped><p>Test 3</p></od-modal-confirm>

document.querySelector( "#alert" ).alert( 'This is an alert' ); //displays the alert
document.querySelector( "#confirm" ).confirm( 'This is a confirm' ); //displays the confirm

Attributes

AttributeTypeDefaultDescription
scopedBooleanfalseCan be set to tell the modal to scope itself to the next parent element with relative position (in CSS)
activeBooleanfalseControls CSS to show/hide the modal.
hijackBooleanfalseCan be set to hijack the user experience until stated otherwise in JS. This is always true in alerts and confirms

Properties

OD-Modal

AttributeTypeDefaultDescription
scopedBooleanfalseCan be set to tell the modal to scope itself to the next parent element with relative position (in CSS)
activeBooleanfalseControls CSS to show/hide the modal.
hijackBooleanfalseCan be set to hijack the user experience until stated otherwise in JS.

OD-Modal-Alert & OD-Modal-Confirm

AttributeTypeDefaultDescription
scopedBooleanfalseCan be set to tell the modal to scope itself to the next parent element with relative position (in CSS)
activeBooleanfalseControls CSS to show/hide the modal.
messageString''Can be used to set the displayed message of the modal

Functions

OD-Modal

NameParametersDescription
toggleModalNoneToggles the modal on and off

OD-Modal-Alert

NameParametersDescription
toggleAlertNoneToggles the alert on and off
alertmessageAsync. Displays the alert and waits for the user input. Displays the given string to the user

OD-Modal-Confirm

NameParametersDescription
toggleConfirmNoneToggles the alert on and off
confirmmessageAsync. Displays the confirm and waits for the user input. Displays the given string to the user. Returns the Users input choice

Styling

  • CSS variables are available to alter the default styling provided
Shadow PartsDescription
modalThe inner div used for the modal
content-boxOn alerts and confirms this is the div that holds the buttons and message
mesageOn alerts and confirms this is the div that holds the text message
buttons-containerOn alerts and confirms this is the div that holds the buttons
confirm-buttonOn alerts and confirms this is the OK button
confirm-buttonOn confirms this is the CANCEL button

Development

Run development server and show demo

npm run demo

Run linter

npm run lint

Fix linter errors

npm run fix

Run tests

npm run test

Build for production

npm run build
3.1.0

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.1

6 years ago

2.0.0

6 years ago