Skip to content

Commit

Permalink
fix: add wrapperStyle to Snackbar (#1865)
Browse files Browse the repository at this point in the history
* fix: add wrapperStyle

* style: fix lint

* style: fix lint

* test: update snapshots
  • Loading branch information
jaulz authored and Trancever committed Apr 30, 2020
1 parent ac3d8ac commit 3a00234
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
10 changes: 9 additions & 1 deletion src/components/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ type Props = React.ComponentProps<typeof Surface> & {
* Text content of the Snackbar.
*/
children: React.ReactNode;
/**
* Style for the wrapper of the snackbar
*/
wrapperStyle?: StyleProp<ViewStyle>;
style?: StyleProp<ViewStyle>;
ref?: React.RefObject<View>;
/**
Expand Down Expand Up @@ -218,6 +222,7 @@ class Snackbar extends React.Component<Props, State> {
onDismiss,
theme,
style,
wrapperStyle,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
duration,
...rest
Expand All @@ -229,7 +234,10 @@ class Snackbar extends React.Component<Props, State> {
}

return (
<SafeAreaView pointerEvents="box-none" style={styles.wrapper}>
<SafeAreaView
pointerEvents="box-none"
style={[styles.wrapper, wrapperStyle]}
>
<Surface
pointerEvents="box-none"
accessibilityLiveRegion="polite"
Expand Down
39 changes: 24 additions & 15 deletions src/components/__tests__/__snapshots__/Snackbar.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ exports[`renders snackbar with Text as a child 1`] = `
emulateUnlessSupported={true}
pointerEvents="box-none"
style={
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
}
Array [
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
},
undefined,
]
}
>
<View
Expand Down Expand Up @@ -79,11 +82,14 @@ exports[`renders snackbar with action button 1`] = `
emulateUnlessSupported={true}
pointerEvents="box-none"
style={
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
}
Array [
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
},
undefined,
]
}
>
<View
Expand Down Expand Up @@ -242,11 +248,14 @@ exports[`renders snackbar with content 1`] = `
emulateUnlessSupported={true}
pointerEvents="box-none"
style={
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
}
Array [
Object {
"bottom": 0,
"position": "absolute",
"width": "100%",
},
undefined,
]
}
>
<View
Expand Down

0 comments on commit 3a00234

Please sign in to comment.