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

@dr/bem-helper

Package Overview
Dependencies
Maintainers
43
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dr/bem-helper

Helper to create BEM-style classnames

  • 1.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
285
decreased by-43.79%
Maintainers
43
Weekly downloads
 
Created
Source

bem-helper

Helper to create BEM-style classnames

Install

npm install @dr/bem-helper

Usage

var bem = require("@dr/bem-helper");

var className = bem("dr-module", "list");
// className === "dr-module__list"

var className = bem("dr-module", { loaded: true });
// className === "dr-module dr-module--loaded"


// Get all applicable combinations for an element:
var className = bem("dr-module", "list", { expanded: true });
// className === "dr-module__list dr-module__list--expanded"


// Get a single classname for an element:
var className = bem.single("dr-module", "list", { expanded: true });
// className === "dr-module__list--expanded"


// Modifiers with values

// Get all applicable combinations for an element:
var className = bem("dr-module", "list", { expanded: true, rated: 3 });
// className === "dr-module__list dr-module__list--expanded dr-module__list--rated-3"


// Get a single classname for an element:
var className = bem.single("dr-module", "list", { rated: 3 });
// className === "dr-module__list--rated-3"


// Prebinding a helper

var block = "dr-module";

var boundBem = bem.bind(null, block);

// Get all applicable scoped combinations for an element:
var className = boundBem("list", { expanded: true });
// className === "dr-module__list dr-module__list--expanded"

var boundSingle = bem.single.bind(null, block);

// Get a single scoped classname for an element:
var className = boundSingle("list", { expanded: true });
// className === "dr-module__list--expanded"

API

bem

A function that creates all applicable combinations of classnames for an element in BEM-style.

Arguments
  • block (string) - The block element for the classname.
  • ...args (string|object) - Optional. Elements are described by strings and modifiers are described by objects: keys are use as the modifier names and boolean values trigger whether the modifier is active, and any other type is used as a value; {expanded: true} > "--expanded", {rating: 3} > "--rating-3".

bem.single

Same as bem above - but it only returns a single classname.

Keywords

FAQs

Package last updated on 16 Nov 2016

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