4.1.11 • Published 2 years ago

bpk-component-popover-css v4.1.11

Weekly downloads
196
License
Apache-2.0
Repository
github
Last release
2 years ago

bpk-component-popover

Backpack popover component.

Installation

npm install bpk-component-popover --save-dev

Usage

import React, { Component } from 'react';
import BpkButton from 'bpk-component-button';
import BpkPopover from 'bpk-component-popover';
import BpkText from 'bpk-component-text';

class App extends Component {
  constructor() {
    super();

    this.state = {
      isOpen: false,
    };

  }

  openPopover = () => {
    this.setState({
      isOpen: true,
    });
  }

  closePopover = () => {
    this.setState({
      isOpen: false,
    });
  }

  render() {
    return (
      <div id="popover-container">
        <BpkPopover
          id="my-popover"
          target={
            <BpkButton onClick={this.openPopover}>Open</BpkButton>
          }
          onClose={this.closePopover}
          isOpen={this.state.isOpen}
          label="My popover"
          closeButtonText="Close"
          renderTarget={() =>
            document.getElementById('popover-container')
          }
          closeButtonProps={{
            tabIndex: 0,
          }}
        >
          <BpkText>My popover content</BpkText>
        </BpkPopover>
      </div>
    );
  }
}

Theming: In order to theme the modal, a renderTarget needs to be supplied as a function which returns a DOM node in the scope of a BpkThemeProvider.

Props

PropertyPropTypeRequiredDefault Value
childrennodetrue-
closeButtonTextstringtrue-
idstringtrue-
isOpenbooltrue-
labelstringtrue-
onClosefunctrue-
targetelement or functrue-
closeButtonIconboolfalsetrue
closeButtonPropsobjectfalsenull
labelAsTitleboolfalsefalse
paddedboolfalsetrue
placementoneOf('top', 'right', 'bottom', 'left')false'bottom'
popperModifiersobjectfalsenull
portalClassNamestringfalsenull
portalStyleobjectfalsenull
renderTargetfuncfalsenull

In order to attach the popover to a regular DOM element, provide a function which returns it to target:

<BpkPopover
  id="my-popover"
  target={() => document.getElementById('mydiv')}
  onClose={this.closePopover}
  isOpen={this.state.isOpen}
  label="My popover"
  closeButtonText="Close"
>
  <BpkText>My popover content</BpkText>
</BpkPopover>

Prop Details

onClose

const onClose = (event, {
  source: <string>, // One of `DOCUMENT_CLICK`, `CLOSE_BUTTON`, `CLOSE_LINK`, `ESCAPE`
}) => {
  ...
}

popperModifiers

Please refer to the documentation for the underlying positioning library "Popper.js". You can achieve various behaviours such as allowing the popover to overflow the viewport etc.

Theme Props

  • linkColor
  • linkHoverColor
  • linkActiveColor
  • linkVisitedColor
4.1.9

2 years ago

4.1.11

2 years ago

4.1.7

2 years ago

4.1.5

2 years ago

4.1.4

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.0.26

2 years ago

4.0.28

2 years ago

4.0.25

2 years ago

4.0.40

2 years ago

4.0.37

2 years ago

4.0.34

2 years ago

4.0.35

2 years ago

4.0.23

2 years ago

4.0.18

3 years ago

4.0.15

3 years ago

4.0.13

3 years ago

4.0.12

3 years ago

4.0.11

3 years ago

4.0.10

3 years ago

4.0.9

3 years ago

4.0.8

3 years ago

4.0.7

3 years ago

4.0.6

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

3.1.8

3 years ago

4.0.0

3 years ago

3.1.6

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.132

3 years ago

3.0.130

3 years ago

3.0.131

3 years ago

3.0.129

3 years ago

3.0.127

3 years ago

3.0.126

3 years ago

3.0.125

3 years ago

3.0.124

3 years ago

3.0.123

3 years ago

3.0.122

3 years ago

3.0.121

3 years ago

3.0.119

3 years ago

3.0.120

3 years ago

3.0.118

3 years ago

3.0.117

3 years ago

3.0.116

3 years ago

3.0.115

3 years ago

3.0.114

3 years ago

3.0.113

3 years ago

3.0.112

3 years ago

3.0.111

3 years ago

3.0.110

3 years ago

3.0.109

3 years ago

3.0.107

3 years ago

3.0.108

3 years ago

3.0.106

3 years ago

3.0.105

3 years ago

3.0.104

3 years ago

3.0.103

3 years ago

3.0.102

3 years ago

3.0.101

3 years ago

3.0.100

3 years ago

3.0.99

3 years ago

3.0.98

3 years ago

3.0.97

3 years ago

3.0.94

3 years ago

3.0.93

3 years ago

3.0.92

4 years ago

3.0.91

4 years ago

3.0.90

4 years ago

3.0.88

4 years ago

3.0.87

4 years ago

3.0.86

4 years ago

3.0.85

4 years ago

3.0.84

4 years ago

3.0.83

4 years ago

3.0.81

4 years ago

3.0.80

4 years ago

3.0.79

4 years ago

3.0.74

4 years ago

3.0.72

4 years ago

3.0.71

4 years ago

3.0.69

4 years ago

3.0.68

4 years ago

3.0.67

4 years ago

3.0.66

4 years ago