boldr/boldr-ui

View on GitHub
src/Popover/placement/bottom-right.js

Summary

Maintainability
B
4 hrs
Test Coverage
import createPlacement from './create';

/**
 * ---------------
 * |   anchor     |
 * |              |
 * ---------------
 *        |popover|
 *        ---------
 */
export function locate(anchorBoundingBox, containerBoundingBox, contentDimension, options) {
  const { right, bottom } = anchorBoundingBox;
  const x = right - contentDimension.width;
  const y = bottom + options.cushion;

  return {
    getCSSStyle() {
      return {
        position: 'absolute',
        left: `${Math.round(x)}px`,
        top: `${Math.round(y)}px`,
      };
    },

    name: 'position-bottom-right',
  };
}

const BottomRight = createPlacement(locate);

export default BottomRight;