source: frontend/node_modules/@csstools/postcss-trigonometric-functions/README.md

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

Fix frontend appearance

  • Property mode set to 100644
File size: 5.7 KB
Line 
1# PostCSS Trigonometric Functions [<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/@csstools/postcss-trigonometric-functions.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/trigonometric-functions.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
4
5[PostCSS Trigonometric Functions] lets you use `sin`, `cos`, `tan`, `asin`, `acos`, `atan` and `atan2` to be able to compute trigonometric relationships following the [CSS Values 4] specification.
6
7```pcss
8.trigonometry {
9 line-height: sin(pi / 4);
10 line-height: cos(.125turn);
11 line-height: tan(50grad);
12 transform: rotate(asin(-1));
13 transform: rotate(asin(sin(30deg + 1.0471967rad)));
14 transform: rotate(acos(-1));
15 transform: rotate(acos(cos(0 / 2 + 1 - 1)));
16 transform: rotate(atan(infinity));
17 transform: rotate(atan(e - 2.7182818284590452354));
18 transform: rotate(atan2(-infinity,-infinity));
19 transform: rotate(atan2(-infinity,infinity));
20 transform: rotate(atan2(-infinity,infinity));
21 transform: rotate(atan2(90, 15));
22}
23
24/* becomes */
25
26.trigonometry {
27 line-height: 0.70711;
28 line-height: 0.70711;
29 line-height: 1;
30 transform: rotate(-90deg);
31 transform: rotate(90deg);
32 transform: rotate(180deg);
33 transform: rotate(0deg);
34 transform: rotate(90deg);
35 transform: rotate(0deg);
36 transform: rotate(-135deg);
37 transform: rotate(-45deg);
38 transform: rotate(-45deg);
39 transform: rotate(80.54deg);
40}
41```
42
43## Usage
44
45Add [PostCSS Trigonometric Functions] to your project:
46
47```bash
48npm install postcss @csstools/postcss-trigonometric-functions --save-dev
49```
50
51Use it as a [PostCSS] plugin:
52
53```js
54const postcss = require('postcss');
55const postcssTrigonometricFunctions = require('@csstools/postcss-trigonometric-functions');
56
57postcss([
58 postcssTrigonometricFunctions(/* pluginOptions */)
59]).process(YOUR_CSS /*, processOptions */);
60```
61
62[PostCSS Trigonometric Functions] runs in all Node environments, with special
63instructions for:
64
65| [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) |
66| --- | --- | --- | --- | --- | --- |
67
68## ⚠️ About custom properties
69
70Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet.
71
72Because of that, any usage that contains a `var` is skipped.
73
74## Units
75
76[PostCSS Trigonometric Functions] lets you use different special units that are within the spec and computed at run time to be able to calculate the result of the trigonometric function.
77
78The following units are supported:
79
80* `pi`: Computes to `Math.PI` which is `3.141592653589793`
81* `e`: Computes to `Math.E` which is `2.718281828459045`
82* `infinity`, `-infinity`: Compute to `Infinity` and `-Infinity` respectively. Note that the usage is case insensitive so `InFiNiTy` is a valid value.
83
84Some calculations (such as `sin(-infinity)`) might return `NaN` as per the spec. Given that `NaN` can't be replaced with a value that's useful to CSS it is left as is, as the result will be effectively ignored by the browser.
85
86## Options
87
88### preserve
89
90The `preserve` option determines whether the original notation
91is preserved. By default, it is not preserved.
92
93```js
94postcssTrigonometricFunctions({ preserve: true })
95```
96
97```pcss
98.trigonometry {
99 line-height: sin(pi / 4);
100 line-height: cos(.125turn);
101 line-height: tan(50grad);
102 transform: rotate(asin(-1));
103 transform: rotate(asin(sin(30deg + 1.0471967rad)));
104 transform: rotate(acos(-1));
105 transform: rotate(acos(cos(0 / 2 + 1 - 1)));
106 transform: rotate(atan(infinity));
107 transform: rotate(atan(e - 2.7182818284590452354));
108 transform: rotate(atan2(-infinity,-infinity));
109 transform: rotate(atan2(-infinity,infinity));
110 transform: rotate(atan2(-infinity,infinity));
111 transform: rotate(atan2(90, 15));
112}
113
114/* becomes */
115
116.trigonometry {
117 line-height: 0.70711;
118 line-height: sin(pi / 4);
119 line-height: 0.70711;
120 line-height: cos(.125turn);
121 line-height: 1;
122 line-height: tan(50grad);
123 transform: rotate(-90deg);
124 transform: rotate(asin(-1));
125 transform: rotate(90deg);
126 transform: rotate(asin(1));
127 transform: rotate(asin(sin(30deg + 1.0471967rad)));
128 transform: rotate(180deg);
129 transform: rotate(acos(-1));
130 transform: rotate(0deg);
131 transform: rotate(acos(1));
132 transform: rotate(acos(cos(0 / 2 + 1 - 1)));
133 transform: rotate(90deg);
134 transform: rotate(atan(infinity));
135 transform: rotate(0deg);
136 transform: rotate(atan(e - 2.7182818284590452354));
137 transform: rotate(-135deg);
138 transform: rotate(atan2(-infinity,-infinity));
139 transform: rotate(-45deg);
140 transform: rotate(atan2(-infinity,infinity));
141 transform: rotate(-45deg);
142 transform: rotate(atan2(-infinity,infinity));
143 transform: rotate(80.54deg);
144 transform: rotate(atan2(90, 15));
145}
146```
147
148[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
149[css-url]: https://cssdb.org/#trigonometric-functions
150[discord]: https://discord.gg/bUadyRwkJS
151[npm-url]: https://www.npmjs.com/package/@csstools/postcss-trigonometric-functions
152
153[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
154[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
155[PostCSS]: https://github.com/postcss/postcss
156[PostCSS Loader]: https://github.com/postcss/postcss-loader
157[PostCSS Trigonometric Functions]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-trigonometric-functions
158[CSS Values 4]: https://www.w3.org/TR/css-values-4/#trig-funcs
Note: See TracBrowser for help on using the repository browser.