rofrischmann/inline-style-prefixer

View on GitHub
modules/plugins/calc.js

Summary

Maintainability
A
2 hrs
Test Coverage
import { isPrefixedValue } from 'css-in-js-utils'

const CALC_REGEX = /calc\(/g
const prefixes = ['-webkit-', '-moz-', '']

export default function calc(property, value) {
  if (
    typeof value === 'string' &&
    !isPrefixedValue(value) &&
    value.indexOf('calc(') !== -1
  ) {
    return prefixes.map((prefix) => value.replace(CALC_REGEX, `${prefix}calc(`))
  }
}