Git Product home page Git Product logo

postcss-css-in-js's Introduction

PostCSS CSS-in-JS Syntax

NPM version Build Status

Fork notes

This project was forked by Widen for two reasons:

  1. To fix some peer dependency warnings that don't apply given our setup and cause warnings with Yarn.
  2. To fix Babel parsing. Newer versions of Babel made some non-supported use cases break. We've fixed this to make stylelint work properly.

We will likely not merge our fork into the source repo due to stylelint's desire to deprecate this package eventually.

PostCSS syntax for parsing CSS in JS literals:

Getting Started

First thing's first, install the module:

npm install postcss-syntax @stylelint/postcss-css-in-js --save-dev

Use Cases

const postcss = require("postcss");
const stylelint = require("stylelint");
const syntax = require("postcss-syntax");
postcss([stylelint({ fix: true })])
  .process(source, { syntax: syntax })
  .then(function (result) {
    // An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
    result.content;
  });

input:

import glm from "glamorous";
const Component1 = glm.a({
  flexDirectionn: "row",
  display: "inline-block",
  color: "#fff"
});

output:

import glm from "glamorous";
const Component1 = glm.a({
  color: "#fff",
  display: "inline-block",
  flexDirectionn: "row"
});

Advanced Use Cases

Add support for more css-in-js package:

const syntax = require("postcss-syntax")({
  "i-css": (index, namespace) => namespace[index + 1] === "addStyles",
  "styled-components": true
});

See: postcss-syntax

Style Transformations

The main use case of this plugin is to apply PostCSS transformations to CSS code in template literals & styles as object literals.

postcss-css-in-js's People

Contributors

abalmos avatar abdonrd avatar abraham avatar ai avatar bartlangelaan avatar bpscott avatar chuuddo avatar dependabot[bot] avatar gucong3000 avatar hudochenkov avatar jacobrienstra avatar jeddy3 avatar mattxwang avatar mccleanp avatar ota-meshi avatar puku0x avatar vankop avatar web-padawan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.