We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2114f82 commit e6ff448Copy full SHA for e6ff448
src/utils/dom.js
@@ -253,3 +253,18 @@ export const createNativeNotification = (options, onclick) => {
253
254
return Promise.reject('Unsupported');
255
};
256
+
257
+/**
258
+ * Calculates pixel size from em
259
+ * @param {number} em Em size
260
+ * @param {DOMElement} [root=document.body] Optional root element
261
+ * @return {number} Size in pixels
262
+ */
263
+export const emToPx = (em, root = document.body) => {
264
+ const px = parseInt(
265
+ getComputedStyle(root).fontSize,
266
+ 10
267
+ );
268
269
+ return Math.round(px * em);
270
+};
0 commit comments