Skip to content
/ BemIt Public

A BEM(Block Element Modifier) classes generator.

Notifications You must be signed in to change notification settings

capdiem/BemIt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BemIt

A BEM(Block Element Modifier) classes generator.

BEM — is a methodology that helps you to create reusable components and code sharing in front‑end development.

Getting Started

Prerequisites

NET 6.0 or later

Installing

dotnet add package BemIt

Usage

using BemIt;

var card = new Block("card"); // card
var outlinedCard = card.Modifier("outlined"); // card--outlined
var cardTitle = card.Element("title"); // card__title
var largeCardTitle = cardTitle.Modifier("large"); // card__title--large
using BemIt;

enum Density
{
    Dense,
    Comfortable,
    Compact,
}

var outlined = true;
var isDisabled = true;
var density = Density.Dense;

var cardModifierBuilder = new Block("card")
    .CreateModifierBuilder()
    .Add(outlined)
    .Add("disabled", isDisabled)
    .Add(density)
    .AddClass("theme--light");

var cardClasses = cardModifierBuilder.Build();
// output: card card--outlined card--disabled card--density-dense theme--light