An open API service indexing awesome lists of open source software.

https://github.com/reubn/dragonfruit

Syntactic Sugar Over Namespaced CSS
https://github.com/reubn/dragonfruit

css css-modules hacktoberfest javascript webpack webpack-loader

Last synced: 23 days ago
JSON representation

Syntactic Sugar Over Namespaced CSS

Awesome Lists containing this project

README

          

# dragonfruit [![Build Status](https://travis-ci.org/reubn/dragonfruit.svg?branch=master)](https://travis-ci.org/reubn/dragonfruit) [![npm](https://img.shields.io/npm/v/dragonfruit.svg)](https://www.npmjs.com/package/dragonfruit) [![David](https://img.shields.io/david/reubn/dragonfruit.svg)](https://github.com/reubn/dragonfruit/blob/master/package.json) [![David](https://img.shields.io/david/dev/reubn/dragonfruit.svg)](https://github.com/reubn/dragonfruit/blob/master/package.json)
Webpack Loader for Syntactic Sugar Over Namespaced CSS

# Installation
`npm install dragonfruit --save-dev`

## e.g.

### CSS

```css
.datepicker
{
display: block;
color: black;
}
```
### JS

```javascript
var React = require("react");
var styles = require("./datepicker.css");

module.exports = React.createClass({
render: function() {
return


// This ^^ will contain a random namespaced hash that corresponds with the css class ".datepicker"

}
});
```

### __Would Be Transformed To__

```css
.kg64jk3l
{
display: block;
color: black;
}
```

```javascript
var React = require("react");
var styles = require("./datepicker.css");

module.exports = React.createClass({
render: function() {
return



}
});
```
# Usage

In your `webpack.config.js`:

```javascript

module.exports = {
...
module: {
loaders: [
{test: /\.css$/, loader: "dragonfruit!style!css?modules=true"}
]
}
...
};

```

From API:

Any Strings, Objects, Functions, Arrays, Nested Arrays, etc. of `classNames`

## e.g.

```javascript
var styles = require("./datepicker.css");

styles("day") -> "hr486_eio"
styles(["day"]) -> "hr486_eio"
styles([["day"]]) -> "hr486_eio"
styles({"day":true}) -> "hr486_eio"
styles(function(classNamesAvailable){return "day"}) -> "hr486_eio"
styles(function(classNamesAvailable){return [{"day":true}]}) -> "hr486_eio"

styles("day week") -> "hr486_eio iooi676_5hj"
styles("day", "week") -> "hr486_eio iooi676_5hj"
styles(["day", "week"]) -> "hr486_eio iooi676_5hj"
styles([["day",[[, "week"]]]]) -> "hr486_eio iooi676_5hj"
styles({"day":true, "week":true, month:false}) -> "hr486_eio iooi676_5hj"
styles(function(classNamesAvailable){return ["day", {"week": true, month:false}]}) -> "hr486_eio iooi676_5hj"

```