Skip to content

A simple class utility to simplify and enforce name spacing

Notifications You must be signed in to change notification settings

momotofu/compose-namespace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compose Namespace

Takes a main css class for a component and an optional overriding class or classes (array) and returns a function which constructs a class strings.

function composeNamespace(
  string, [
      string of classes,
      single classString,
      Array of classes
  ]
)

For example if given the main class of APMDrawer and the overriding class of className:

const cc = composeNamespace('APMDrawer', 'className')

cc('bg')
// 'APMDrawer-bg className-bg'

cc('bg', 'container')
// 'APMDrawer-bg className-bg APMDrawer-containter className-container'

const cc = composeNamespace('mainClass', ['jam', 'cake', 'fig'])

cc('jello', 'frosting')
// 'mainClass-jello mainClass-frosting jam-jello
jam-frosting cake-jello cake-frosting fig-jello fig-frosting'

About

A simple class utility to simplify and enforce name spacing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published