0.4.3 • Published 5 years ago

postcss-button v0.4.3

Weekly downloads
104
License
MIT
Repository
github
Last release
5 years ago

postcss-button

npm version Build Status Dependency Status

NPM

francoisromain.github.io/postcss-button

A PostCSS plugin to create buttons.


This plugin outputs a lot of the repetitive css code necessary to create clean buttons. It also uses box-shadow to create borders which does not break the vertical rhythm.


Examples

There are two ways to declare a button:

With specific declarations

.my-button-class {
  /* short-hand syntax example */

  /* color: default | active | hover */
  button-color: skyblue white white;

  /* background-color: default | active | hover */
  button-background: white skyblue silver;

  /* border: size | default | active | hover */
  button-border: 4px skyblue skyblue silver;

  /* classes: active class name | disabled class name | apply classes and pseudo classes to the parent selector */
  button-class: active disabled true;
}

With a configuration

@button my-button-name {
  /* detailed-syntax example */

  /* color */
  button-color: orange;
  button-color-active: white;
  button-color-hover: white;

  /* background-color */
  button-background-color: white;
  button-background-color-active: silver;
  button-background-color-hover: orange;

  /* border */
  button-border-width: 1px;
  button-border-color: silver;
  button-border-color-active: silver;
  button-border-color-hover: orange;

  /* classes */
  button-class-active: active;
  button-class-disabled: disabled;
  button-class-parent: true;
}
.my-button-class {
  button: my-button-name;
}

01: input, output, markup, demo

02: input, output, markup, demo


Installation

Install the npm package:

npm install --save-dev postcss postcss-button

Require the PostCSS plugin:

postcss([require("postcss-button")]);

See PostCSS docs to setup with Gulp, Grunt, Webpack, npm scripts…


Usage

With a configuration (optional)

@button ([name]) {
  /* name is a custom identifier to use multiple configurations.
  If no name is provided, the default settings are overwritten */
  [button-css-rules…]
}

.my-class {
  button: [name];
  /* use 'default' to apply the default settings */
}

Without a configuration

.my-class {
  [button-css-rules…]
}

Css rules

Color

/* Button text color when active */
button-color-active: [color];

/* button text color on hover */
button-color-hover: [color];

/* short-hand syntax */
button-color: [color] ([color-active]) ([color-hover]);

Background color

/* button background color when active */
button-background-active: [color];

/* button background color on hover */
button-background-hover: [color];

/* short-hand syntax */
button-background: [background-color] ([background-color-active])
  ([background-color-hover]);

Border

/* width and units of the border */
button-border-width: [width];

/* color of the border */
button-border-color: [color];

/* color of the border when active */
button-border-color-active: [color];

/* color of the border on hover */
button-border-color-hover: [color];

/* short-hand syntax */
button-border: [border-width] ([border-color]) ([border-color-active])
  ([border-color-hover]);

Classes

/* class name to apply the active styles */
button-class-active: [class-name];

/* class name to apply the disabled styles */
button-class-disabled: [class-name];

/* apply the classes and pseudo elements
to the parent element in the selector chain
if it exists. (default to false)
(See test 07 and 08) */
button-class-parent: [boolean];

/* short-hand syntax */
button-class: [active] ([disabled]) ([parent]);

Missing declarations fallback to the default settings.

0.4.3

5 years ago

0.4.2

5 years ago

0.4.0

5 years ago

0.3.17

7 years ago

0.3.16

7 years ago

0.3.15

8 years ago

0.3.14

8 years ago

0.3.13

8 years ago

0.3.12

8 years ago

0.3.11

8 years ago

0.3.10

8 years ago

0.3.9

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.21

8 years ago

0.1.20

8 years ago

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.0

10 years ago