5.0.5 • Published 16 days ago

postcss-double-position-gradients v5.0.5

Weekly downloads
3,603,313
License
MIT-0
Repository
github
Last release
16 days ago

PostCSS Double Position Gradients

PostCSS Double Position Gradients lets you use double-position gradients in CSS, following the CSS Image Values and Replaced Content specification.

.linear-gradient {
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

/* becomes */

.linear-gradient {
  background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

Usage

Add PostCSS Double Position Gradients to your project:

npm install postcss-double-position-gradients --save-dev

Use PostCSS Double Position Gradients to process your CSS:

const postcssDoublePositionGradients = require('postcss-double-position-gradients');

postcssDoublePositionGradients.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssDoublePositionGradients = require('postcss-double-position-gradients');

postcss([
  postcssDoublePositionGradients(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Double Position Gradients runs in all Node environments, with special instructions for:

NodePostCSS CLIWebpackGulpGrunt

Options

preserve

The preserve option determines whether the original double-position gradients should be preserved. By default, double-position gradients are preserved.

postcssDoublePositionGradients({ preserve: false })
.linear-gradient {
  background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

/* becomes */

.linear-gradient {
  background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
}

.conic-gradient {
  background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
}

enableProgressiveCustomProperties

The enableProgressiveCustomProperties option determines whether the original notation is wrapped with @supports when used in Custom Properties. By default, it is enabled.

!NOTE We only recommend disabling this when you set preserve to false or if you bring your own fix for Custom Properties.
See what the plugin does in its README.

postcssDoublePositionGradients({ enableProgressiveCustomProperties: false })
:root {
	--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}

/* becomes */

:root {
	--a-gradient: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%); /* will never be used, not even in older browser */
	--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
}
5.0.5

16 days ago

5.0.4

1 month ago

5.0.3

3 months ago

5.0.2

6 months ago

5.0.1

6 months ago

5.0.0

9 months ago

4.0.4

10 months ago

4.0.3

10 months ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

1 year ago

3.1.2

2 years ago

3.1.1

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.1.0

2 years ago

3.0.5

2 years ago

3.0.1

2 years ago

3.0.0

3 years ago

2.0.0

4 years ago

1.0.0

5 years ago