5.1.7 • Published 2 years ago

bpk-scrim-utils-css v5.1.7

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

bpk-scrim-utils

Higher order component that adds a scrim behind components and manages scroll states

Installation

npm install bpk-scrim-utils --save-dev
import { withScrim } from 'bpk-scrim-utils';

const Box = props => (
  <div ref={props.dialogRef}>
    <BpkButton onClick={props.onClose}>Close</BpkButton>
    Hello
  </div>
);

const BoxWithScrim = withScrim(Box);

withScrim sends all props it receives down to the component, except getApplicationElement and padded. It also adds some props that are used for a11y and closing the modal:

  • dialogRef should be set as the ref on the visible container on top of the scrim; it is used to set focus
  • onClose should be set as the onClick action on a button or a link
  • isIphone can be used to apply iPhone only styles or behaviour, as it has different scrolling behaviour

containerClassName can be used to apply styles to the full-screen container into which the enriched component is inserted (e.g. display: flex or display: grid)

Note: the pagewrap element id is a convention we use internally at Skyscanner. In most cases it should "just work".

Props

PropertyPropTypeRequiredDefault Value
onClosefunctrueSee prop details
getApplicationElementfunctrue-
isIphoneboolfalse/iPhone/i.test(typeof window !== 'undefined' ? window.navigator.platform : '')
containerClassNamestringfalse''
closeOnScrimClickboolfalsetrue
darkboolfalsefalse

Prop Details

onClose

This is required unless closeOnScrimClick is false.

5.1.7

2 years ago

5.1.5

2 years ago

5.1.3

2 years ago

5.1.2

2 years ago

5.1.0

2 years ago

5.0.24

2 years ago

5.0.25

2 years ago

5.0.26

2 years ago

5.0.29

2 years ago

5.0.16

2 years ago

5.0.17

2 years ago

5.0.19

2 years ago

5.0.15

2 years ago

5.0.11

3 years ago

5.0.8

3 years ago

5.0.6

3 years ago

5.0.5

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

4.1.8

3 years ago

5.0.0

3 years ago

4.1.6

3 years ago

4.1.5

3 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.116

3 years ago

4.0.115

3 years ago

4.0.114

3 years ago

4.0.113

3 years ago

4.0.112

3 years ago

4.0.109

3 years ago

4.0.110

3 years ago

4.0.111

3 years ago

4.0.107

3 years ago

4.0.108

3 years ago

4.0.106

3 years ago

4.0.105

3 years ago

4.0.104

3 years ago

4.0.103

3 years ago

4.0.102

3 years ago

4.0.101

3 years ago

4.0.100

3 years ago

4.0.99

3 years ago

4.0.98

3 years ago

4.0.97

3 years ago

4.0.96

3 years ago

4.0.95

3 years ago

4.0.94

3 years ago

4.0.91

3 years ago

4.0.90

3 years ago

4.0.89

4 years ago

4.0.88

4 years ago

4.0.87

4 years ago

4.0.85

4 years ago

4.0.84

4 years ago

4.0.83

4 years ago

4.0.82

4 years ago

4.0.81

4 years ago

4.0.80

4 years ago

4.0.78

4 years ago

4.0.77

4 years ago

4.0.76

4 years ago

4.0.71

4 years ago

4.0.70

4 years ago

4.0.69

4 years ago

4.0.67

4 years ago

4.0.66

4 years ago

4.0.65

4 years ago

4.0.64

4 years ago