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

bemy-class-builder

v1.1.0

Published

Tool which is here to help you work with BEM structured classes in a nice way

Downloads

6

Readme

Bemy-class-builder

Simple utility which allows you to use BEM class naming without painful copy-pasting these long names here and there.

Usage

bemy-class-builder is supposed to be used alongside with bemy-style-loader, so don't hesitate to check its docs

Block classes

Define your component classes using BEM principles (to configure naming schema check out bemy-style-loader docs)

.button {
  // base button styles
}

.button_disabled {
  // disabled button styles
}

.button_theme_danger {
  // danger button styles
}

and use it in your component file

import styles from './styles.css'

// base block styles
const blockClassName = styles() // => 'button;

// block styles with modifiers
const collapsedBlockClassName = styles({ disabled: true }) // => 'button button_disabled'
const darkBlockStyles = styles({ theme: 'danger' }) // => 'button button_theme_danger'

// passing additional classes
const blockClassNameWithMixin = styles(null, 'foo') // => 'button foo'
const modifierAndMixinClassName = styles({ disabled: true, theme: 'danger' }, 'foo') // => 'button button_disabled button_theme_danger foo'

Element classes

Element classes generation is similar to block with only one difference - you should call property corresponding to element name on the root style object.

.header {
  // base header styles
}

.header__navigation {
  // navigation element styles
}

.header__navigation_collapsed {
  // collapsed navigation styles
}
import styles from './styles.css'

const elemClassName = styles.navigation() // => 'header__navigation'
const elemAndAllAllAll = styles.navigation({ collapsed: true }, 'bar') // => 'header__navigation header__navigation_collapsed bar'

Api

styles(mods, mixins)

Generate block class names with specified mods and mixins

Parameter | Type | Description
------------------|-------------------------------|----------------------------------------------------------------------------- mods | object | Dictionary of modifiers to set
mods[key] | string | Modifier name
mods[key][value]| string / boolean | Modifier value (modifiers with falsy values won't be included in the output) mixins | string / array / object | Mixin class in any format suitable for amazing yet simple classnames lib

styles[elemName](elemMods, mixins)

Generate element class names of given block with specified mods and mixins.