Skip to content
This repository has been archived by the owner on Jul 4, 2019. It is now read-only.

jxnblk/jsxcss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsxcss

Experimental

Function to transform JSX style prop into CSS with support for pseudo classes and media queries

Getting Started

Use with Hyperscript

npm i -D jsxcss babel-transform-react-jsx

.babelrc

{
  "presets": [
    "es2015",
    "stage-0"
  ],
  "plugins": [
    [
      "transform-react-jsx", {
        "pragma": "hcss"
      }
    ]
  ]
}
import { hcss } from 'jsxcss'

const MyComponent = (props) => {
  const sx = {
    root: {
      color: 'tomato',
      ':hover': {
        color: 'blue'
      }
    }
  }

  return (
    <div style={sx.root}>
      Hello!
    </div>
  )
}

export default MyComponent

Use with React

Coming soon

How it Works

Jsxcss exports functions for use with React or Hyperscript.

It then takes the style prop and passes it to Aphrodite's StyleSheet.create function and applies appropriate classNames to the function.

MIT License


To do

  • Plain hyperscript version
  • Nestable hyperscript jsx (use preact's function)
  • Make configuration work
  • Fix babel preset

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published