mirror of
https://github.com/zhigang1992/react-native-paper.git
synced 2026-05-22 08:01:41 +08:00
fix: add contentStyle prop to Menu
This commit is contained in:
committed by
Wojtek Szafraniec
parent
3adc549399
commit
4fc1eb9b0e
@@ -47,6 +47,10 @@ type Props = {
|
||||
* Content of the `Menu`.
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* Style of menu's inner content.
|
||||
*/
|
||||
contentStyle?: StyleProp<ViewStyle>;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
/**
|
||||
* @optional
|
||||
@@ -332,6 +336,7 @@ class Menu extends React.Component<Props, State> {
|
||||
const {
|
||||
visible,
|
||||
anchor,
|
||||
contentStyle,
|
||||
style,
|
||||
children,
|
||||
theme,
|
||||
@@ -483,6 +488,7 @@ class Menu extends React.Component<Props, State> {
|
||||
[
|
||||
styles.shadowMenuContainer,
|
||||
shadowMenuContainerStyle,
|
||||
contentStyle,
|
||||
] as StyleProp<ViewStyle>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -36,3 +36,21 @@ it('renders not visible menu', () => {
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders menu with content styles', () => {
|
||||
const tree = renderer
|
||||
.create(
|
||||
<Menu
|
||||
visible
|
||||
onDismiss={jest.fn()}
|
||||
anchor={<Button mode="outlined">Open menu</Button>}
|
||||
contentStyle={{ borderTopLeftRadius: 0, borderTopRightRadius: 0 }}
|
||||
>
|
||||
<Menu.Item onPress={jest.fn()} title="Undo" />
|
||||
<Menu.Item onPress={jest.fn()} title="Redo" />
|
||||
</Menu>
|
||||
)
|
||||
.toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,95 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders menu with content styles 1`] = `
|
||||
<View
|
||||
collapsable={false}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "transparent",
|
||||
"borderColor": "rgba(0, 0, 0, 0.29)",
|
||||
"borderRadius": 4,
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": 0.5,
|
||||
"elevation": 0,
|
||||
"minWidth": 64,
|
||||
}
|
||||
}
|
||||
>
|
||||
<View
|
||||
accessibilityRole="button"
|
||||
accessible={true}
|
||||
isTVSelectable={true}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"overflow": "hidden",
|
||||
},
|
||||
Object {
|
||||
"borderRadius": 4,
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"alignItems": "center",
|
||||
"flexDirection": "row",
|
||||
"justifyContent": "center",
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={
|
||||
Array [
|
||||
Object {
|
||||
"color": "#000000",
|
||||
"fontFamily": "System",
|
||||
"fontWeight": "400",
|
||||
"textAlign": "left",
|
||||
"writingDirection": "ltr",
|
||||
},
|
||||
Array [
|
||||
Object {
|
||||
"letterSpacing": 1,
|
||||
"marginHorizontal": 16,
|
||||
"marginVertical": 9,
|
||||
"textAlign": "center",
|
||||
},
|
||||
undefined,
|
||||
Object {
|
||||
"color": "#6200ee",
|
||||
"fontFamily": "System",
|
||||
"fontWeight": "500",
|
||||
},
|
||||
Object {
|
||||
"fontFamily": "System",
|
||||
"fontWeight": "500",
|
||||
},
|
||||
],
|
||||
]
|
||||
}
|
||||
>
|
||||
OPEN MENU
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`renders not visible menu 1`] = `
|
||||
<View
|
||||
collapsable={false}
|
||||
|
||||
Reference in New Issue
Block a user