Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
makeup-expander
Advanced tools
Creates the basic interactivity for an element that expands and collapses another element.
Creates the basic interactivity for an element that expands and collapses another element.
This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.
In the first example, our expanded content is adjacent to the host element.
<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 Expander from "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 its 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;
}
In this second example, our expanded content is not adjacent to the host element.
<div class="expander">
<span>
<input class="expander__host" type="text" />
</span>
<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>
A CSS classname is required as our styling hook. This can be passed in via the options.
// options
const options = {
expandedClass: "expander--expanded",
expandOnFocus: true,
};
Setting focus on the host (a text input) sets it's aria-expanded state and add adds the chosen class to the root. CSS can be used to display the content accordingly, for example:
.expander--expanded .expander__content {
display: block;
}
el
: the root widget eloptions.alwaysDoFocusManagement
: whether focusManagement
option (see below) should apply for mouse clickoptions.ariaControls
: specify whether aria-controls
relationship should be created between host and overlay (default: true)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 keyboard focus should go (null, 'content', 'focusable', 'interactive', or ID reference) when expanded via ENTER
or SPACEBAR
(default: null)options.hostSelector
: the query selector for the host element in relation to the widget (default: '.expander__host')options.expandedClass
: the class which will be used on the root element to signify expanded state. Example: foo--expanded
; this mirrors the aria-expanded="true"
setting on the host elementSet the following properties to true or false to enable or disable the behaviour.
collapseOnClickOut
collapseOnFocusOut
collapseOnMouseOut
expanded
expandOnClick
expandOnFocus
expandOnHover
collapse()
: set state to collapsed (DEPRECATED)expand()
: set state to expanded (DEPRECATED)isExpanded()
: returns expanded state (DEPRECATED)toggle()
: toggle expanded/collapsed state (DEPRECATED)expander-collapse
expander-expand
FAQs
Creates the basic interactivity for an element that expands and collapses another element.
The npm package makeup-expander receives a total of 265 weekly downloads. As such, makeup-expander popularity was classified as not popular.
We found that makeup-expander demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.