Package Exports
- makeup-expander
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (makeup-expander) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
makeup-expander
Creates the basic interactivity for an element that expands and collapses another element, e.g. a fly-out or fly-in.
Experimental
This module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.
Install
// via npm
npm install makeup-expander
// via yarn
yarn add makeup-expanderExample
<div class="expander expander--click">
<button class="expander__host">Click for Flyout</button>
<div class="expander__content">
<p>Any kind of HTML control can go inside...</p>
<p>A link: <a id="foo" href="http://www.ebay.com">www.ebay.com</a></p>
<p>A button: <button>Click Me</button></p>
<p>An input: <input type="text" aria-label="Dummy textbox"></p>
<p>A checkbox: <input type="checkbox" aria-label="Dummy checkbox"></p>
</div>
</div>// import the module
const Expander = require('makeup-expander');
// get an element reference
const widgetEl = document.querySelector('.expander--click');
// default options
const options = {
autoCollapse: true,
click: true,
contentSelector: '.expander__content',
focus: false,
focusManagement: null,
hostSelector: '.expander__host',
hover: false
};
// get widget instance
const widget = new Expander(widgetEl, options);Clicking the button will now toggle it's aria-expanded state. CSS can be used to display the content accordingly, for example:
.expander__content {
display: none;
}
.expander__host[aria-expanded=true] ~ .expander__content {
display: block;
}Params
el: the root widget eloptions.autoCollapse: whether expandee should collapse when focus or mouse leaves the widgetoptions.click: whether the host should be click activated (default: true)options.contentSelector: the query selector for the expandee element in relation to the widget (default: '.expander__content')options.focus: whether the host should be focus activated (default: false)options.focusManagement: where focus should go (null, 'content', 'focusable' or ID reference) when click expander is activated with keyboard (default: null)options.hostSelector: the query selector for the host element in relation to the widget (default: '.expander__host')options.hover: whether the host should be hover activated (default: false)
Events
collapsedexpanded
Dependencies
Development
npm startnpm testnpm run lintnpm run fixnpm run buildnpm run clean
The following hooks exist, and do not need to be invoked manually:
npm prepublishcleans, lints, tests and builds on everynpm publishcommandpre-commitcleans, lints, tests and builds on everygit commitcommand
Test Reports
Each test run will generate the following reports:
/reports/coveragecontains Istanbul code coverage report/reports/htmlcontains HTML test report
CI Build
https://travis-ci.org/makeup-js/makeup-expander