Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jss

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

bin/cssToJss.js

73

bin/cli.js
#!/usr/bin/env node
var css = require('css')
var fs = require('fs')

@@ -8,59 +7,2 @@ var path = require('path')

/**
* Convert rules from css ast to jss style.
*
* @param {Array} cssRules
* @return {Object}
*/
function toJss(cssRules) {
var jssRules = {}
function addRule(rule, rules) {
var key, style = {}
key = rule.selectors.join(', ')
rule.declarations.forEach(function (decl) {
style[decl.property] = decl.value
})
rules[key] = style
}
cssRules.forEach(function (rule) {
switch (rule.type) {
case 'rule':
addRule(rule, jssRules)
break
case 'media':
var key = '@media ' + rule.media
var value = {}
rule.rules.forEach(function(rule) {
addRule(rule, value)
})
jssRules[key] = value
break
case 'font-face':
var key = '@' + rule.type
var value = {}
rule.declarations.forEach(function (decl) {
value[decl.property] = decl.value
})
jssRules[key] = value
break
case 'keyframes':
var key = '@' + rule.type + ' ' + rule.name
var value = {}
rule.keyframes.forEach(function (keyframe) {
var frameKey = keyframe.values.join(', ')
var frameValue = {}
keyframe.declarations.forEach(function (decl) {
frameValue[decl.property] = decl.value
})
value[frameKey] = frameValue
})
jssRules[key] = value
}
})
return jssRules;
}
program

@@ -84,13 +26,10 @@ .version(require('../package.json').version)

var converters = {
'.css': require('./cssToJss')
}
;(function convert() {
var code = fs.readFileSync(program.sourcePath, 'utf-8')
var ast = css.parse(code)
if (ast.stylesheet && ast.stylesheet.rules) {
var jss = toJss(ast.stylesheet.rules)
var spaces = program.pretty ? ' ' : ''
var output = JSON.stringify(jss, null, spaces)
output = program.export + output + ';'
console.log(output)
}
var ext = path.extname(program.sourcePath)
console.log(converters[ext](code, program))
}())
{
"name": "jss",
"description": "Dynamic stylesheets for web components.",
"version": "0.8.0",
"version": "0.8.1",
"author": {

@@ -6,0 +6,0 @@ "name": "Oleg Slobodskoi",

@@ -0,1 +1,5 @@

## 0.8.1 / 2014-11-29
- support non browser env #12
## 0.8.0 / 2014-11-29

@@ -2,0 +6,0 @@

@@ -26,4 +26,8 @@ 'use strict'

this.text = ''
this.element = this.createElement()
// Don't create element if we are not in a browser environment.
if (typeof document != 'undefined') {
this.element = this.createElement()
}
for (var key in rules) {

@@ -30,0 +34,0 @@ this.createRules(key, rules[key])

{
"name": "jss",
"description": "Dynamic stylesheets for web components.",
"version": "0.8.0",
"version": "0.8.1",
"author": {

@@ -6,0 +6,0 @@ "name": "Oleg Slobodskoi",

## Dynamic style sheets for web components.
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/jsstyles/jss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -3,0 +4,0 @@ Why do we need transpilers like [sass](http://sass-lang.com/) or [stylus](http://learnboost.github.io/stylus/) when we can use javascript to do the same and much more?

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc