All Projects → bredele → spruceup

bredele / spruceup

Licence: MIT license
Spruce up CSS classes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to spruceup

openmoji-awesome
CSS classes to easily integrate Openmoji in your website!
Stars: ✭ 19 (+58.33%)
Mutual labels:  classes
SoftUni-Software-Engineering
SoftUni- Software Engineering
Stars: ✭ 47 (+291.67%)
Mutual labels:  classes
react-native-use-styles
A classy approach to manage your react native styles.
Stars: ✭ 66 (+450%)
Mutual labels:  classes
HostsFileManagement
Hosts file management on Windows systems using PowerShell classes
Stars: ✭ 25 (+108.33%)
Mutual labels:  classes
lua-classy
Class-based OO library for Lua
Stars: ✭ 28 (+133.33%)
Mutual labels:  classes
MulleObjC
💎 A collection of Objective-C root classes for mulle-objc
Stars: ✭ 50 (+316.67%)
Mutual labels:  classes
Attrs
Python Classes Without Boilerplate
Stars: ✭ 3,786 (+31450%)
Mutual labels:  classes
tailwind-cascade
Override TailwindCSS classes for component composition
Stars: ✭ 28 (+133.33%)
Mutual labels:  classes
The-Java-Workshop
A New, Interactive Approach to Learning Java
Stars: ✭ 65 (+441.67%)
Mutual labels:  classes
postcss-typed-css-classes
PostCSS plugin that generates typed entities from CSS classes for chosen programming language.
Stars: ✭ 12 (+0%)
Mutual labels:  classes
claxed
Classes with the same style of Styled-Components
Stars: ✭ 17 (+41.67%)
Mutual labels:  classes
jvm-dump-proxy
A proxy DLL for Windows to dump JVM classes at JNI level
Stars: ✭ 53 (+341.67%)
Mutual labels:  classes
Heir
Helper functions for prototypical inheritance in JavaScript
Stars: ✭ 61 (+408.33%)
Mutual labels:  classes
ta-json
Type-aware JSON serializer/parser
Stars: ✭ 67 (+458.33%)
Mutual labels:  classes

Spruce up

Build Status NPM Downloads pledge

Spruce up is a simple JavaScript function for conditionally and elegantly concatenate CSS classes. Spruce up supports:

  • Primitives: Returns a string that is the result of joining all primitives passed to the the function. Booleans and falsy values are exempted!
  • Arrays: Evaluate and join all elements of an array as classes.
  • Functions: Evaluate functions and concatenate their output as a class name.
  • Objects: Objects are looped through and used to conditionally add classes.

Spruce up is particularly useful with React and support all main stream browsers.

Usage

import classes from 'spruceup'

classes('hello', 'world')
// => 'hello world'

classes('hello', () => 'world')
// => 'hello world'

classes('hello', null, 0, '', 'world')
// => 'hello world'

classes('hello', ['world', null, 'and', 0], 'universe')
// => 'hello world and universe'

classes('hello', {
  world: false,
  universe: true
})
// => hello universe

Here's a simple example using a React component.

import classes from 'spruceup'

function Button (props) {
  const {label, ...styles} = props
  return ('
    <button className={classes('button', styles, ['primary', 'btn'])}></button>
  )
}

Installation

npm install spruceup --save

NPM

Question

For questions and feedback please use our twitter account. For support, bug reports and or feature requests please make sure to read our community guideline and use the issue list of this repo and make sure it's not present yet in our reporting checklist.

Contribution

This is an open source project and would not exist without its community. If you want to participate please make sure to read our guideline before making a pull request. If you have any spruceup related project, component or other let everyone know in our wiki.

License

The MIT License (MIT)

Copyright (c) 2016 Olivier Wietrich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].