Skip to content

Latest commit

 

History

History

styles

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Styles

Utilities to work with styles.

Installation

npm install @enzsft/styles

Usage

Concatenate styles and optimise whitespace and conditionally apply styles.

import { clsx } from "@enzsft/styles";

clsx("one", "two", "three");
// one two three

clsx("one", false && "two", "three");
// one three

Apply the first truthy style.

import { fclsx } from "@enzsft/styles";

fclsx("one", "two", "three");
// one

fclsx(false && "one", false && "two", "three");
// three

Build styles from an object.

import { oclsx } from "@enzsft/styles";

const styles = oclsx({
  one: "one",
  two: "two",
  three: "three",
});

styles({
  one: true,
  two: false,
  three: true,
});
// one three

styles({
  three: true,
});
// three