Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@dr/bem-helper
Advanced tools
Helper functions to create BEM-style classnames
npm install @dr/bem-helper
import bem from "@dr/bem-helper";
var className = bem("block", "element", { modifier: true });
// className = "block__element block__element--modifier"
A function that creates all applicable combinations of classnames for an element scoped to a block in BEM-style format.
block
(string) - The block element for the classname....args
(string|object) - Optional. Any number of the following arguments are allowed:
element
(string) - Optional.modifier
(object) - Optional. Keys are used for modifier names. Values determine whether to turn the modifier off (false
, ""
, null
or undefined
) or on - either through true
or a value which will be appended to the modifier name; {modifier: true}
-> "--modifier"
, {modifier: "value"}
-> "--modifier-value"
. Should not follow a previous modifier argument.
var className = bem("block", "element");
// className === "block__element"
var className = bem("block", { modifier: true });
// className === "block block--modifier"
var className = bem("block", "element", { modifier: "value", modifier2: false });
// className === "block__element block__element--modifier-value"
var boundBem = bem.bind(null, "block");
var className = boundBem("element", { modifier: true });
// className === "block__element block__element--modifier"
FAQs
Helper functions to create BEM-style classnames
We found that @dr/bem-helper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 55 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.