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

sass-bem

v2.6.5

Published

Amazing package for sass to write bem classes, with namespaces and more advanced features.

Downloads

131

Readme

sass-bem

Please upgrade to version 2.6.0, we have some great features. Thanks to @szalonna and @MartinN3 resolved issue in documentation and updated some mixins.

TEST RESULTS: 124 Tests, 82 Passed, 0 Failed, 42 Output to CSS

Bower NPM

| sass-bem | | |:----------:|:----| | sass-bem | Amazing package for sass to write bem classes, with namespaces and more advanced features. Pull requests are welcome :tada: |

Table of Contents

Installation

Install with bower or npm

$ bower install sass-bem --save

$ npm install sass-bem --save

or install manually

What? Why? How?

I was inspired to create this package, after I read an article "More Transparent UI Code with Namespaces" written by Harry Roberts.

Also I can't miss about bem, methodology for creating amazing html & css classes. If you don't know about it, you really should read more and get informed about bem.

What about this package? This is great tool, if you want to stay strict at writing code. If you want your code to be more readable and easy to maintenance. If you want to be advanced in writing sass, install this package and became pro.

Why do I love this package? When I'm writing with sass-bem I'm always strict to use same structure each time. I'm in love with all of its features, but two of them are most amazing.

  • First one is parse, also known as p mixin. You can pass list of mixins, selectors, pseudo elements and etc. You will get comma separated selectors in your css file. You can pass "m:inline", this will call m mixin with parameter "inline", so you will get &--inline. You can also use & at your will.

  • Second one is very helpfull to write more code in less time. You can define shortcodes to use in parse mixin. For example, you can define "fha" as list of "focus", "hover", "active", and when you call parse('fha'), you will get pre-defined list parsed.

I suggest you to create "ha" and "lv" shortcuts, for "hover", "active" and "link", "visited", just like HATE & LOVE. Also you can create shortcut called something like "dsbld", which will cover "disabled", "is:disabled" mixins. This one will be generated as &[disabled], &.is-disabled, because of disabled mixin and is mixin with param "disabled". Keep playing with shortcuts. :stuck_out_tongue_closed_eyes:

How to use package? Simply @import "bem" at the very beggining of your sass/scss main file, configure some parameters at your will, and enjoy with great features.

Looking for configuration docs? Visit your documentation website, and look at variables section. You will find $bem map, where you can see all parameters. Or scroll down to see how to change them separately.

Example

Let's work on Nicole Sullivan's post, about media object.

index.html

<div class="o-media">
  <a href="#" class="o-media__image">
    <img src="#" class="o-media__thumb" alt="Thumb" />
  </a>
  <!-- /.o-media__image -->

  <div class="o-media__body">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
    dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip 
    ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore 
    eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia 
    deserunt mollit anim id est laborum.
  </div>
  <!-- /.o-media__body -->
</div>
<!-- /.o-media -->

app.scss

@import "node_modules/sass-bem/bem";

// coding...
@include object('media') { // or o('media')
  margin: 10px;
  
  @include parse('&', 'e:body') { // or p('&', 'e:body')
    overflow:hidden;
    _overflow:visible;
    zoom:1;
  }
  
  @include element('image') { // or e('image')
    float:left;
    margin-right: 10px;
    
    @include at('rtl') { // .o-media--rtl .o-media__image
      float: right;
      margin-left: 10px;
      margin-right: 0;
    }
  }
    
  @include element('thumb') { // or e('thumb')
    display: block;
  }
}

app.css

.o-media {
  margin: 10px;
}

.o-media,
.o-media__body {
  overflow: hidden;
  _overflow: visible;
  zoom: 1;
}

.o-media__image {
  float: left;
  margin-right: 10px;
}
  
.o-media--rtl .o-media__image {
  float: right;
  margin-left: 10px;
  margin-right: 0;
}

.o-media__thumb {
  display: block;
}

Result

More examples here and even more will come soon...

Wiki

We would recomend you to read full documentation in our website: http://zgabievi.me/sass-bem/

Still prefer Wiki? Then follow this table of contents or go to our Wiki page.

License

The sass-bem package is open-sourced software licensed under the MIT license.