fuzzy-rucksack

1.0.3 • Public • Published

fuzzy-rucksack

Some tools to help on your fuzzy-chainsaw adventures.

Install

npm install fuzzy-rucksack --save-dev

Documentation

createVariants(prefix, variants)

Creates an array of classNames from a space seperated variants string.

Example

createVariants('box--', 'round large dark');
 
/* output */
['box--round', 'box--large', 'box--dark']

createClassName(classNameArray)

Creates a className string based on input arrays. skips undefined values and flattens array entries.

Example

createClassName([
    'box',
    ['box--round', 'box--large'],
    props.isActive ? 'box--is-active' : undefined,
    props.className
]);
 
/* props */
{ isActive: true, className: 'js-extra' }
 
/* output */
'box box--round box--large box--is-active js-extra'

PropTypes.variants(variantArray)

Validates that all variants in a space seperated string are valid.

Useage

const Button = ({ variant }) => (
    <div className={createVariants('box--', variant)} />
);
 
Button.propTypes = {
    variant: PropTypes.variants(['round', 'large', 'dark'])
}
 
/* valid */
<Button variant="round" />
<Button variant="large dark" />
 
/* invalid */
<Button variant="utlra" />
<Button variant="big dark" />
<Button variant="round ultra dark" />

License

MIT Copyright ConnectiveDX 2016

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    0
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i fuzzy-rucksack

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • krambuhl