How to use the @instructure/ui-dom-utils.getFontSize function in @instructure/ui-dom-utils

To help you get started, we’ve selected a few @instructure/ui-dom-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-utils / src / px.js View on Github external
function px (val, el) {
  const container = el || document.body

  if (!val || typeof val === 'number') {
    return val
  }

  const [ num, unit ] = parseUnit(val)

  if (unit === 'rem') {
    return num * getFontSize()
  } else if (unit === 'em') {
    return num * getFontSize(container)
  } else {
    return num
  }
}
github instructure / instructure-ui / packages / ui-utils / src / px.js View on Github external
function px (val, el) {
  const container = el || document.body

  if (!val || typeof val === 'number') {
    return val
  }

  const [ num, unit ] = parseUnit(val)

  if (unit === 'rem') {
    return num * getFontSize()
  } else if (unit === 'em') {
    return num * getFontSize(container)
  } else {
    return num
  }
}