Skip to content

Commit

Permalink
Rename u-css to greens
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Valls Fernández committed Oct 30, 2016
1 parent 8b5ed19 commit 945d636
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# CSS
# Greens
[![Build Status][ci-img]][ci-url] [![Coverage Status][cover-img]][cover-url]

## Sample usage

```javascript
var css = require('u-css'),
var css = require('greens')(),

bodyRule = css.add('body',{
backgroundColor: 'black',
Expand Down Expand Up @@ -33,7 +33,7 @@ rot50 = rotation.add('50%',{
rotation.remove(rot50); // Remove the rule
```

[ci-img]: https://circleci.com/gh/manvalls/u-css.svg?style=shield
[ci-url]: https://circleci.com/gh/manvalls/u-css
[cover-img]: https://coveralls.io/repos/manvalls/u-css/badge.svg?branch=master&service=github
[cover-url]: https://coveralls.io/github/manvalls/u-css?branch=master
[ci-img]: https://circleci.com/gh/manvalls/greens.svg?style=shield
[ci-url]: https://circleci.com/gh/manvalls/greens
[cover-img]: https://coveralls.io/repos/manvalls/greens/badge.svg?branch=master&service=github
[cover-url]: https://coveralls.io/github/manvalls/greens?branch=master
2 changes: 1 addition & 1 deletion check.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var css = require('./main'),
var css = require('./main')(),
check,style;

style = css.addClass().style;
Expand Down
43 changes: 39 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/**/ 'use strict' /**/
var apply = require('u-proto/apply'),
sheet = Symbol(),
var sheet = Symbol(),
parent = Symbol(),
style = Symbol(),

RE = /[A-Z]|(^(webkit|moz|ms|o)(?=[A-Z]))/g,
atRE = /^(@[^ {]+)(.*)$/;
atRE = /^(@[^ {]+)(.*)$/,
apply;

// CssGroup

class CssGroup{

Expand Down Expand Up @@ -94,6 +99,32 @@ class CssGroup{

}

// Css

class Css extends CssGroup{

constructor(p){
var elem = p.ownerDocument.createElement('style');

super();
this[style] = elem;
this.attach(p);
this[sheet] = elem.sheet;
}

detach(){
this[parent].removeChild(this[style]);
}

attach(p){
this[parent] = p;
p.appendChild(this[style]);
}

}

// Utils

function addRule(sheet,rule){
if(sheet.insertRule) sheet.insertRule(rule,sheet.cssRules.length);
else sheet.appendRule(rule);
Expand All @@ -116,4 +147,8 @@ function JSONtoCSS(obj){
return ret;
}

module.exports = new CssGroup(require('./sheet.js'));
module.exports = function(parent){
return new Css(parent || global.document.head);
};

apply = require('u-proto/apply');
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "u-css",
"version": "2.2.1",
"name": "greens",
"version": "1.0.0",
"description": "Dynamic css helpers",
"main": "main.js",
"dependencies": {
Expand All @@ -14,10 +14,10 @@
},
"repository": {
"type": "git",
"url": "git://github.com/manvalls/u-css.git"
"url": "git://github.com/manvalls/greens.git"
},
"bugs": {
"url": "https://github.com/manvalls/u-css/issues"
"url": "https://github.com/manvalls/greens/issues"
},
"author": "Manuel Valls Fernández <manolo@vlrz.es>",
"license": "LGPL-3.0"
Expand Down
3 changes: 0 additions & 3 deletions sheet.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/main.br.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var t = require('u-test'),
getKey = require('../get-key.js'),
getValue = require('../get-value.js'),
getPair = require('../get-pair.js'),
css = require('../main.js');
css = require('../main.js')();

t('Basic class',function(){
var div = document.createElement('div'),
Expand Down

0 comments on commit 945d636

Please sign in to comment.