conditional-classnames.js

1.0.3 • Public • Published

conditional-classnames.js

Helper function adding one or more classnames to an element depending on the result of the condition.

Installation

$ npm install --save conditional-classnames.js

Example

import 'conditional-classnames.js';
 
// Add bar when result is higher than 10. Otherwise remove it.
const foo = document.getElementById('#foo');
const result = (Math.random() * 10) > 10;
 
foo.classlist.bool('bar', result);

Package Sidebar

Install

npm i conditional-classnames.js

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • patrickpietens