UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

15 lines 410 B
const emRegex = /(.*\d+)em$/; const percentageRegex = /(%$)/; export const emToPixels = (value, fontSize) => { if (typeof value === 'string') { const 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; };