@instructure/ui-utils 8.56.2-pr-snapshot-1721749364069 → 8.56.2-snapshot-2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1 -1
- package/lib/__new-tests__/px.test.js +3 -3
- package/lib/px.js +5 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -3,7 +3,7 @@
|
|
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.2-
|
6
|
+
## [8.56.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2-snapshot-2) (2024-08-06)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-utils
|
9
9
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
require("@testing-library/jest-dom");
|
4
|
-
var
|
4
|
+
var _getFontSize = require("@instructure/ui-dom-utils/lib/getFontSize.js");
|
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, _getFontSize.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, _getFontSize.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,7 +7,8 @@ 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
|
10
|
+
var _canUseDOM = require("@instructure/ui-dom-utils/lib/canUseDOM.js");
|
11
|
+
var _getFontSize = require("@instructure/ui-dom-utils/lib/getFontSize.js");
|
11
12
|
var _parseUnit3 = require("./parseUnit");
|
12
13
|
/*
|
13
14
|
* The MIT License (MIT)
|
@@ -60,11 +61,11 @@ function px(val, el) {
|
|
60
61
|
num = _parseUnit2[0],
|
61
62
|
unit = _parseUnit2[1];
|
62
63
|
if (unit === 'rem') {
|
63
|
-
return num * (0,
|
64
|
+
return num * (0, _getFontSize.getFontSize)();
|
64
65
|
} else if (unit === 'em') {
|
65
|
-
const doc =
|
66
|
+
const doc = _canUseDOM.canUseDOM ? document.body : null;
|
66
67
|
const container = el || doc;
|
67
|
-
return num * (0,
|
68
|
+
return num * (0, _getFontSize.getFontSize)(container);
|
68
69
|
} else {
|
69
70
|
return num;
|
70
71
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-utils",
|
3
|
-
"version": "8.56.2-
|
3
|
+
"version": "8.56.2-snapshot-2",
|
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.2-
|
25
|
+
"@instructure/ui-babel-preset": "8.56.2-snapshot-2",
|
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.2-
|
33
|
-
"@instructure/ui-dom-utils": "8.56.2-
|
32
|
+
"@instructure/console": "8.56.2-snapshot-2",
|
33
|
+
"@instructure/ui-dom-utils": "8.56.2-snapshot-2",
|
34
34
|
"@types/ua-parser-js": "^0.7.37",
|
35
35
|
"bowser": "^2.11.0",
|
36
36
|
"fast-deep-equal": "^3.1.3",
|