Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrcgrtz/postcss-opacity-percentage
π PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.
https://github.com/mrcgrtz/postcss-opacity-percentage
css css4 opacity postcss postcss-plugin
Last synced: 3 days ago
JSON representation
π PostCSS plugin to transform percentage-based opacity values to more compatible floating-point values.
- Host: GitHub
- URL: https://github.com/mrcgrtz/postcss-opacity-percentage
- Owner: mrcgrtz
- License: mit
- Created: 2021-11-08T14:38:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-01T13:16:56.000Z (23 days ago)
- Last Synced: 2025-01-19T03:16:26.827Z (5 days ago)
- Topics: css, css4, opacity, postcss, postcss-plugin
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/postcss-opacity-percentage
- Size: 1.78 MB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# PostCSS Opacity Percentage
[![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/mrcgrtz/postcss-opacity-percentage.svg)](https://github.com/mrcgrtz/postcss-opacity-percentage/blob/main/LICENSE.md)[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.
## Install
Using [npm](https://www.npmjs.com/get-npm):
```bash
npm install --save-dev postcss postcss-opacity-percentage
```Using [yarn](https://yarnpkg.com/):
```bash
yarn add --dev postcss postcss-opacity-percentage
```## Example
```css
/* Input */
.foo {
opacity: 45%;
}
``````css
/* Output */
.foo {
opacity: 0.45;
}
```## Usage
```js
postcss([
require('postcss-opacity-percentage'),
]);
```See [PostCSS](https://github.com/postcss/postcss) documentation for examples for your environment.
### `postcss-preset-env`
If you are using [`postcss-preset-env@>=7.3.0`](https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/CHANGELOG.md#730-january-31-2022), you already have this plugin installed via this package.
## 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/)