fitzgerald

12oz modal

View on GitHub

Fitzgerald

CI Coverage Status Package Version Software License

Fitzgerald (or just Fitz) is a minimalist modal window for the browser implemented in pure JavaScript and CSS.

Demo is available here and here (Vue).

Features

Installation

Install the package using npm:

npm add fitzgerald

Or yarn:

yarn add fitzgerald

And add imports:

import createModal from 'fitzgerald'
import 'fitzgerald/src/style.css'
import 'fitzgerald/src/default-theme.css'

Also you can just include JS script and CSS file into your HTML page:

<link href="https://cdn.jsdelivr.net/gh/voronkovich/fitzgerald/dist/fitzgerald.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/voronkovich/fitzgerald/dist/fitzgerald-default-theme.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/voronkovich/fitzgerald/dist/fitzgerald.min.js"></script>

Usage example

Application:

import createModal from 'fitzgerald'
import 'fitzgerald/src/style.css'
import 'fitzgerald/src/default-theme.css'

const modal = createModal('Hey!')

modal.show()

Browser:

<script>
const modal = Fitz.createModal('Hey!')

modal.show()
</script>

Options

Instance API

Properties

You can use properties to interact with the modal DOM (attach event listeners, add nodes and etc.):

const modal = createModal({ /* Options */ })

modal.content.addEventListener('submit', (e) => {
    // Handle form submit
})

Methods

const modal = createModal()

modal.setContent('This modal will be closed after 5 seconds.')

modal.show()

setTimeout(modal.hide, 5000)

Events

let counter = 0

const modal = createModal()

modal.on('show:before', () => {
    modal.setContent(`You've seen this modal ${++counter} times!`)
})

License

Copyright (c) Voronkovich Oleg. Distributed under the MIT.