npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lintel-contrib-modals

v0.1.4

Published

Modals for lintel.

Downloads

8

Readme

lintel-contrib-modals

Modals for lintel.

npm Bower

Getting Started

This module requires Lintel.

If you haven't used Lintel before, be sure to check out the Getting Started guide, as it explains how to install and use this module. Once you're familiar with that process, you may install this module with this command:

bower install lintel-contrib-modals --save

Once the module has been installed, you will have to load it in your main SASS file:

@import "bower_components/lintel-contrib-modals/sass/modals.scss"

This module also includes a JavaScript component, which you will have to load separately.

<script src="bower_components/lintel-contrib-modals/dist/modals.min.js" type="text/javascript"></script>

You can use wiredep or grunt-wiredep to automatically inject files in your build process.

Variables

Check the vars file in the sass folder to see the full list of variables you can customize.

$modal-padding-y & $modal-padding-x

Change default modal paddings.

The following vars are available for finer grained control (and default to these 2):

  • $modal-header-padding-y
  • $modal-header-padding-x
  • $modal-body-padding-y
  • $modal-body-padding-x
  • $modal-footer-padding-y
  • $modal-footer-padding-x

$modal-bg

Default value: #fff

$modal-border

Default value: rgba(0,0,0,.6)

$modal-border-radius

Default value: $border-radius-base

$modal-box-shadow

Default value: $box-shadow-dark

$modal-z-index

Default value: $z-index-3xl

$modal-xs-width

Default value: 400px

$modal-sm-width

Default value: 500px

$modal-md-width

Default value: 600px

This is the default modal width.

$modal-lg-width

Default value: 700px

$modal-xl-width

Default value: 800px

$modal-header-border

Default value: $border-base

$modal-footer-border

Default value: $border-base

$modal-overlay-bg

Default value: rgba(0,0,0,.5)

$modal-overlay-bg-fallback

Default value: #333

NOTE: If you do not want a fallback, set the fallback to the same value as the bg.

$modal-overlay-bg-fallback: $modal-overlay-bg;

$modal-overlay-padding-y & $modal-overlay-padding-y

Default value: $cushion-base

$modal-*-bg

Change the background for a specific (*) state. Ex: primary, secondary, error, warning, success, info

$modal-*-border

Change the border-color for a specific (*) state. Ex: primary, secondary, error, warning, success, info

$modal-*-text

Change the text color for a specific (*) state. Ex: primary, secondary, error, warning, success, info

$modal-center-y

Default value: true

Determines whether to vertically center the modal for browsers that support flexbox. See usage below.

Mixins

Check the mixins file in the sass folder to see how you can extend this module.

modal-state($bg, $border, $text)

Change this mixin to customize what each state does.

@mixin modal-state($bg, $border, $text) {
  .modal-header,
  .modal-footer {
    @if $bg     { background-color: $bg; }
    @if $border { border-color: $border; }
    @if $text   { color: $text; }
  }
}

JavaScript

Options

Name | Type | Default | Description --------- | ------------------------------ | ------------------- | ----------- onShow | function | | Callback function to execute every time modal is shown. onHide | function | | Callback function to execute every time modal is hidden. esc | boolean | true | Close modal on escape key. show | boolean | true | Show modal when invoking .modal()

Methods

Name | Parameters | Description --------- | ------------------------ | ----------- show | (options, relatedTarget) | Show modal. Related target is the trigger that opened the modal. Focus will return to this element when modal hides. hide | | Hide modal.

Events

Event | Description -------------------- | ------------------------------ show.lt.modal | Fires immediately before modal is shown. Can prevent modal from showing here. Trigger button (if provided) can be accessed under relatedTarget. shown.lt.modal | Fires immediately after modal is shown. hide.lt.modal | Fires immediately before modal is hidden. Can prevent modal from hiding here. hidden.lt.modal | Fires immediately after modal is hidden.

Data-attr

Add data-toggle="modal" and data-target="#selector" to a button/element. You can add additional options as data-attributes.

<button type="button" data-toggle="modal" data-target="#myModal">
  Modal
</button>
<div id="myModal" class="modal">
...
</div>

jQuery

Call the jQuery plugin on the modal, passing in any options and the related target (button).

In order for events and onShow/onHide callbacks to have access to the triggering element(ie. button), provide the related target. See example for onShow/onHide below.

var options = {
  onShow: function(modal, button) {
    console.log('onShow', this, modal, button);
  },
  onHide: function(modal, button) {
    console.log('onHide', this, modal, button);
  },
  esc: false
};

$('#myButton').click(function(e) {
  $('#myModal').modal(options, this); // this == #myButton
});

Alternatively, you can use the default options:

$('#myButton').click(function(e) {
  $('#myModal').modal('show', this); // this == #myButton
});

Examples

Modal

<div class="modal">
  <div class="modal-container">
    <div class="modal-dialog">
      <form>
        <div class="modal-header">
          <h1 class="modal-title">
            <a href="modal-title-link">Modal Title</a>
          </h1>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label class="form-label">
              Email
              <input class="form-control" type="text" placeholder="Email">
            </label>
          </div>
          <div class="form-group">
            <label class="form-label">
              Password
              <input class="form-control" type="password" placeholder="Password">
            </label>
          </div>
        </div>
        <div class="modal-footer">
          <div class="btn-group float-right">
            <button class="btn" type="button">
              Cancel
            </button>
            <button class="btn-primary" type="submit">
              OK
            </button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>

Modal Header

<div class="modal-header">
  <h1 class="modal-title">
    Modal Title
  </h1>
</div>

Modal Header with Linked Title

<div class="modal-header">
  <h1 class="modal-title">
    <a href="modal-title-link">Modal Link Title</a>
  </h1>
</div>

Modal Header with Right Side Actions

NOTE: There should be no whitespace after .modal-header-actions. See Fighting the Space Between Inline Block Elements.

<div class="modal-header">
  <div class="modal-header-actions">
    <div class="btn-group">
      <button class="btn" type="button">
        Cancel
      </button>
      <button class="btn btn-primary" type="submit">
        OK
      </button>
    </div>
  </div><!--
  -->
  <h1 class="modal-title">
    <a href="modal-title-link">Modal Title</a>
  </h1>
</div>

Modal Header with Close Button

<div class="modal-header">
  <button type="button" class="modal-close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <h1 class="modal-title">
    <a href="modal-title-link">Modal Link Title</a>
  </h1>
</div>

Modal Header with Close Button in Right Side Actions

<div class="modal-header">
  <div class="modal-header-actions">
    <button type="button" class="modal-close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  </div><!--
  --><h1 class="modal-title">
    <a href="modal-title-link">Modal Link Title</a>
  </h1>
</div>

Modal Body

<div class="modal-body">...</div>

Modal Footer

<div class="modal-footer">
  <div class="btn-group">
    <button class="btn" type="button">
      Back
    </button>
  </div>

Modal Footer with Right Side Actions

NOTE: There should be no whitespace after .modal-footer-actions. See Fighting the Space Between Inline Block Elements.

<div class="modal-footer">
  <div class="modal-footer-actions">
    <div class="btn-group">
      <button class="btn" type="button">
        Cancel
      </button>
      <button class="btn btn-primary" type="submit">
        OK
      </button>
    </div>
  </div><!--
  --><div class="btn-group">
    <button class="btn" type="button">
      Back
    </button>
  </div>

Vertical Center

If the body has the class .flexbox, the modal will be centered using flexbox. DO NOT ADD THIS CLASS MANUALLY. Nothing bad will probably happen if you do, but it's not recommended. This class should be added by modernizr. Set $modal-center-y to false if you wish to disable this feature.

<body class="flexbox">
  <div class="modal">...</div>
</body>

Sizes

<div class="modal-container modal-xs">...</div>
<div class="modal-container modal-sm">...</div>
<div class="modal-container modal-lg">...</div>
<div class="modal-container modal-xl">...</div>
<div class="modal-container modal-max">...</div>

Full Height and Width

<div class="modal-container modal-max modal-full">...</div>

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.