Code Monkey home page Code Monkey logo

postcss-all-link-colors's Introduction

postcss-all-link-colors

NPM version npm license Travis Build Status codecov Dependency Status

npm

PostCSS plugin to insert colors for link-related pseudo-classes.

Introduction

Adding link-related pseudo-classes can be a total pain. Just look at how much garbage we have to write!

a {
	color: red;
}
a:visited {
	color: red;
}
a:focus {
	color: red;
}
a:hover {
	color: red;
}
a:active {
	color: red;
}

This plugin allows you to simplify the above syntax into the following:

a {
	@link-colors all red;
}

You can override individual pseudo-classs like so:

a {
	@link-colors all red {
		focus: white;
		hover: blue;
	}
}

This transpiles into:

a {
	color: red;
}
a:visited {
	color: red;
}
a:focus {
	color: white;
}
a:hover {
	color: blue;
}
a:active {
	color: red;
}

Of course, you don't have to color all link-related pseudo-classes if you don't want. Just get rid of the all parameter to make the colors inclusive:

a {
	@link-colors red {
		hover: white;
	}
}

This transpiles into:

a {
	color: red;
}
a:hover {
	color: white;
}

Link-related pseudo-classes are written in LVHA-order: :link:visited:hover:active with the following variations:

  • The :link pseudo-class is replaced by just color, as it covers not only links, but buttons and other elements as well.
  • The :focus pseudo-class is placed before or after :hover, depending on the order in which you specify it; thus, the desired effect.

Installation

$ npm install postcss-all-link-colors

Usage

JavaScript

postcss([ require('postcss-all-link-colors') ]);

TypeScript

import * as postcssAllLinkColors from 'postcss-all-link-colors';

postcss([ postcssAllLinkColors ]);

Options

None at this time.

Testing

Run the following command:

$ npm test

This will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.

Watching

For much faster development cycles, run the following commands in 2 separate processes:

$ npm run build:watch

Compiles TypeScript source into the ./dist folder and watches for changes.

$ npm run watch

Runs the tests in the ./dist folder and watches for changes.

Similar projects

postcss-all-link-colors's People

Contributors

jedmao avatar jednano avatar

Stargazers

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

Watchers

 avatar  avatar  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.