@uxf/styles 2.0.1 → 2.1.1

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 CHANGED
@@ -123,6 +123,25 @@ const example1 = rem(320) /* returns "20rem" */
123
123
  const example2 = rem(320, 10) /* returns "32rem" */
124
124
  ```
125
125
 
126
+ ### `emToPx` and `remToPx`
127
+
128
+ - parse em or rem units to pixels (as number) by specified base (defaults `16`)
129
+
130
+ ```tsx
131
+ import { emToPx } from "@uxf/styles/units/em-to-px";
132
+
133
+ const example1 = emToPx("20em") /* 320 */
134
+ const example2 = emToPx("20em", 10) /* 200 */
135
+ const example3 = emToPx("20rem", 10) /* "20rem" */
136
+ ```
137
+ ```tsx
138
+ import { remToPx } from "@uxf/styles/units/rem-to-px";
139
+
140
+ const example1 = remToPx("20rem") /* 320 */
141
+ const example2 = remToPx("20rem", 10) /* 200 */
142
+ const example3 = remToPx("20%", 10) /* "20%" */
143
+ ```
144
+
126
145
  ### `formatCssValue`
127
146
 
128
147
  - returns normalized css value: pass string as string or input to rem or zero as string or optionally forced input as string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/styles",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,22 +20,22 @@
20
20
  "url": "git+https://gitlab.com/uxf-npm/styles.git"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/node": "^18.8.2",
23
+ "@types/node": "^18.11.18",
24
24
  "@types/react": "^17.0.2",
25
25
  "@types/react-dom": "^17.0.2",
26
- "@uxf/core": "^3.1.0",
26
+ "@uxf/core": "^4.1.1",
27
27
  "@uxf/eslint-config": "^1.2.3",
28
28
  "csstype": "^3.1.1",
29
29
  "color2k": "^2.0.0",
30
- "eslint": "^8.8.0",
31
- "parcel": "^2.7.0",
32
- "prettier": "^2.7.1",
30
+ "eslint": "^8.31.0",
31
+ "parcel": "^2.8.2",
32
+ "prettier": "^2.8.1",
33
33
  "react": "^17.0.2",
34
34
  "react-dom": "^17.0.2",
35
- "typescript": "^4.8.4"
35
+ "typescript": "^4.9.4"
36
36
  },
37
37
  "peerDependencies": {
38
- "@uxf/core": "^3.1.0",
38
+ "@uxf/core": "^4.1.1",
39
39
  "color2k": "^2.0.0",
40
40
  "react": "^16 || ^17 || ^18",
41
41
  "react-dom": "^16 || ^17 || ^18"
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties } from "react";
2
- export declare type CssTimeUnits = "ms" | "s";
3
- export declare type CssAbsoluteLengthsUnits = "cm" | "mm" | "in" | "px" | "pt" | "pc" | "deg" | "rad";
4
- export declare type CssRelativeLengthsUnits = "em" | "ex" | "ch" | "rem" | "vw" | "vh" | "vmin" | "vmax" | "%";
5
- export declare type CssUnits = CssTimeUnits | CssAbsoluteLengthsUnits | CssRelativeLengthsUnits;
6
- export declare type TransitionProperty = keyof CSSProperties;
7
- export declare type TransitionProperties = TransitionProperty | TransitionProperty[];
2
+ export type CssTimeUnits = "ms" | "s";
3
+ export type CssAbsoluteLengthsUnits = "cm" | "mm" | "in" | "px" | "pt" | "pc" | "deg" | "rad";
4
+ export type CssRelativeLengthsUnits = "em" | "ex" | "ch" | "rem" | "vw" | "vh" | "vmin" | "vmax" | "%";
5
+ export type CssUnits = CssTimeUnits | CssAbsoluteLengthsUnits | CssRelativeLengthsUnits;
6
+ export type TransitionProperty = keyof CSSProperties;
7
+ export type TransitionProperties = TransitionProperty | TransitionProperty[];
@@ -0,0 +1 @@
1
+ export declare function emToPx(value: string, size?: number): string | number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emToPx = void 0;
4
+ function emToPx(value, size) {
5
+ if (size === void 0) { size = 16; }
6
+ if (/\d*\.?\d+em/.test(value)) {
7
+ return parseFloat(value) * size;
8
+ }
9
+ return value;
10
+ }
11
+ exports.emToPx = emToPx;
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW0tdG8tcHguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdW5pdHMvZW0tdG8tcHgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsU0FBZ0IsTUFBTSxDQUFDLEtBQWEsRUFBRSxJQUFTO0lBQVQscUJBQUEsRUFBQSxTQUFTO0lBQzNDLElBQUksYUFBYSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsRUFBRTtRQUMzQixPQUFPLFVBQVUsQ0FBQyxLQUFLLENBQUMsR0FBRyxJQUFJLENBQUM7S0FDbkM7SUFDRCxPQUFPLEtBQUssQ0FBQztBQUNqQixDQUFDO0FBTEQsd0JBS0MifQ==
@@ -0,0 +1 @@
1
+ export declare function remToPx(value: string, size?: number): string | number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remToPx = void 0;
4
+ function remToPx(value, size) {
5
+ if (size === void 0) { size = 16; }
6
+ if (/\d*\.?\d+rem/.test(value)) {
7
+ return parseFloat(value) * size;
8
+ }
9
+ return value;
10
+ }
11
+ exports.remToPx = remToPx;
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtLXRvLXB4LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3VuaXRzL3JlbS10by1weC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxTQUFnQixPQUFPLENBQUMsS0FBYSxFQUFFLElBQVM7SUFBVCxxQkFBQSxFQUFBLFNBQVM7SUFDNUMsSUFBSSxjQUFjLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFO1FBQzVCLE9BQU8sVUFBVSxDQUFDLEtBQUssQ0FBQyxHQUFHLElBQUksQ0FBQztLQUNuQztJQUNELE9BQU8sS0FBSyxDQUFDO0FBQ2pCLENBQUM7QUFMRCwwQkFLQyJ9