@uxf/styles 11.97.0 → 11.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/package.json +2 -2
- package/units/em-to-px.d.ts +1 -1
- package/units/em-to-px.js +5 -1
- package/units/percent.d.ts +1 -1
- package/units/percent.js +3 -4
- package/units/rem-to-px.d.ts +1 -1
- package/units/rem-to-px.js +5 -1
- package/units/spacing.d.ts +3 -0
- package/units/spacing.js +3 -0
package/README.md
CHANGED
|
@@ -125,21 +125,25 @@ const example2 = rem(320, 10) /* returns "32rem" */
|
|
|
125
125
|
|
|
126
126
|
### `emToPx` and `remToPx`
|
|
127
127
|
|
|
128
|
-
- parse em or rem units to pixels (
|
|
128
|
+
- parse em or rem units to pixels (always returns `number`) by specified base (defaults `16`)
|
|
129
|
+
- the string `"0"` is also accepted and returns `0`
|
|
130
|
+
- throws an error for any other invalid input (previously returned the input as-is)
|
|
129
131
|
|
|
130
132
|
```tsx
|
|
131
133
|
import { emToPx } from "@uxf/styles/units/em-to-px";
|
|
132
134
|
|
|
133
|
-
const example1 = emToPx("20em")
|
|
135
|
+
const example1 = emToPx("20em") /* 320 */
|
|
134
136
|
const example2 = emToPx("20em", 10) /* 200 */
|
|
135
|
-
const example3 = emToPx("
|
|
137
|
+
const example3 = emToPx("0") /* 0 */
|
|
138
|
+
// emToPx("20rem") — throws error: Invalid value
|
|
136
139
|
```
|
|
137
140
|
```tsx
|
|
138
141
|
import { remToPx } from "@uxf/styles/units/rem-to-px";
|
|
139
142
|
|
|
140
|
-
const example1 = remToPx("20rem")
|
|
143
|
+
const example1 = remToPx("20rem") /* 320 */
|
|
141
144
|
const example2 = remToPx("20rem", 10) /* 200 */
|
|
142
|
-
const example3 = remToPx("
|
|
145
|
+
const example3 = remToPx("0") /* 0 */
|
|
146
|
+
// remToPx("20%") — throws error: Invalid value
|
|
143
147
|
```
|
|
144
148
|
|
|
145
149
|
### `formatCssValue`
|
|
@@ -167,6 +171,8 @@ const example = percent(54.874, 80, 2) /* returns 68.59 */
|
|
|
167
171
|
|
|
168
172
|
### `spacing`
|
|
169
173
|
|
|
174
|
+
> **Deprecated** — This function will be deleted in future versions.
|
|
175
|
+
|
|
170
176
|
- returns input multiplied by given factor (defaults `8`)
|
|
171
177
|
|
|
172
178
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/styles",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.104.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "git+https://gitlab.com/uxf-npm/styles.git"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@uxf/core": "11.
|
|
18
|
+
"@uxf/core": "11.100.0",
|
|
19
19
|
"color2k": "2.0.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
package/units/em-to-px.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function emToPx(value: string, size?: number):
|
|
1
|
+
export declare function emToPx(value: string, size?: number): number;
|
package/units/em-to-px.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.emToPx = emToPx;
|
|
4
|
+
const throw_error_1 = require("@uxf/core/utils/throw-error");
|
|
4
5
|
function emToPx(value, size = 16) {
|
|
5
6
|
if (/\d*\.?\d+em/.test(value)) {
|
|
6
7
|
return parseFloat(value) * size;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
else if (value === "0") {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
(0, throw_error_1.throwError)(`Invalid value: ${value}`);
|
|
9
13
|
}
|
package/units/percent.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function percent(inputValue: number, maxValue?: number, precision?: number): number;
|
package/units/percent.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.percent =
|
|
3
|
+
exports.percent = percent;
|
|
4
4
|
const trim_trailing_zeros_1 = require("@uxf/core/utils/trim-trailing-zeros");
|
|
5
|
-
|
|
5
|
+
function percent(inputValue, maxValue = 100, precision = 2) {
|
|
6
6
|
if (inputValue === 0) {
|
|
7
7
|
return inputValue;
|
|
8
8
|
}
|
|
9
9
|
return parseFloat((0, trim_trailing_zeros_1.trimTrailingZeros)(((inputValue / maxValue) * 100).toFixed(precision)));
|
|
10
|
-
}
|
|
11
|
-
exports.percent = percent;
|
|
10
|
+
}
|
package/units/rem-to-px.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function remToPx(value: string, size?: number):
|
|
1
|
+
export declare function remToPx(value: string, size?: number): number;
|
package/units/rem-to-px.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.remToPx = remToPx;
|
|
4
|
+
const throw_error_1 = require("@uxf/core/utils/throw-error");
|
|
4
5
|
function remToPx(value, size = 16) {
|
|
5
6
|
if (/\d*\.?\d+rem/.test(value)) {
|
|
6
7
|
return parseFloat(value) * size;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
else if (value === "0") {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
(0, throw_error_1.throwError)(`Invalid value: ${value}`);
|
|
9
13
|
}
|
package/units/spacing.d.ts
CHANGED
package/units/spacing.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.spacing = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated This function will be deleted in future versions.
|
|
6
|
+
*/
|
|
4
7
|
const spacing = (input, factor = 8) => (input === 0 ? input : input * factor);
|
|
5
8
|
exports.spacing = spacing;
|