1.0.3 • Published 7 years ago

conditional-classnames.js v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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);