Modals

Star
The Trowel project is abandonned. Trowel core and the Trowel components are no more maintained or supported. More infos

Download

You can fetch Trowel Modals with npm, yarn or bower.

# With bower
$ bower install --save trowel-modals

# With npm
$ npm install --save trowel-modals

# With yarn
$ yarn add trowel-modals

You can also download a zip archive right here.

Installation

Scss

The main scss file to include to your main .scss file is located at the ./src/scss/modals.scss. As a Trowel Component, it also requires two dependencies to compile the scss code. Here an scss installation snippet.

// Trowel core (need to be imported first)
@import './path/to/dependencies/trowel-core/src/trowel';

// Trowel Modals
@import './path/to/dependencies/trowel-modals/src/scss/modals';

JavaScript

You have several javascript files for different use cases :

Usage

<button data-modal="open" data-target="#modal-example">click me !</button>

<div class="modal modal--lg" id="modal-example" data-flag="modal">
  <div class="modal__dialog">
    <div class="modal__content">
      <div class="modal__header">
        Modal title
        <button class="modal__close" data-modal="hide">x</button>
      </div>

      <div class="modal__body">
        Woohoo, you're reading this text in a modal!
      </div>

      <div class="modal__footer">
        <button type="button" data-modal="hide">Close</button>
      </div>
    </div>
  </div>
</div>

Javascript setup

In order to make it work you need to setup some javascript. You have two ways to make it work :

Javascript usage into html

<script src="./path/to/trowel-collapses/javascript/collapses.js"></script>

<script type="text/javascript">
  var modals = new TrowelModals(document.querySelectorAll('[data-flag="modal"]'));
</script>

Javascript usage with an import

import TrowelModals from './path/to/trowel-modals/src/javascript/modals';

const modals = new TrowelModals(document.querySelectorAll('[data-flag="modal"]'));

Sass reference

Syntax variables

You can override the global syntax config for a specific component with the following variables

VARIABLE DEFAULT VALUE DESCRIPTION
$modals--syntax null syntax config for .modal

Component variables

VARIABLE DEFAULT VALUE DESCRIPTION
$modals--font-size 1rem set the font-size property
$modals--font-family null set the font-family property
$modals--font-weight null set the font-weight property
$modals--text-transform null set the text-transform property
$modals--letter-spacing null set the letter-spacing property
$modals--line-height null set the line-height property
$modals--text-align null set the text-align property
$modals--text-decoration null set the text-decoration property
$modals--color null set the color property
$modals--background null set the background property
$modals--background-color rgba(0, 0, 0, 0.5) set the background-color property
$modals--z-index 1050 set the z-index property
$modals--transition all 200ms ease-in-out set the transition property
Dialog    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-dialog--max-width 500px set the max-width property for .modal__dialog
$modals-dialog--margin 30px auto set the margin property for .modal__dialog
Content    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-content--background-color rgb(255, 255, 255) set the background-color property for .modal__content
$modals-content--border-width 1px set the border-width property for .modal__content
$modals-content--border-style solid set the border-style property for .modal__content
$modals-content--border-color rgb(232, 232, 236) set the border-color property for .modal__content
$modals-content--border-radius 0.2em set the border-radius property for .modal__content
$modals-content--box-shadow null set the box-shadow property for .modal__content
Header    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-header--background-color null set the background-color property for .modal__header
$modals-header--border-bottom-width $modals-content--border-width set the border-bottom-width property for .modal__header
$modals-header--border-bottom-style $modals-content--border-style set the border-bottom-style property for .modal__header
$modals-header--border-bottom-color $modals-content--border-color set the border-bottom-color property for .modal__header
$modals-header--padding 0.65em 1.65em set the padding property for .modal__header
Close    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-close--font-size 1em set the font-size property for .modal__close
$modals-close--font-weight null set the font-weight property for .modal__close
$modals-close--line-height 1 set the line-height property for .modal__close
$modals-close--color null set the color property for .modal__close
$modals-close--text-shadow null set the text-shadow property for .modal__close
$modals-close--opacity 0.5 set the opacity property for .modal__close
Body    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-body--background-color null set the background-color property for .modal__body
$modals-body--padding 0.65em 1.65em set the padding property for .modal__body
Footer    
VARIABLE DEFAULT VALUE DESCRIPTION
$modals-footer--background-color null set the background-color property for .modal__footer
$modals-footer--border-top-width $modals-content--border-width set the border-top-width property for .modal__footer
$modals-footer--border-top-style $modals-content--border-style set the border-top-style property for .modal__footer
$modals-footer--border-top-color $modals-content--border-color set the border-top-color property for .modal__footer
$modals-footer--padding 0.65em 1.65em set the padding property for .modal__footer
$modals-footer--text-align right set the text-align property for .modal__footer