How to use the @instructure/ui-position.parsePlacement function in @instructure/ui-position

To help you get started, we’ve selected a few @instructure/ui-position 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 instructure / instructure-ui / packages / ui-popover / src / Popover / index.js View on Github external
computeOffsets (placement) {
    let { offsetX, offsetY } = this.props

    if ((this.props.shouldAlignArrow || this.props.alignArrow) && this._view) {
      const secondaryPlacement = parsePlacement(placement)[1]
      const { arrowSize, arrowBorderWidth } = this._view.theme
      const offsetAmount = (px(arrowSize) + px(arrowBorderWidth)) * 2
      if (secondaryPlacement === 'start') {
        offsetX = offsetAmount
      } else if (secondaryPlacement === 'end') {
        offsetX = -offsetAmount
      } else if (secondaryPlacement === 'top') {
        offsetY = offsetAmount
      } else if (secondaryPlacement === 'bottom') {
        offsetY = -offsetAmount
      }
    }

    return { offsetX, offsetY }
  }