How to use the mjml-core.helpers.widthParser function in mjml-core

To help you get started, we’ve selected a few mjml-core 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 mjmlio / mjml / packages / mjml-column / src / index.js View on Github external
getMobileWidth () {
    const { mjAttribute, sibling, parentWidth, mobileWidth } = this.props
    const width = mjAttribute('width')

    if (mobileWidth != "mobileWidth" ) {
      return '100%'
    } else if (width == undefined) {
      return `${parseInt(100 / sibling)}%`
    }

    const { width: parsedWidth, unit } = helpers.widthParser(width)

    switch (unit) {
      case '%':
        return width
      case 'px':
      default:
        return `${parsedWidth / parentWidth}%`
    }
  }
github mjmlio / mjml / packages / mjml-column / src / index.js View on Github external
getColumnClass () {
    const { mjAttribute, sibling } = this.props
    const width = mjAttribute('width')

    if (width == undefined) {
      return `mj-column-per-${parseInt(100 / sibling)}`
    }

    const { width: parsedWidth, unit } = helpers.widthParser(width)

    switch (unit) {
      case '%':
        return `mj-column-per-${parsedWidth}`

      case 'px':
      default:
        return `mj-column-px-${parsedWidth}`
    }
  }
github mjmlio / mjml / packages / mjml-column / src / index.js View on Github external
uniq(columnWidths).forEach((width) => {
      const { width: parsedWidth } = helpers.widthParser(width, { parseFloatToInt: false })
      const mediaQueryClass = `${className}-${parseInt(parsedWidth)}`

      mediaQueries.push(`.${mediaQueryClass} { width:${parsedWidth}${unit}!important; }`)
    })
  })
github mjmlio / mjml / packages / mjml-column / src / index.js View on Github external
getColumnClass () {
    const { mjAttribute, sibling } = this.props
    const width = mjAttribute('width')

    if (width == undefined) {
      return `mj-column-per-${parseInt(100 / sibling)}`
    }

    const { width: parsedWidth, unit } = helpers.widthParser(width)

    switch (unit) {
      case '%':
        return `mj-column-per-${parsedWidth}`

      case 'px':
      default:
        return `mj-column-px-${parsedWidth}`
    }
  }
github mjmlio / mjml / packages / mjml-container / src / index.js View on Github external
render () {
    const { renderWrappedOutlookChildren, mjAttribute, children } = this.props
    const { width } = helpers.widthParser(mjAttribute('width'))

    return (
      <div style="{this.styles.div}" data-width="{width}" data-background-color="{mjAttribute('background-color')}">
        {renderWrappedOutlookChildren(children)}
      </div>
    )
  }