Giter VIP home page Giter VIP logo

postcss-spiffing's Introduction

postcss-spiffing

My hands are of your colour, but I shame
To wear a heart so white.
- William Shakespeare, Macbeth

Shakespeare wouldn't have settled for using "color" rather than "colour" in CSS, and neither should you! He would've recognised that in doing so, he would've comprised the whole integrity of his writing.

Write CSS using proper British English anywhere with postcss-spiffing.

The main differences between this and spiffing by muan, are that this integrates with postcss and does not use regular expressions.

Install

npm install postcss-spiffing --save-dev

Example

/* Your well-spelt CSS */

body {
  background-colour: grey;
  transparency: 0.3;
  text-align: centre;
  text-transform: capitalise;
  border: 1px solid grey;
}

span {
  font-weight: plump;
}

.frame {
  background-photograph: url("/queen.png") !please;
}

.hello {
	content: "subjects";
	colour: grey;
}

will go to:

body {
  background-color: gray;
  opacity: 0.7;
  text-align: center;
  text-transform: capitalize;
  border: 1px solid gray;
}

span {
  font-weight: bold;
}

.frame {
  background-image: url("/queen.png") !important;
}

.hello {
	content: "subjects";
	color: gray;
}

Use

var postcss = require("postcss");
var spiffing = require("postcss-spiffing");
var fs = require("fs");

var css = fs.readFileSync("random.css");

console.log(postcss(spiffing()).process(css).css);

To use this with gulp, use gulp-postcss.

Changes Applied

  1. colour goes to color
  2. plump goes to bold
  3. capitalise goes to capitalize
  4. !please goes to !important
  5. centre goes to center
  6. grey goes to gray
  7. background-photograph goes to background-image (list-style-photograph is supported too)
  8. transparency goes to opacity (since transparency is the opposite of opacity it becomes (1-n))
  9. storey goes to z-index (ground equals 1 and so on)

postcss-spiffing's People

Contributors

arku avatar davguij avatar hashanp avatar igoradamenko avatar myhlamaeus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

postcss-spiffing's Issues

Transparency vs Opacity

Transparency is the opposite of opacity. The opacity value should be 1-n for transparency value n. Opaqueness might be a better choice.

!please; isn't working in my setup

Hi,

All rules are working other than !please; - which is the only one that I want!


I’ve tested it thoroughly and reduced it down to these code examples:

gulpfile.js

gulp.task('styles', function () {
  return gulp.src('source/styles/main.scss')
    .pipe(sass())
    .pipe(postcss([
      spiffing()
    ]))
    .pipe(gulp.dest('./dist'))
})

SCSS

.frame {
  background-photograph: url("/queen.png") !please;
}

Console error:

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: source/styles/main.scss
Error: Invalid CSS after '...l("/queen.png")': expected expression (e.g. 1px, bold), was "!please;"
        on line 18 of source/styles/_trumps.iframe-embed.scss
>>   background-photograph: url("/queen.png") !please;
   ------------------------------------------^

package.json

"gulp": "^3.9.0",
"gulp-postcss": "^6.1.1",
"postcss-spiffing": "^0.1.0",

Has anyone else had this particular issue? Any help would be appreciated. Thanks! :octocat:

Example for utilizing ES6 Modules

Hello, I think an example of how to use the plugin with es6 modules could be helpful. Here's an proposal:

Use (ES6)

import postcss from 'postcss';
import spiffing from 'postcss-spiffing';
import * as fs from 'fs';

const css = fs.readFileSync('random.css');

console.log(postcss(spiffing()).process(css).css);

Maybe a section about loading ES6 modules in node with ESM (https://github.com/standard-things/esm) might be helpful, too:

Execute in Node >= 13

// Execute directly
node main.js

// Execute via npm scripts
// package.json
{
  ...
  "type": "module",
  "scripts": {
    "convert": "node main.js"
  }
  ....
}
// Command line
npm run convert
yarn convert

Update postcss version, tests and so on

Hi!

I wanted to fix #2 and also noticed that plugin depends on old version of postcss and also I couldn't run tests without errors. Can I update all of that in one PR or I should to create several PRs?

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.