7.0.0-beta.2 • Published 5 years ago

@lightspeed/cirrus-popover v7.0.0-beta.2

Weekly downloads
317
License
MIT
Repository
-
Last release
5 years ago

Popover

Popover with content that appears when clicking on a target element.

Installation

First, make sure you have been through the Getting Started steps of adding Cirrus in your application.

If using Yarn:

yarn add @lightspeed/cirrus-popover

Or using npm:

npm i -S @lightspeed/cirrus-popover

Usage

Import required styles in your .scss:

@import '@lightspeed/cirrus-popover/Popover.scss';

React Component

Props

PropTypeDefaultDescription
childrenreact.noderequiredContent to display inside the popover
placementstringbottom-startPosition of the Popover in relation with the targeted element.
targetfunctionrequiredTarget that will toggle the popover. Must return a React element that will be rendered. The function receives the following props: ({ targetProps: object, targetEvents: object, active: boolean }). targetProps and targetEvents are required to be passed to the target. Uses the render props pattern
lightbooleanundefinedDisplays popover on a light background
noArrowbooleanundefinedDoesn't show arrow for the popover
isOpenbooleanfalseOpened and closed state
isFlipEnabledbooleantrueWhen enabled the popover repositions itself based on the screen size
onOpenfunction() => {}Called when the popover is opened
onClosefunction() => {}Called when the popover is closed
autoClosebooleantrueWhether the component should call onClose when clicking outside of the popover

Example

import React from 'react';
import Popover from '@lightspeed/cirrus-popover';

const MyComponent = () => (
  <div>
    <Popover
      target={({ targetProps, targetEvents }) => (
        <button {...targetProps} {...targetEvents}>
          Target {active && '(is active)'}
        </button>
      )}
    >
      <div>
        Content
      </div>
    </Popover>
  </div>
);

export default MyComponent;

CSS Component

You can use CSS classes along with popper.js (the library used by the React component) to enable popovers outside a React application. Here's the available classes:

TypeClass
box.cr-popover
placement[data-placement="top"]
light.cr-popover--light
arrow.cr-popover__arrow
7.0.0-beta.2

5 years ago

7.0.0-beta.1

5 years ago

7.0.0-beta.0

5 years ago

7.0.0-alpha.0

5 years ago

6.0.0

5 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.0

6 years ago

3.0.0

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago