2.0.0 • Published 17 days ago

@internetarchive/modal-manager v2.0.0

Weekly downloads
28
License
AGPL-3.0-only
Repository
github
Last release
17 days ago

Build Status codecov

Modal Manager Component

A modal manager built on LitElement with support for custom content and light DOM elements.

Modal Manager

Installation

npm install --save @internetarchive/modal-manager

Usage

<!-- index.html -->
<script type="module">
  import '@internetarchive/modal-manager';
  import { ModalConfig } from '@internetarchive/modal-manager';
</script>

<style>
  /* add the following styles to ensure proper modal visibility */
  body.modal-manager-open {
    overflow: hidden;
  }

  modal-manager {
    display: none;
  }

  modal-manager[mode='open'] {
    display: block;
  }
</style>

<modal-manager></modal-manager>

<script>
  // show a simple modal
  const manager = document.querySelector('modal-manager');
  const config = new ModalConfig();
  config.headline = 'Hi, Everybody!';
  config.message = 'Hi, Doctor Nick!';
  manager.showModal(config)

  // to hide the modal call `closeModal()`:
  manager.closeModal();
</script>

Advanced Usage

Markup Content

You can pass in custom HTML into the ModalConfig:

<script type="module">
  import { html } from 'lit-html';
</script>

<modal-manager></modal-manager>

<script>
  const manager = document.querySelector('modal-manager');
  const config = new ModalConfig();
  config.title = 'Internet Archive';
  config.subtitle = '';
  config.headline = 'Thanks for your Support!';
  config.message = html`
    <p>Thanks for your donation!</p>
    <p>Please click <a href="">here</a> to complete!</p>
  `;
  config.headerColor = '#36A483';
  manager.showModal(config);
</script>

Custom Content

Display completely custom content in the modal body, including light DOM content like a PayPal button.

<modal-manager></modal-manager>

<script>
  const manager = document.querySelector('modal-manager');
  const config = new ModalConfig();
  const customContent = html`
    Can contain any markup, including web components. Event listeners also work. Try clicking on the picture.
    <div style="text-align: center">
      <div class="sr-only">Visible for screen-readers only</div>
      <a href="https://fillmurray.com" style="display: block">Fill Murray</a>
      <img src="100x100.jpg" @click=${showBillAlert} />
    </div>
  `;

  // customContent used to render as slotted content, it can also use .sr-only class
  modalManager.showModal(config, customContent);
</script>

Config Options

All of the config options:

const config = new ModalConfig();
config.title = 'Internet Archive';
config.subtitle = '';
config.headline = '<div class="sr-only">Visible for screen-readers only</div>Thanks for your Support!';
config.message = 'Thank you for supporting the Internet Archive!';
config.headerColor = '#36A483';
config.showProcessingIndicator = false;
config.processingImageMode = 'processing'; // or `complete`

Development

Prerequisite

npm install

Start Development Server

npm start

Testing

npm test

Linting

npm lint
2.0.0

17 days ago

1.0.3-alpha.1

18 days ago

1.0.3-alpha.0

2 months ago

1.0.0

2 months ago

0.9.1-alpha.0

2 months ago

0.3.4

2 months ago

0.3.3-alpha.1

3 months ago

0.3.3-alpha.0

3 months ago

0.3.1-alpha.5

3 months ago

0.3.1-alpha.6

3 months ago

0.3.1-alpha.7

3 months ago

0.3.1-alpha.8

3 months ago

0.3.1-alpha.4

3 months ago

0.3.1-alpha.2

3 months ago

0.3.1-alpha.3

3 months ago

0.3.1-alpha.1

3 months ago

0.3.1-alpha.0

3 months ago

0.3.0

7 months ago

0.2.13-alpha.1

1 year ago

0.2.8-alpha.1

1 year ago

0.2.12

1 year ago

0.2.10

1 year ago

0.2.11-alpha.1

1 year ago

0.2.9-alpha.1

1 year ago

0.2.9-alpha.3

1 year ago

0.2.9-alpha.2

1 year ago

0.2.8-alpha01

1 year ago

0.2.8

1 year ago

0.2.7

2 years ago

0.2.4-alpha1

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1-alpha.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0-lit1

2 years ago

0.1.1-alpha.1

3 years ago

0.1.0

4 years ago

0.0.0-alpha.28

4 years ago

0.0.0-alpha.27

4 years ago

0.0.0-alpha.26

4 years ago

0.0.0-alpha.25

4 years ago

0.0.0-alpha.24

4 years ago

0.0.0-alpha.23

4 years ago

0.0.0-alpha.22

4 years ago

0.0.0-alpha.20

4 years ago

0.0.0-alpha.21

4 years ago

0.0.0-alpha.19

4 years ago

0.0.0-alpha.18

4 years ago

0.0.0-alpha.17

4 years ago

0.0.0-alpha.16

4 years ago

0.0.0-alpha.15

4 years ago

0.0.0-alpha.14

4 years ago

0.0.0-alpha.13

4 years ago

0.0.0-alpha.12

4 years ago

0.0.0-alpha.11

4 years ago

0.0.0-alpha.9

4 years ago

0.0.0-alpha.10

4 years ago

0.0.0-alpha.8

4 years ago

0.0.0-alpha.7

4 years ago

0.0.0-alpha.6

4 years ago

0.0.0-alpha.5

4 years ago

0.0.0-alpha.4

4 years ago

0.0.0-alpha.3

4 years ago

0.0.0-alpha.2

4 years ago

0.0.0-alpha.1

4 years ago