All Projects โ†’ siddharthkp โ†’ Css Constructor

siddharthkp / Css Constructor

Licence: mit
๐Ÿ’„ CSS constructor for React components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Css Constructor

Blog
ไธ€่ˆฌไธไผšๅ†™ API ็ฑปๆ–‡็ซ ๏ผŒๅŠชๅŠ›ๅ†™ๆœ‰่ฅๅ…ป็š„ๆ–‡็ซ ๏ผŒๅ–œๆฌข่ฏท็‚น star
Stars: โœญ 146 (+50.52%)
Mutual labels:  decorators, css-in-js
Match Media
Universal polyfill for match media API using Expo APIs on mobile
Stars: โœญ 95 (-2.06%)
Mutual labels:  css-in-js
Moo Css
ๆจกๅ—ๅŒ–้ขๅ‘ๅฏน่ฑก็š„cssๅ†™ๆณ•่ง„่Œƒ็ญ–็•ฅใ€‚้€‚็”จไบŽๅคงไธญๅฐๅž‹C็ซฏ้กน็›ฎๆ ทๅผๅผ€ๅ‘๏ผŒๆ—จๅœจๆ้ซ˜ๅผ€ๅ‘ๅ’Œ็ปดๆŠคๆ•ˆ็Ž‡ใ€‚
Stars: โœญ 79 (-18.56%)
Mutual labels:  css-in-js
Scale
The Scale library offers a set of customizable web components written with Stencil.js & TypeScript. The default theme of the library can be easily replaced so that a corresponding corporate identity of a dedicated brand can be represented.
Stars: โœญ 87 (-10.31%)
Mutual labels:  css-in-js
React Inform
Simple controlled forms with validations in react
Stars: โœญ 81 (-16.49%)
Mutual labels:  decorators
React Usestyles
๐Ÿ– Style components using React hooks. Abstracts the styling library away.
Stars: โœญ 89 (-8.25%)
Mutual labels:  css-in-js
React Jss
JSS integration for React (Migrated to a Monorepo it JSS repository)
Stars: โœญ 1,212 (+1149.48%)
Mutual labels:  css-in-js
Jest Glamor React
Jest utilities for Glamor and React
Stars: โœญ 97 (+0%)
Mutual labels:  css-in-js
Glamorous Primitives
๐Ÿ’„ style primitive React interfaces with glamorous
Stars: โœญ 91 (-6.19%)
Mutual labels:  css-in-js
Compiled
A familiar and performant compile time CSS-in-JS library for React.
Stars: โœญ 1,235 (+1173.2%)
Mutual labels:  css-in-js
Nano Style
React functional CSS-in-JS
Stars: โœญ 85 (-12.37%)
Mutual labels:  css-in-js
React Image Smooth Loading
[not maintained] Images which just flick to appear aren't cool. Images which appear smoothly with a fade like Instagram are cool
Stars: โœญ 84 (-13.4%)
Mutual labels:  css-in-js
Stylex
Write CSS-in-JS with atomic support. Like Facebook's Stylex!
Stars: โœญ 90 (-7.22%)
Mutual labels:  css-in-js
Clxx
Some lightweight H5 components and features
Stars: โœญ 79 (-18.56%)
Mutual labels:  css-in-js
Onno
Responsive style props for building themed design systems
Stars: โœญ 95 (-2.06%)
Mutual labels:  css-in-js
Horror
๐Ÿ˜ฑ React HTML elements with CSS-in-JS
Stars: โœญ 78 (-19.59%)
Mutual labels:  css-in-js
Lit Element Router
A LitElement Router (1278 bytes gzip)
Stars: โœญ 85 (-12.37%)
Mutual labels:  decorators
Multitasking
Non-blocking Python methods using decorators
Stars: โœญ 87 (-10.31%)
Mutual labels:  decorators
Rockey
Stressless CSS for components using JS. Write Component Based CSS with functional mixins.
Stars: โœญ 97 (+0%)
Mutual labels:  css-in-js
Utils Decorators
Decorators for web and node applications
Stars: โœญ 95 (-2.06%)
Mutual labels:  decorators

CSS constructor for React

 

Every React component gets an inbuilt javascript constructor for functional logic.

Introducing the css constructor for styling!

   

import React from 'react';
import css from 'css-constructor';                  // ๐Ÿ‘ถ Super tiny: only 1.2K gzipped!

export default class Hello extends React.Component {

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

    /* css constructor */                           
    @css`                                           // ๐Ÿ”’ Isolated and co-located
        font-size: 16px;                            
        text-align: center;                         // ๐ŸŽ€ Supports the entirety of CSS

        color: {this.props.color};                  // ๐Ÿ”ฅ Use props in css

        display: flex;                              // ๐Ÿ’ป Built in vendor prefixing

        &:hover {                                   // ๐ŸŒ€ Pseudo selectors
            color: #FFF;
        }

        img {                                       // ๐Ÿ‘ช Nested css
            border-radius: 50%;
        }
        #handle {
            margin-top: 20px;
        }

        @media (max-width: 600px) {                 // ๐Ÿ“ฑ Media queries support
            & {font-size: 18px;}
        }
    `

    render () {
        return (<div>                               // ๐Ÿ”ผ Attaches class to the highest element
            <img src="https://github.com/siddharthkp.png"/>
            <div id="handle">@siddharthkp</div>
        </div>)
    }
};

// <Hello color='papayawhip'/>

--

Other features

๐Ÿ™‹ Uses classes instead of inline styles

๐Ÿ”ง Editable in developer tools

๐Ÿ‘ถ Super tiny: only 1.2K gzipped!

๐Ÿ’„ Official library emoji

Coming soon

๐ŸŒ server side rendering

--

Usage

  1. npm install css-constructor --save

  2. import css from 'css-constructor'

  3. Add a @css block just before the render function (important)

  4. Add transform-decorators-legacy as the first plugin in your .babelrc (already downloaded with ๐Ÿ’„).

If you are not familiar with babel plugins you can follow the detailed instructions here.

Or, if you would prefer using ๐Ÿ’„ without adding the babel transform for decorators, up-vote this issue.

--

How does it work?

๐Ÿ’„ uses ES7 class method decorators on the render function. Detailed post coming soon.

Inspiration

Heavily inspired from glamor, styled-components and radium

Special thanks to thysultan. stylis is the bomb!

Support

โญ๏ธ this repo!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].