function parseOffsetAsPixels(str) {
  if (!isNaN(parseFloat(str)) && isFinite(str)) {
    return parseFloat(str);
  } if (str.slice(-2) === 'px') {
    return parseFloat(str.slice(0, -2));
  }

  return undefined;
}
Attempts to parse the offset provided as a prop as a pixel value. If
parsing fails, then `undefined` is returned. Three examples of values that
will be successfully parsed are:
`20`
"20px"
"20"

@param {string|number} str A string of the form "{number}" or "{number}px",
  or just a number.
@return {number|undefined} The numeric version of `str`. Undefined if `str`
  was neither a number nor string ending in "px".