16
16
* limitations under the License.
17
17
*/
18
18
19
- /* @flow strict */
20
-
21
- import PropTypes from 'prop-types' ;
22
- import type { Node } from 'react' ;
19
+ import type { ReactNode } from 'react' ;
23
20
21
+ // @ts -expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
24
22
import Transition from 'react-transition-group/Transition' ;
25
23
26
24
import { animations } from '@skyscanner/bpk-foundations-web/tokens/base.es6' ;
27
25
26
+ // @ts -expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
28
27
import BpkCloseButton from '../../bpk-component-close-button' ;
28
+ // @ts -expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
29
29
import { BpkButtonLink } from '../../bpk-component-link' ;
30
30
import { cssModules } from '../../bpk-react-utils' ;
31
31
@@ -34,42 +34,43 @@ import STYLES from './BpkDrawerContent.module.scss';
34
34
const getClassName = cssModules ( STYLES ) ;
35
35
36
36
type Props = {
37
- children : Node ,
38
- dialogRef : ( ) => mixed ,
39
- onCloseAnimationComplete : ( ) => mixed ,
40
- onClose : ( ) => mixed ,
37
+ children : ReactNode ,
38
+ dialogRef : ( ) => React . RefObject < HTMLElement > ,
39
+ onCloseAnimationComplete : ( ) => void ,
40
+ onClose : ( ) => void
41
41
id : string ,
42
42
title : string ,
43
- className : ?string ,
44
- contentClassName : ?string ,
45
- closeLabel : string ,
46
- closeText : ?string ,
47
- isDrawerShown : boolean ,
48
- hideTitle : boolean ,
49
- closeOnScrimClick : boolean ,
50
- isIphone : boolean ,
51
- isIpad : boolean ,
43
+ className ?: string ,
44
+ contentClassName ?: string ,
45
+ closeLabel ?: string ,
46
+ closeText ?: string ,
47
+ isDrawerShown ?: boolean ,
48
+ hideTitle ?: boolean ,
49
+ closeOnScrimClick ?: boolean ,
50
+ isIphone ?: boolean ,
51
+ isIpad ?: boolean ,
52
+ padded ?: boolean ,
52
53
} ;
53
54
54
- const BpkDrawerContent = ( props : Props ) => {
55
- const {
56
- children ,
57
- className ,
58
- closeLabel ,
59
- closeOnScrimClick , // Unused from withScrim scrim HOC
60
- closeText ,
61
- contentClassName ,
62
- dialogRef ,
63
- hideTitle ,
64
- id ,
65
- isDrawerShown ,
66
- isIpad , // Unused from withScrim scrim HOC
67
- isIphone , // Unused from withScrim scrim HOC
68
- onClose ,
69
- onCloseAnimationComplete ,
70
- title,
71
- ...rest
72
- } = props ;
55
+ const BpkDrawerContent = ( {
56
+ children ,
57
+ className ,
58
+ closeLabel ,
59
+ closeOnScrimClick = true , // Unused from withScrim scrim HOC
60
+ closeText ,
61
+ contentClassName ,
62
+ dialogRef ,
63
+ hideTitle = false ,
64
+ id ,
65
+ isDrawerShown = true ,
66
+ isIpad = false , // Unused from withScrim scrim HOC
67
+ isIphone = false , // Unused from withScrim scrim HOC
68
+ onClose ,
69
+ onCloseAnimationComplete ,
70
+ padded ,
71
+ title,
72
+ ...rest
73
+ } : Props ) => {
73
74
74
75
const drawerClassNames = [ getClassName ( 'bpk-drawer' ) ] ;
75
76
const headerClassNames = [ getClassName ( 'bpk-drawer__heading' ) ] ;
@@ -83,6 +84,10 @@ const BpkDrawerContent = (props: Props) => {
83
84
headerClassNames . push ( getClassName ( 'bpk-drawer__heading--visually-hidden' ) ) ;
84
85
}
85
86
87
+ if ( padded ) {
88
+ contentClassNames . push ( getClassName ( 'bpk-drawer__content--padded' ) ) ;
89
+ }
90
+
86
91
if ( contentClassName ) {
87
92
contentClassNames . push ( contentClassName ) ;
88
93
}
@@ -101,11 +106,10 @@ const BpkDrawerContent = (props: Props) => {
101
106
in = { isDrawerShown }
102
107
onExited = { onCloseAnimationComplete }
103
108
>
104
- { ( status ) => (
105
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See decisions/flowfixme.md
109
+ { ( status : string ) => (
106
110
< section
107
111
id = { id }
108
- tabIndex = "-1"
112
+ tabIndex = { - 1 }
109
113
role = "dialog"
110
114
key = "dialog"
111
115
aria-labelledby = { headingId }
@@ -125,10 +129,7 @@ const BpkDrawerContent = (props: Props) => {
125
129
< BpkButtonLink onClick = { onClose } > { closeText } </ BpkButtonLink >
126
130
) : (
127
131
< div className = { getClassName ( 'bpk-drawer__close-button' ) } >
128
- < BpkCloseButton
129
- label = { closeLabel }
130
- onClick = { onClose }
131
- />
132
+ < BpkCloseButton label = { closeLabel } onClick = { onClose } />
132
133
</ div >
133
134
) }
134
135
</ header >
@@ -139,34 +140,4 @@ const BpkDrawerContent = (props: Props) => {
139
140
) ;
140
141
} ;
141
142
142
- BpkDrawerContent . propTypes = {
143
- children : PropTypes . node . isRequired ,
144
- dialogRef : PropTypes . func . isRequired ,
145
- onCloseAnimationComplete : PropTypes . func . isRequired ,
146
- onClose : PropTypes . func . isRequired ,
147
- id : PropTypes . string . isRequired ,
148
- title : PropTypes . string . isRequired ,
149
- className : PropTypes . string ,
150
- contentClassName : PropTypes . string ,
151
- closeLabel : PropTypes . string ,
152
- closeText : PropTypes . string ,
153
- isDrawerShown : PropTypes . bool ,
154
- hideTitle : PropTypes . bool ,
155
- closeOnScrimClick : PropTypes . bool ,
156
- isIphone : PropTypes . bool ,
157
- isIpad : PropTypes . bool ,
158
- } ;
159
-
160
- BpkDrawerContent . defaultProps = {
161
- className : null ,
162
- contentClassName : null ,
163
- closeLabel : null ,
164
- closeText : null ,
165
- isDrawerShown : true ,
166
- hideTitle : false ,
167
- closeOnScrimClick : true ,
168
- isIphone : false ,
169
- isIpad : false ,
170
- } ;
171
-
172
143
export default BpkDrawerContent ;
0 commit comments