4.3.2 • Published 9 months ago

@wedgekit/popover v4.3.2

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Popover

A light muffin made from a thin batter, which rises to form a hollow shell when baked.

Example

import Popover from '@wedgekit/popover';

const Test = () => {
  const [open, setOpen] = React.useState(false);
  const ref = React.useRef();

  return (
    <div>
      <Button ref={ref} onClick={() => setOpen(true)}>
        Open Popover
      </Button>
      {open && (
        <Popover node={ref.current} onExit={() => setOpen(false)}>
          <div
            style={{
              padding: '24px',
              backgroundColor: 'white',
              fontSize: '16px',
              'border-radius': '4px',
            }}
          >
            Here is some content.
          </div>
        </Popover>
      )}
    </div>
  );
};

render(<Test />);

Props

children

The popover content; can be a string or JSX

Type: ReactNode

Required:

node

The current ref of the DOM node that the popover is positioned in relation to

Type: HTMLElement

Required:

onExit

A callback which fires when an exit action is taken; this should generally be used to unmount the popover.

NOTE: The event which triggered the exit callback is passed as an argument, so if you want to refine which events close the popover, you can simply choose not to unmount it.

Type: (e: SyntheticEvent<unknown>) => void

Required:

bearings

The bearings prop defines how the popover is positioned relative to the node.

The bearings prop has four properties: side, align, offset and fallback:

  • side defines the position of the popover in relation to the node; it defaults to bottom
  • align defines how the popover aligns with the node; it defaults to start
  • offset defines the distance of the popover from the node; it defaults to 16px
  • fallback provides an alternate side and align if the popover is falling off the page; if absent the popover will be adjusted until it no longer overhangs the page - possibly covering the node

The following illustrates the interaction of side and align:

bearings examples

Type: Bearings

type Align = 'start' | 'center' | 'end';
type Side = 'top' | 'bottom' | 'left' | 'right';

type Bearings = {
  align: Align;
  side: Side;
  offset: number;
  fallback?: [Side, Align];
};

Required:

Default:

{
  align: 'start',
  side: 'bottom',
  offset: 16,
}

className

A string identifier for a CSS class. className should generally not be used directly; it is provided in order to make styled-components work correctly.

Type: string

Required:

ref

If consuming code needs to track changes within the popover, they may pass in a ref. Note that this is different than the 'node' prop, which is passed in so the popover can position itself.

node: popover tracks an element in the consuming code. ref: the consuming code has access to the popover

Type: React.Ref<HTMLDivElement>

Required: ❌

autoUpdatePosition

If true the popover will automatically reposition itself when it's parent is resized or scrolled. Additional documentation here https://floating-ui.com/docs/autoUpdate

Type: boolean

Required: ❌

4.3.1-tc.0

9 months ago

4.3.2

9 months ago

4.3.1

9 months ago

4.3.0-tc.0

9 months ago

4.3.0

10 months ago

4.1.2-tc.3

1 year ago

4.1.2-tc.1

1 year ago

4.1.2-tc.2

1 year ago

4.1.2

1 year ago

4.0.5-tc.20

2 years ago

4.0.5-tc.0

2 years ago

4.0.5-tc.1

2 years ago

4.0.5-tc.3

2 years ago

4.0.5-tc.4

2 years ago

4.0.5-tc.5

2 years ago

4.0.4

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

4.1.2-tc.0

1 year ago

4.0.1-tc.0

2 years ago

4.0.1-tc.1

2 years ago

4.0.1-tc.2

2 years ago

4.0.5-tc.11

2 years ago

4.1.1-tc.0

1 year ago

4.0.5-tc.10

2 years ago

4.0.1-tc.3

2 years ago

4.0.1-tc.4

2 years ago

4.0.1-tc.5

2 years ago

4.0.1-tc.6

2 years ago

4.1.0

1 year ago

4.1.1

1 year ago

2.0.1-tc.14

2 years ago

2.0.1-tc.15

2 years ago

2.0.1-tc.16

2 years ago

2.0.1-tc.17

2 years ago

2.0.1-tc.10

2 years ago

2.0.1-tc.11

2 years ago

2.0.1-tc.12

2 years ago

2.0.1-tc.13

2 years ago

2.0.10-tc.0

2 years ago

1.0.7

3 years ago

2.0.1-tc.18

2 years ago

2.0.0

3 years ago

3.1.1

2 years ago

3.1.0

2 years ago

2.0.1-tc.9

2 years ago

2.0.1-tc.20

2 years ago

3.0.0

2 years ago

2.0.1-tc.0

2 years ago

2.0.1-tc.8

2 years ago

2.0.1-tc.7

2 years ago

2.0.1-tc.6

2 years ago

2.0.1-tc.5

2 years ago

2.0.1-tc.4

2 years ago

2.0.1-tc.2

2 years ago

2.0.1-tc.1

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.0-tc.3

3 years ago

0.0.0-tc.2

3 years ago

0.0.0-tc.0

3 years ago