iamjoshellis / react-handheld-portal-device

Perfectly positioned portals... πŸŒ€

Home Page:https://react-handheld-portal-device.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Handheld Portal Device πŸŒ€

npm Build Status code style: prettier Greenkeeper badge Netlify Status

Makes positioning portaled tooltips/dropdowns/etc a piece of cake 🍰!

Usage

import React from 'react';
import Portal from 'react-handheld-portal-device';

const Component = () => (
  <Parent>
    <Portal>
      (parentRect => <Content style={{ position: 'fixed', top: parentRect.top, left: parentRect.left,  }} />)
    </Portal>
  </Parent>
);

Using the render props pattern the Content can be "aware" of Parent's parentRect, which is the result of calling getBoundingClientRect on the Parent DOM node.

Props

class Portal extends React.Component {
  static propTypes = {
    debounce: PropTypes.number, // set the debounce time for event listeners
  };

  static defaultProps = {
    debounce: 16,
  };

  ...
}

About

Perfectly positioned portals... πŸŒ€

https://react-handheld-portal-device.netlify.com/

License:MIT License


Languages

Language:TypeScript 100.0%