Skip to content

Function to ease the process of writing and reading of classes in JSX and TSX code

Notifications You must be signed in to change notification settings

Andrewmat/join-classes-x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

join-classes-x

Simple functions to ease the process of joining classes in jsx and tsx files.

Usage

This module contains currently 2 functions:

  • joinClasses()
  • joinClasses.withModule()

joinClasses()

joinClasses simply joins multiple classes with space as separator

const joinClasses = require('join-classes-x');

// ...

<Component className={joinClasses('input', 'input-disabled')}/>  // -> 'input input-disabled'

joinClasses.withStyle(style)

joinClasses.withStyle() attaches a style module to improve code legibility.

const joinClasses = require('join-classes-x');
const styles = require('./style.scss');

const classes = joinClasses.withStyle(styles);

// ...

<Component className={classes('button', 'button-primary')}/>   // -> 'component__button component__button-primary'
<Component className={classes('button', 'button-secondary')}/> // -> 'component__button component__button-secondary'
<Component className={classes('button', 'button-disabled')}/>  // -> 'component__button component__button-disabled'

About

Function to ease the process of writing and reading of classes in JSX and TSX code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published