GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - rebem/css: :dizzy: BEM syntax for CSS

This repository was archived by the owner on Aug 19, 2019. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
test
test
 
 
.babelrc
.babelrc
 
 
.editorconfig
.editorconfig
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
license.md
license.md
 
 
package.json
package.json
 
 
readme.md
readme.md
 
 

Repository files navigation

maintenance npm travis coverage deps gitter

BEM syntax for CSS.

Overview

Dead simple

It just replaces substrings in selectors:

:block()

:block(block) {}
.block {}

:elem()

:block(block):elem(elem) {}
.block__elem {}

:mod()

:block(block):mod(mod) {}
.block_mod {}

:block(block):mod(mod val) {}
.block_mod_val {}
:block(block):elem(elem):mod(mod) {}
.block__elem_mod {}

:block(block):elem(elem):mod(mod val) {}
.block__elem_mod_val {}

CSS compatible

It's just a custom pseudo-classes, so you can use it with Less or any other CSS preprocessor:

:block(block) {
    &:mod(mod) {

    }

    &:elem(elem) {
        &:mod(mod val) {

        }
    }
}

Usage

rebem-css is a PostCSS plugin.

CLI

npm i -S postcss postcss-cli rebem-css
postcss --use rebem-css test.css -o test.css

API

npm i -S postcss rebem-css
import postcss from 'postcss';
import reBEMCSS from 'rebem-css';

console.log(
    postcss([ reBEMCSS ]).process(':block(block) {}').css
);
// .block {}

webpack

npm i -S postcss postcss-loader rebem-css
import reBEMCSS from 'rebem-css';

export default {
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: 'style!css!postcss'
            }
        ]
    },
    postcss() {
        return [ reBEMCSS ];
    }
};

Custom delimeters

Default delimeters are _ for modifiers and __ for elements, but you can change it with special environment variables. For example in webpack you can do this with DefinePlugin:

plugins: [
    new webpack.DefinePlugin({
        'process.env': {
            REBEM_MOD_DELIM: JSON.stringify('--'),
            REBEM_ELEM_DELIM: JSON.stringify('~~')
        }
    })
]

About

💫 BEM syntax for CSS

Resources

Readme
MIT license
Activity
Custom properties

Stars

10 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.