Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add wrapperStyle to Snackbar #1865

Merged
merged 4 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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