3.1.10 • Published 2 years ago

bpk-component-modal-css v3.1.10

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

bpk-component-modal

Backpack modal component.

Installation

npm install bpk-component-modal --save-dev

Usage

import React, { Component } from 'react';
import BpkModal from 'bpk-component-modal';
import BpkButton from 'bpk-component-button';
import { BpkNavigationBarButtonLink } from 'bpk-component-navigation-bar';

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

    this.state = {
      isOpen: false,
    };
  }

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

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

  render() {
    return (
      <div id="modal-container">
        <div id="pagewrap">
          <BpkButton onClick={this.onOpen}>Open modal</BpkButton>
        </div>
        <BpkModal
          id="my-modal"
          isOpen={this.state.isOpen}
          onClose={this.onClose}
          title="Modal title"
          closeLabel="Close modal"
          getApplicationElement={() => document.getElementById('pagewrap')}
          renderTarget={() => document.getElementById('modal-container')}
          accessoryView={
            <BpkNavigationBarButtonLink
              label="Close"
              onClick={this.onClose}
              className={getClassName('bpk-modal__leading-button')}
            >
              <div>
                Back to results
              </div>
            </BpkNavigationBarButtonLink>
          }
        >
          This is a modal. You can put anything you want in here.
        </BpkModal>
      </div>
    );
  }
}

Note: In order to "hide" your application from screen readers whilst the modal is open you need to let it know what the root element for your application is by returning it's DOM node via the function passed to the getApplicationElement prop (see the example above). The pagewrap element id is a convention we use internally at Skyscanner. In most cases it should "just work".

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
idstringtrue-
childrennodetrue-
isOpenbooltrue-
onClosefunctrue-
getApplicationElementfunctrue-
titlestringtrue-
accessoryViewnodefalsenull
classNamestringfalsenull
contentClassNamestringfalsenull
closeLabelstringfalsenull
closeTextstringfalsenull
renderTargetfuncfalsenull
wideboolfalsefalse
fullScreenOnMobileboolfalsetrue
fullScreenboolfalsefalse
closeOnScrimClickboolfalsetrue
showHeaderboolfalsetrue
closeOnEscPressedboolfalsetrue
paddedboolfalsetrue

accessoryView

The accessory view allows for icons and actions to be placed in front of the main title inside the modal header. To be used with BpkNavigationBarButtonLink

Theme Props

  • linkColor
  • linkHoverColor
  • linkActiveColor
  • linkVisitedColor
3.1.10

2 years ago

3.1.8

2 years ago

3.1.7

2 years ago

3.1.5

2 years ago

3.1.2

2 years ago

3.1.4

2 years ago

3.1.1

2 years ago

3.0.22

2 years ago

3.0.28

2 years ago

3.0.20

2 years ago

3.0.19

2 years ago

3.0.34

2 years ago

3.0.31

2 years ago

3.0.29

2 years ago

3.0.18

3 years ago

3.0.14

3 years ago

3.0.11

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

2.2.6

3 years ago

3.0.0

3 years ago

2.2.8

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.129

3 years ago

2.1.128

3 years ago

2.1.127

3 years ago

2.1.126

3 years ago

2.1.125

3 years ago

2.1.124

3 years ago

2.1.121

3 years ago

2.1.123

3 years ago

2.1.122

3 years ago

2.1.120

3 years ago

2.1.119

3 years ago

2.1.118

3 years ago

2.1.117

3 years ago

2.1.116

3 years ago

2.1.115

3 years ago

2.1.114

3 years ago

2.1.113

3 years ago

2.1.112

3 years ago

2.1.111

3 years ago

2.1.110

3 years ago

2.1.109

3 years ago

2.1.108

3 years ago

2.1.107

3 years ago

2.1.106

3 years ago

2.1.105

3 years ago

2.1.104

3 years ago

2.1.103

3 years ago

2.1.102

3 years ago

2.1.101

3 years ago

2.1.100

3 years ago

2.1.98

3 years ago

2.1.99

3 years ago

2.1.95

3 years ago

2.1.94

3 years ago

2.1.92

3 years ago

2.1.93

3 years ago

2.1.91

4 years ago

2.1.90

4 years ago

2.1.89

4 years ago

2.1.88

4 years ago

2.1.86

4 years ago

2.1.85

4 years ago

2.1.84

4 years ago

2.1.83

4 years ago

2.1.82

4 years ago

2.1.81

4 years ago

2.1.80

4 years ago

2.1.78

4 years ago

2.1.77

4 years ago

2.1.76

4 years ago

2.1.71

4 years ago

2.1.69

4 years ago

2.1.68

4 years ago

2.1.66

4 years ago

2.1.65

4 years ago

2.1.64

4 years ago

2.1.63

4 years ago