@instructure/ui-utils 10.13.1-pr-snapshot-1741357986437 → 10.13.1-snapshot-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/CHANGELOG.md +1 -1
- package/lib/__new-tests__/px.test.js +3 -3
- package/lib/px.js +5 -4
- package/package.json +5 -5
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
|
-
## [10.13.1-
|
6
|
+
## [10.13.1-snapshot-0](https://github.com/instructure/instructure-ui/compare/v10.13.0...v10.13.1-snapshot-0) (2025-03-10)
|
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": "10.13.1-
|
3
|
+
"version": "10.13.1-snapshot-0",
|
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,7 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"license": "MIT",
|
24
24
|
"devDependencies": {
|
25
|
-
"@instructure/ui-babel-preset": "10.13.1-
|
25
|
+
"@instructure/ui-babel-preset": "10.13.1-snapshot-0",
|
26
26
|
"@testing-library/jest-dom": "^6.6.3",
|
27
27
|
"@testing-library/react": "^16.0.1",
|
28
28
|
"@types/json-stable-stringify": "^1.0.36",
|
@@ -30,9 +30,9 @@
|
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
32
|
"@babel/runtime": "^7.26.0",
|
33
|
-
"@instructure/console": "10.13.1-
|
34
|
-
"@instructure/shared-types": "10.13.1-
|
35
|
-
"@instructure/ui-dom-utils": "10.13.1-
|
33
|
+
"@instructure/console": "10.13.1-snapshot-0",
|
34
|
+
"@instructure/shared-types": "10.13.1-snapshot-0",
|
35
|
+
"@instructure/ui-dom-utils": "10.13.1-snapshot-0",
|
36
36
|
"@types/ua-parser-js": "^0.7.39",
|
37
37
|
"fast-deep-equal": "^3.1.3",
|
38
38
|
"json-stable-stringify": "^1.1.1",
|