UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

15 lines 418 B
var emRegex = /(.*\d+)em$/; var percentageRegex = /(%$)/; export var emToPixels = function emToPixels(value, fontSize) { if (typeof value === 'string') { var emMatch = value.match(emRegex); if (emMatch && typeof fontSize === 'number') { return Number(emMatch[1]) * fontSize; } else if (value.match(percentageRegex)) { return value; } else { return null; } } return value; };