@instructure/ui-utils 8.56.4 → 8.56.5-pr-snapshot-1728655013879
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/lib/__new-tests__/px.test.js +3 -3
- package/lib/px.js +4 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [8.56.5-pr-snapshot-1728655013879](https://github.com/instructure/instructure-ui/compare/v8.56.4...v8.56.5-pr-snapshot-1728655013879) (2024-10-11)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @instructure/ui-utils
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
6
14
|
## [8.56.4](https://github.com/instructure/instructure-ui/compare/v8.56.3...v8.56.4) (2024-10-02)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-utils
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
require("@testing-library/jest-dom");
|
4
|
-
var
|
4
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
5
5
|
var _px = require("../px");
|
6
6
|
/*
|
7
7
|
* The MIT License (MIT)
|
@@ -41,11 +41,11 @@ describe('px', () => {
|
|
41
41
|
expect((0, _px.px)('30px')).toEqual(30);
|
42
42
|
});
|
43
43
|
it('converts rem to px', () => {
|
44
|
-
expect((0, _px.px)('50rem')).toEqual(50 * (0,
|
44
|
+
expect((0, _px.px)('50rem')).toEqual(50 * (0, _uiDomUtils.getFontSize)());
|
45
45
|
});
|
46
46
|
it('converts em to px', () => {
|
47
47
|
node.style.fontSize = '24px';
|
48
|
-
expect((0, _px.px)('10em', node)).toEqual(10 * (0,
|
48
|
+
expect((0, _px.px)('10em', node)).toEqual(10 * (0, _uiDomUtils.getFontSize)(node));
|
49
49
|
});
|
50
50
|
it('handles unitless input', () => {
|
51
51
|
expect((0, _px.px)('4')).toEqual(4);
|
package/lib/px.js
CHANGED
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.default = void 0;
|
8
8
|
exports.px = px;
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
10
|
-
var
|
11
|
-
var _getFontSize = require("@instructure/ui-dom-utils/lib/getFontSize.js");
|
10
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
12
11
|
var _parseUnit3 = require("./parseUnit");
|
13
12
|
/*
|
14
13
|
* The MIT License (MIT)
|
@@ -61,11 +60,11 @@ function px(val, el) {
|
|
61
60
|
num = _parseUnit2[0],
|
62
61
|
unit = _parseUnit2[1];
|
63
62
|
if (unit === 'rem') {
|
64
|
-
return num * (0,
|
63
|
+
return num * (0, _uiDomUtils.getFontSize)();
|
65
64
|
} else if (unit === 'em') {
|
66
|
-
const doc =
|
65
|
+
const doc = _uiDomUtils.canUseDOM ? document.body : null;
|
67
66
|
const container = el || doc;
|
68
|
-
return num * (0,
|
67
|
+
return num * (0, _uiDomUtils.getFontSize)(container);
|
69
68
|
} else {
|
70
69
|
return num;
|
71
70
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-utils",
|
3
|
-
"version": "8.56.
|
3
|
+
"version": "8.56.5-pr-snapshot-1728655013879",
|
4
4
|
"description": "A collection of utilities for UI components",
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
6
6
|
"module": "./es/index.js",
|
@@ -22,15 +22,15 @@
|
|
22
22
|
},
|
23
23
|
"license": "MIT",
|
24
24
|
"devDependencies": {
|
25
|
-
"@instructure/ui-babel-preset": "8.56.
|
25
|
+
"@instructure/ui-babel-preset": "8.56.5-pr-snapshot-1728655013879",
|
26
26
|
"@testing-library/jest-dom": "^6.1.4",
|
27
27
|
"@testing-library/react": "^14.1.2",
|
28
28
|
"@types/json-stable-stringify": "^1.0.34"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
31
|
"@babel/runtime": "^7.23.2",
|
32
|
-
"@instructure/console": "8.56.
|
33
|
-
"@instructure/ui-dom-utils": "8.56.
|
32
|
+
"@instructure/console": "8.56.5-pr-snapshot-1728655013879",
|
33
|
+
"@instructure/ui-dom-utils": "8.56.5-pr-snapshot-1728655013879",
|
34
34
|
"@types/ua-parser-js": "^0.7.37",
|
35
35
|
"bowser": "^2.11.0",
|
36
36
|
"fast-deep-equal": "^3.1.3",
|