1.3.1 • Published 8 years ago

merge-classes v1.3.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 years ago

Function aware of CSS modules when merging CSS classes.

Installation

npm install --save merge-classes

Usage

import mergeClasses from 'merge-classes'

const SIMPLE_CLASS = 'simple-a'

const ARRAY_OF_SIMPLE_CLASSES = [
  'array-simple-1',
  'array-simple-2'
]

const CSS_MODULE = {
  style1: 'hash123-style-1',
  style2: 'hash123-style-2'
}

const ARRAY_OF_CSS_MODULES = [{
  style1: 'array-hash123-style-1',
  style2: 'array-hash123-style-2'
}, {
  style3: 'array-hash123-style-3',
  style4: 'array-hash123-style-4'
}]

// Properties with the value “false” will be skipped.
const CONDITIONAL = {
  'conditional-1': false,
  'conditional-2': true
}

console.log(
  mergeClasses(
    SIMPLE_CLASS,
    ARRAY_OF_SIMPLE_CLASSES,
    CSS_MODULE,
    ARRAY_OF_CSS_MODULES,
    CONDITIONAL
  )
)

// Output (without line breaks):
// simple-a
// array-simple-1
// array-simple-2
// hash123-style-1
// hash123-style-2
// array-hash123-style-1
// array-hash123-style-2
// array-hash123-style-3
// array-hash123-style-4
// conditional-2
1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago