๐ŸŽ This small function allows you to manage class names
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commitโ€ฆ
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lang/es Initial commit Jan 10, 2018
.gitattributes Initial commit Jan 10, 2018
LICENSE Initial commit Jan 10, 2018
README.md Initial commit Jan 10, 2018
index.js Initial commit Jan 10, 2018
package.json Initial commit Jan 10, 2018

README.md

as-cn

This small function allows you to manage class names

Mode 1

In this way, you can extract names of an object using the index, which has a definition check.

import {h}   from 'preact';
import cn    from 'as-cn';
import './style.css';

export default function(){
   return <div class={
           cn({
               box : true
           })
       }>
   </div>
}

// <div class="box"></div>

Mode 2

In this way you can extract names of a module by means of a parallel object that points to each property of the module object.

import {h}   from 'preact';
import cn    from 'as-cn';
import style from './style.css';

export default function(){
   return <div class={
           cn(style,{
               box : true
           })
       }>
   </div>
}
// <div class="box"></div>