Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

makeup-expander

Package Overview
Dependencies
Maintainers
5
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-expander

Creates the basic interactivity for an element that expands and collapses another element.

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
327
increased by96.99%
Maintainers
5
Weekly downloads
 
Created
Source

makeup-expander

Build Status Coverage Status Dependency status devDependency status

Creates the basic interactivity for an element that expands and collapses another element.

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-expander

Example

<div class="expander">
    <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');

// options
const options = {
    expandOnClick: true
};

// 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 el
  • options.autoCollapse: applies a collapse behavior (collapseOnClick, collapseOnFocusOut, collapseOnMouseOut) based on expand behaviour (default: false)
  • options.collapseOnClickOut: whether the content should collapse when clicking outside of content (default: false)
  • options.collapseOnFocusOut: whether the content should collapse when focus leaves the content (default: false)
  • options.collapseOnMouseOut: whether the content should collapse when mouse leaves the content (default: false)
  • options.contentSelector: the query selector for the expandee element in relation to the widget (default: '.expander__content')
  • options.expandOnClick: whether the host should be click activated (default: false)
  • options.expandOnFocus: whether the host should be focus activated (default: false)
  • options.expandOnHover: whether the host should be hover activated (default: false)
  • options.focusManagement: where focus should go (null, 'content', 'focusable', 'interactive', 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')

Properties

Set the following properties to true or false to enable or disable the behaviour.

  • collapseOnClickOut
  • collapseOnFocusOut
  • collapseOnMouseOut
  • expandOnClick
  • expandOnFocus
  • expandOnHover

Methods

  • collapse(): set state to collapsed
  • expand(): set state to expanded
  • isExpanded(): returns expanded state
  • toggle(): toggle expanded/collapsed state

Events

  • expander-collapse
  • expander-expand

Dependencies

Development

  • npm start
  • npm test
  • npm run lint
  • npm run fix
  • npm run build
  • npm run clean

The following hooks exist, and do not need to be invoked manually:

  • npm prepublish cleans, lints, tests and builds on every npm publish command
  • pre-commit cleans, lints, tests and builds on every git commit command

Test Reports

Each test run will generate the following reports:

  • /reports/coverage contains Istanbul code coverage report
  • /reports/html contains HTML test report

CI Build

https://travis-ci.org/makeup-js/makeup-expander

Code Coverage

https://coveralls.io/github/makeup-js/makeup-expander

Keywords

FAQs

Package last updated on 20 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc