You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Treat classList string as space seperated class list(e.g. in <div class="abc efg">),
Replace all seperated word by localized version. (without dot)
The classList can be 'nav item', or '.nav .item' form, all . will be replaced by space.
The returned class string is .trim()ed, you need polyfill this method if you want support IE < 9.
Above 2 method both can accept .!class1 .!class2 escaped for global space.
Usage
- Localize
varlocalize=require('cssobj-plugin-localize')varret=cssobj({'.item': {color: 'red'}},{plugins:[localize()]})// css is => ._1hisnf23_item {color: red;}// you can get the mapped selector using:ret.mapSel('.nav .item')// === ._1hisnf23_nav ._1hisnf23_item// you can get the mapped class list using:// (used in className attributes for HTML tag)ret.mapClass('.nav .item')// === _1hisnf23_nav _1hisnf23_itemret.mapClass('nav item')// === _1hisnf23_nav _1hisnf23_item
- Global
There's a way to make class Global
- .!className
Just add ! in front of class name, if you want it global.
varret=cssobj({'body .!nav .!item .login': {color: 'red'}},{plugins:[localize()]})// css is => body .nav .item ._1hisnf23_login {color: red;}
- Custom Prefix
You can control the space:
varret=cssobj({'body .nav .item .login': {color: 'red'}},{plugins:[localize('_your_space_')]})// css is => body ._your_space_nav ._your_space_item ._your_space_login {color: red;}
- Custom Local Names
You can control the map for each class name:
varret=cssobj({'body .nav .!item .login': {color: 'red'}},{plugins:[localize(null,{nav: '_abc_'})]})// css is => body ._abc_ .!item ._1hisnf23_login {color: red;}