Skip to content

Alternative syntax (without decorators/babel transform) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
siddharthkp opened this issue Dec 11, 2016 · 0 comments
Open

Alternative syntax (without decorators/babel transform) #1

siddharthkp opened this issue Dec 11, 2016 · 0 comments
Labels

Comments

@siddharthkp
Copy link
Owner

siddharthkp commented Dec 11, 2016

Alternate syntax

✅ No decorators = no extra babel transforms
✅ CSS constructor looks like other class methods
✅ Position independent (don't have to place it right above render)
⚠️ Code is more verbose
⚠️ Adds a wrapper

import React from 'react';
import css from 'css-constructor';

class Hello extends React.Component {

    /* javascript constructor */
    constructor (props) {
        super(props);
    }

    /* css constructor */
    css (props) {
        return `
            font-size: 16px;
            text-align: center;
            color: {this.props.color};
            font-family: monospace;
        `;
    }

    render () {
        return <div>Styled {this.props.color} text!</div>
    }
};

export default css(Hello);
@siddharthkp siddharthkp changed the title Remove extra babel transform/build step Remove extra babel transform/build step? Dec 11, 2016
@siddharthkp siddharthkp changed the title Remove extra babel transform/build step? Alternative syntax (without decorators/babel transform) Dec 13, 2016
@txwizard txwizard mentioned this issue Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant