5.1.7 • Published 3 years ago

bpk-scrim-utils-css v5.1.7

Weekly downloads
175
License
Apache-2.0
Repository
github
Last release
3 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

3 years ago

5.1.5

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.0

3 years ago

5.0.24

3 years ago

5.0.25

3 years ago

5.0.26

3 years ago

5.0.29

3 years ago

5.0.16

4 years ago

5.0.17

4 years ago

5.0.19

4 years ago

5.0.15

4 years ago

5.0.11

4 years ago

5.0.8

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

4.1.8

4 years ago

5.0.0

4 years ago

4.1.6

4 years ago

4.1.5

4 years ago

4.1.4

4 years ago

4.1.3

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.116

4 years ago

4.0.115

4 years ago

4.0.114

4 years ago

4.0.113

4 years ago

4.0.112

4 years ago

4.0.109

4 years ago

4.0.110

4 years ago

4.0.111

4 years ago

4.0.107

4 years ago

4.0.108

4 years ago

4.0.106

4 years ago

4.0.105

4 years ago

4.0.104

4 years ago

4.0.103

4 years ago

4.0.102

4 years ago

4.0.101

4 years ago

4.0.100

4 years ago

4.0.99

4 years ago

4.0.98

5 years ago

4.0.97

5 years ago

4.0.96

5 years ago

4.0.95

5 years ago

4.0.94

5 years ago

4.0.91

5 years ago

4.0.90

5 years ago

4.0.89

5 years ago

4.0.88

5 years ago

4.0.87

5 years ago

4.0.85

5 years ago

4.0.84

5 years ago

4.0.83

5 years ago

4.0.82

5 years ago

4.0.81

5 years ago

4.0.80

5 years ago

4.0.78

5 years ago

4.0.77

5 years ago

4.0.76

5 years ago

4.0.71

5 years ago

4.0.70

5 years ago

4.0.69

5 years ago

4.0.67

5 years ago

4.0.66

5 years ago

4.0.65

5 years ago

4.0.64

5 years ago