source: frontend/node_modules/postcss-lab-function/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 4.8 KB
Line 
1# PostCSS Lab Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2
3[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-lab-function.svg" height="20">][npm-url]
4[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/lab-function.svg" height="20">][css-url]
5[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
6[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
7
8
9[PostCSS Lab Function] lets you use `lab` and `lch` color functions in
10CSS, following the [CSS Color] specification.
11
12```pcss
13.color-lab {
14 color: lab(40% 56.6 39);
15}
16
17.color-lch {
18 color: lch(40% 68.735435 34.568626);
19}
20
21/* becomes */
22
23.color {
24 color: rgb(179, 35, 35);
25 color: color(display-p3 0.64331 0.19245 0.16771);
26}
27
28.color-lch {
29 color: rgb(179, 35, 35);
30 color: color(display-p3 0.64331 0.19245 0.16771);
31}
32```
33
34## Usage
35
36Add [PostCSS Lab Function] to your project:
37
38```bash
39npm install postcss postcss-lab-function --save-dev
40```
41
42Use it as a [PostCSS] plugin:
43
44```js
45const postcss = require('postcss');
46const postcssLabFunction = require('postcss-lab-function');
47
48postcss([
49 postcssLabFunction(/* pluginOptions */)
50]).process(YOUR_CSS /*, processOptions */);
51```
52
53[PostCSS Lab Function] runs in all Node environments, with special
54instructions for:
55
56| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
57| --- | --- | --- | --- | --- | --- |
58
59## Options
60
61### preserve
62
63The `preserve` option determines whether the original functional color notation
64is preserved. By default, it is not preserved.
65
66```js
67postcssLabFunction({ preserve: true })
68```
69
70```pcss
71.color {
72 color: lab(40% 56.6 39);
73}
74
75/* becomes */
76
77.color {
78 color: rgb(179, 35, 35);
79 color: color(display-p3 0.64331 0.19245 0.16771);
80 color: lab(40% 56.6 39);
81}
82```
83
84### enableProgressiveCustomProperties
85
86The `enableProgressiveCustomProperties` option determines whether the original notation
87is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
88
89⚠️ 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](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
90
91```js
92postcssLabFunction({ enableProgressiveCustomProperties: false })
93```
94
95```pcss
96:root {
97 --firebrick: lab(40% 56.6 39);
98}
99
100/* becomes */
101
102:root {
103 --firebrick: rgb(178, 34, 34); /* will never be used, not even in older browser */
104 --firebrick: color(display-p3 0.64331 0.19245 0.16771); /* will never be used, not even in older browser */
105 --firebrick: lab(40% 56.6 39);
106}
107```
108
109### subFeatures
110
111#### displayP3
112
113The `subFeatures.displayP3` option determines if `color(display-p3 ...)` is used as a fallback.<br>
114By default, it is enabled.
115
116`display-p3` can display wider gamut colors than `rgb` on some devices.
117
118```js
119postcssOKLabFunction({
120 subFeatures: {
121 displayP3: false
122 }
123})
124```
125
126```pcss
127.color {
128 color: lab(40% 56.6 39);
129}
130
131/* becomes */
132
133.color {
134 color: rgb(179, 35, 35);
135 color: lab(40% 56.6 39);
136}
137```
138
139## Out of gamut colors
140
141Depending on the browser implementation out of gamut colors may be clipped, resulting in a different color.<br>
142Fallback values generated by [PostCSS Lab Function] are always mapped to a close alternative in sRGB.
143
144When setting `preserve` to `true` the original values will be used by some browsers and these may be clipped.<br>
145Certain browsers will have an incorrect color if this occurs.
146
147If the plugin detects out of gamut colors it will emit a warning :
148
149> "lch(95% 210 285)" is out of gamut for "display-p3". When "preserve: true" is set this will lead to unexpected results in some browsers.
150
151To resolve this warning you can use a color that is in gamut for `display-p3`.
152
153## Copyright : color conversions
154
155This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
156
157[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
158[css-url]: https://cssdb.org/#lab-function
159[discord]: https://discord.gg/bUadyRwkJS
160[npm-url]: https://www.npmjs.com/package/postcss-lab-function
161
162[CSS Color]: https://drafts.csswg.org/css-color/#specifying-lab-lch
163[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
164[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
165[PostCSS]: https://github.com/postcss/postcss
166[PostCSS Loader]: https://github.com/postcss/postcss-loader
167[PostCSS Lab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-lab-function
Note: See TracBrowser for help on using the repository browser.