|
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:
1.0 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 3 | value: true
|
|---|
| 4 | });
|
|---|
| 5 | Object.defineProperty(exports, "default", {
|
|---|
| 6 | enumerable: true,
|
|---|
| 7 | get: function() {
|
|---|
| 8 | return negateValue;
|
|---|
| 9 | }
|
|---|
| 10 | });
|
|---|
| 11 | function negateValue(value) {
|
|---|
| 12 | value = `${value}`;
|
|---|
| 13 | if (value === "0") {
|
|---|
| 14 | return "0";
|
|---|
| 15 | }
|
|---|
| 16 | // Flip sign of numbers
|
|---|
| 17 | if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
|
|---|
| 18 | return value.replace(/^[+-]?/, (sign)=>sign === "-" ? "" : "-");
|
|---|
| 19 | }
|
|---|
| 20 | // What functions we support negating numeric values for
|
|---|
| 21 | // var() isn't inherently a numeric function but we support it anyway
|
|---|
| 22 | // The trigonometric functions are omitted because you'll need to use calc(…) with them _anyway_
|
|---|
| 23 | // to produce generally useful results and that will be covered already
|
|---|
| 24 | let numericFunctions = [
|
|---|
| 25 | "var",
|
|---|
| 26 | "calc",
|
|---|
| 27 | "min",
|
|---|
| 28 | "max",
|
|---|
| 29 | "clamp"
|
|---|
| 30 | ];
|
|---|
| 31 | for (const fn of numericFunctions){
|
|---|
| 32 | if (value.includes(`${fn}(`)) {
|
|---|
| 33 | return `calc(${value} * -1)`;
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.