0.0.32 • Published 2 years ago

easier-class v0.0.32

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

easier-class

easier-class is a small Javascript ultility for working with classes.

Examples

import createClass, { createClassStr } from "easier-class";

const condition = false;

// Concat classes, and return a string
const container2Class = createClassStr(
  "class-1", "class-2",
  // will add class-3 if condition is true/not undefined/not null
  condition && "class-3"
) // => "class-1 class-2"

// Return an util object with "add/toString" functions
const containerClass = createClass(
  "class-1", "class-2",
  // will add class-3 if condition is true/not undefined/not null
  condition && "class-3"
);

containerClass.add("class-4");

// return a string with added classes
containerClass.toString(); // => "class-1 class-2 class-4"

Installation

easier-class is available via npm packages. You can install easier-class using npm or yarn

$ npm install easier-class --save

// or using yarn
$ yarn add easier-class

Features

createClass

Create class receive arguments as string, false, undefined or null, and return the util object. This util object has the following functions

  • add which allows you to add more classes
  • toString concatenate any string values and return a string

createClassStr

Create class receive arguments as string, false, undefined or null, and return a string value. Similar to calling createClass(..arguments).toString()

Feedback, question

Feel free to create a new issue to discus about easier-class

0.0.31

2 years ago

0.0.3

2 years ago

0.0.32

2 years ago

0.0.2

4 years ago

0.0.1

4 years ago