How to use the fela-tools.isObject function in fela-tools

To help you get started, we’ve selected a few fela-tools 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 robinweser / fela / packages / fela / src / plugins / validator.js View on Github external
function validateKeyframeObject(
  style: Object,
  logInvalid: boolean,
  deleteInvalid: boolean
): void {
  for (const percentage in style) {
    const value = style[percentage]
    if (!isObject(value)) {
      if (logInvalid) {
        console.error(
          `${deleteInvalid ? '[Deleted] ' : ' '}Invalid keyframe value. An object was expected.`,
          {
            percentage,
            style: value
          }
        )
      }
      if (deleteInvalid) {
        delete style[percentage]
      }
      // check for invalid percentage values, it only allows from, to or 0% - 100%
    } else if (
      percentage !== 'from' &&
      percentage !== 'to' &&
github robinweser / fela / packages / fela / src / plugins / embedKeyframeAndFont.js View on Github external
function embedKeyframeAndFont(
  style: Object,
  type: Type,
  renderer: DOMRenderer
): Object {
  for (const property in style) {
    const value = style[property]

    if (property === 'fontFace' && isObject(value)) {
      const { fontFamily, src, ...otherProps } = value
      if (typeof fontFamily === 'string' && Array.isArray(src)) {
        style[property] = renderer.renderFont(fontFamily, src, otherProps)
      } else {
        // TODO: warning - invalid font data
      }
    }

    if (property === 'animationName' && isObject(value)) {
      style[property] = renderer.renderKeyframe(value)
    }
  }

  return style
}
github robinweser / fela / packages / fela / src / plugins / embedded.js View on Github external
function embedded(style: Object, type: Type, renderer: DOMRenderer): Object {
  for (const property in style) {
    const value = style[property]

    if (property === 'fontFace' && isObject(value)) {
      const { fontFamily, src, ...otherProps } = value
      if (typeof fontFamily === 'string' && Array.isArray(src)) {
        style.fontFamily = renderer.renderFont(fontFamily, src, otherProps)
        delete style.fontFace
      } else {
        // TODO: warning - invalid font data
      }
    }

    if (property === 'animationName' && isObject(value)) {
      style[property] = renderer.renderKeyframe(() => value)
    }
  }

  return style
}
github robinweser / fela / packages / fela / src / plugins / validator.js View on Github external
function validateStyleObject(
  style: Object,
  logInvalid: boolean,
  deleteInvalid: boolean
): void {
  for (const property in style) {
    const value = style[property]

    if (isObject(value)) {
      if (isNestedSelector(property) || isMediaQuery(property)) {
        validateStyleObject(value, logInvalid, deleteInvalid)
      } else {
        if (deleteInvalid) {
          delete style[property]
        }
        if (logInvalid) {
          console.error(
            `${deleteInvalid ? '[Deleted] ' : ' '}Invalid nested property. Only use nested media queries, pseudo classes, child selectors or &-combinators.
              Maybe you forgot to add a plugin that resolves "${property}".`,
            {
              property,
              value
            }
          )
        }
github robinweser / fela / packages / fela / src / plugins / important.js View on Github external
function addImportant(style: Object): Object {
  for (const property in style) {
    const value = style[property]

    if (isObject(value)) {
      style[property] = addImportant(value)
    } else if (Array.isArray(value)) {
      style[property] = value.map(addImportantToValue)
    } else {
      style[property] = addImportantToValue(value)
    }
  }

  return style
}
github robinweser / fela / packages / fela / src / enhancers / monolithic.js View on Github external
(ruleset, value, property) => {
        if (isObject(value)) {
          if (isNestedSelector(property)) {
            renderer._renderStyleToCache(
              className,
              value,
              pseudo + normalizeNestedProperty(property),
              media
            )
          } else if (isMediaQuery(property)) {
            const combinedMediaQuery = generateCombinedMediaQuery(
              media,
              property.slice(6).trim()
            )

            renderer._renderStyleToCache(
              className,
              value,