postcss-opacity-percentage
Advanced tools
Comparing version 1.0.0 to 1.1.0
10
index.js
@@ -8,3 +8,6 @@ const doNothingValues = new Set([ | ||
module.exports = () => ({ | ||
/** | ||
* @type {import('postcss').PluginCreator} | ||
*/ | ||
module.exports = ({preserve = false}) => ({ | ||
postcssPlugin: 'postcss-opacity-percentage', | ||
@@ -17,3 +20,6 @@ Declaration: { | ||
decl.value = String(Number.parseFloat(decl.value) / 100); | ||
decl.cloneBefore({value: String(Number.parseFloat(decl.value) / 100)}); | ||
if (!preserve) { | ||
decl.remove(); | ||
} | ||
}, | ||
@@ -20,0 +26,0 @@ }, |
{ | ||
"name": "postcss-opacity-percentage", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.", | ||
@@ -12,10 +12,13 @@ "keywords": [ | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Dreamseer/postcss-opacity-percentage.git" | ||
}, | ||
"funding": { | ||
"type": "kofi", | ||
"url": "https://ko-fi.com/dreamseer" | ||
}, | ||
"repository": "github:mrcgrtz/postcss-opacity-percentage", | ||
"funding": [ | ||
{ | ||
"type": "kofi", | ||
"url": "https://ko-fi.com/mrcgrtz" | ||
}, | ||
{ | ||
"type": "liberapay", | ||
"url": "https://liberapay.com/mrcgrtz" | ||
} | ||
], | ||
"author": { | ||
@@ -33,22 +36,5 @@ "name": "Marc Görtz", | ||
], | ||
"scripts": { | ||
"format": "xo --fix", | ||
"test": "xo && c8 ava", | ||
"coverage": "c8 report --reporter=lcov", | ||
"publish": "clean-publish" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"c8": "^7.10.0", | ||
"clean-publish": "^3.4.3", | ||
"husky": "^7.0.4", | ||
"lint-staged": "^11.2.6", | ||
"xo": "^0.46.4" | ||
}, | ||
"peerDependencies": { | ||
"postcss": ">=8" | ||
}, | ||
"lint-staged": { | ||
"*.js": "xo --fix" | ||
}, | ||
"xo": { | ||
@@ -55,0 +41,0 @@ "rules": { |
# PostCSS Opacity Percentage | ||
[![Test](https://github.com/Dreamseer/postcss-opacity-percentage/actions/workflows/test.yml/badge.svg)](https://github.com/Dreamseer/postcss-opacity-percentage/actions/workflows/test.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/Dreamseer/postcss-opacity-percentage/badge.svg?branch=main)](https://coveralls.io/github/Dreamseer/postcss-opacity-percentage?branch=main) | ||
[![Test](https://github.com/mrcgrtz/postcss-opacity-percentage/actions/workflows/test.yml/badge.svg)](https://github.com/mrcgrtz/postcss-opacity-percentage/actions/workflows/test.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/mrcgrtz/postcss-opacity-percentage/badge.svg?branch=main)](https://coveralls.io/github/mrcgrtz/postcss-opacity-percentage?branch=main) | ||
[![Install size](https://packagephobia.now.sh/badge?p=postcss-opacity-percentage)](https://packagephobia.now.sh/result?p=postcss-opacity-percentage) | ||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
[![MIT license](https://img.shields.io/github/license/dreamseer/postcss-opacity-percentage.svg)](https://github.com/Dreamseer/postcss-opacity-percentage/blob/main/LICENSE.md) | ||
[![MIT license](https://img.shields.io/github/license/mrcgrtz/postcss-opacity-percentage.svg)](https://github.com/mrcgrtz/postcss-opacity-percentage/blob/main/LICENSE.md) | ||
@@ -51,4 +51,32 @@ [PostCSS](https://github.com/postcss/postcss) plugin to transform [percentage-based opacity values](https://www.w3.org/TR/css-color-4/#transparency) to more compatible floating-point values. | ||
## Options | ||
### `preserve` | ||
The `preserve` option determines whether the original percentage value is preserved. By default, it is not preserved. | ||
```js | ||
// Keep the original notation | ||
postcss([ | ||
require('postcss-opacity-percentage')({preserve: true}), | ||
]); | ||
``` | ||
```css | ||
/* Input */ | ||
.foo { | ||
opacity: 45%; | ||
} | ||
``` | ||
```css | ||
/* Output */ | ||
.foo { | ||
opacity: 0.45; | ||
opacity: 45%; | ||
} | ||
``` | ||
## License | ||
MIT © [Marc Görtz](https://marcgoertz.de/) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4506
0
24
82
1