npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bembo

v1.1.0

Published

Module for creating classNames based on BEM methodology

Downloads

5

Readme

A simple module for creating dynamic class names following the BEM Methodology. Intended to be used with React.

Inspired by classnames

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm install bembo

or

for installation via yarn

yarn add bembo

Examples

Using bem

import bem from "bembo";

// Creating a block
bem("list") // => 'list'

// Creating a block with modifiers
bem("list", {error: true, severe: "10", success: ""}); // => 'list list--error list--severe'

// Creating an element
bem("list__item") // => 'list__item'

// Creating an element with modifiers
bem("list__item", {error: true, severe: "10", success: ""}); // => 'list__item list__item--error list__item--severe'

Chaining Elements

import bem from "bembo";

// Creating an element
let b = bem("list")
b.e("item") // => 'list__item'

// Adding element modifiers
b = bem("list")
b.e("item", {error: true, severe: "10", success: ""}) // => 'list__item list__item--error list__item--severe'

Chaining Modifiers

import bem from "bembo";

// Adding modifiers by object
let b = bem("list")
b.m({error: true, severe: "10", success: ""}) // => 'list list--error list--severe'

// Adding modifiers by string
b = bem("list")
b.m("error", "severe") // => 'list list--error list--severe'

// Overriding modifiers
b = bem("list")
b.m({error: true, success: ""}, {error: null, success: "200"}) // => 'list list--success'

React

import React from "react";
import bem from "bembo";

const b = bem("card")
const btnB = bem("btn")

function Card({title, text, error = "An error occurred", disabled = true}){
    return (
        <div className={b}>
            <h2 className={b.e('header')}>{title}</h2>
            <p className={b.e("text")}>{text}</p>
            <span className={b.e("error-text", {error})}>{error}</span>
            <button className={btnB.m({disabled})}>
                Submit
            </button>
        </div>
    )
}

/*
    <div class="card">
        <h2 class="card__header">
            Card Title
        </h2>
        <p class="card__text">
            Card text content
        </p>
        <span class="card__error-text card__error-text--error">
            An error occurred
        </span>
        <button class="btn btn--disabled">
            Submit
        </button>
    </div>
*/

LICENSE

MIT