--
Every React component gets a javascript constructor for functional logic.
Introducing the css constructor for styling!
import React from 'react';
import css from 'css-constructor';
export default class Hello extends React.Component {
/* javascript constructor */
constructor (props) {
super(props);
}
/* css constructor */
@css`
font-size: 16px;
text-align: center;
color: #5AF78E;
font-family: monospace;
`
render () {
return <div>Styled text!</div>
}
};
--
Features:
π Supports real css
π₯ use props in css
πΌ Attaches inline styles to the highest element in your component
π Offical library emoji
--
Coming soon
π classes instead of inline styles
π pseudo selectors
π± media queries support
πͺ nested css
--
-
npm install css-constructor --save
-
Add a
@css
block just before therender
function (important) -
Add
transform-decorators-legacy
as the firstplugin
in your.babelrc
. It is already downloaded with π; If you are not familiar withbabel plugins
you can follow the detailed instructions here.
You can start using this right away. Even though π is in BETA
, the @css
block will always look the same.
π uses ES7 class function decorators on the render function. I'll probably write a detailed post about it.
Heavily inspired from glamor, styled-components and radium
If you think π is useful for your project, βοΈ this repo for my motivation ππ»