Skip to content

Commit 7bdee73

Browse files
committed
breaking: apply better defaults to the styling of ContextMenu
1 parent 2c5b52d commit 7bdee73

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Menu, {
3333
} from 'react-native-popup-menu';
3434

3535
export const App = () => (
36-
<MenuContext style={{flexDirection: 'column', padding: 30}}>
36+
<MenuContext>
3737
<Text>Hello world!</Text>
3838
<Menu onSelect={value => alert(`Selected number: ${value}`)}>
3939
<MenuTrigger text='Select option' />

doc/api.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ The only known exception is when you use [Modal](https://facebook.github.io/reac
1717
|`closeMenu`||Closes currently opened menu|
1818
|`isMenuOpen`||Returns `true` if any menu is open|
1919

20+
### Properties
21+
| Option | Type | Opt/Required | Default | Note |
22+
|---|---|---|---|---|
23+
|`style`|`Style`|Optional||Style of wrapping `View` component. Same as `customStyles.menuContextWrapper` but when both are present result style is a merge where this style has higher precedence.|
24+
|`customStyles`|`Object`|Optional||Object defining wrapper, touchable and text styles|
25+
2026
### Custom styles
2127

2228
To style `<MenuContext />` and backdrop component you can pass `customStyles` object prop with following keys:
@@ -27,14 +33,15 @@ To style `<MenuContext />` and backdrop component you can pass `customStyles` ob
2733
|`backdrop`|`Style`|Backdrop `View` style|
2834

2935
**Note:** `Style` type is any valid RN style parameter.
36+
**Note:** In addition to these styles we add also `{flex:1}`. You can disable it by e.g. `style={{flex:0}}`.
3037

3138
See more in custom styling [example](../examples/StylingExample.js).
3239

3340
## Menu
3441

3542
Root menu component defining menu name and providing menu events.
3643

37-
### Options
44+
### Properties
3845
| Option | Type | Opt/Required | Default | Note |
3946
|---|---|---|---|---|
4047
|`name`|`String`|Optional|`auto-generated`|Unique name of menu|
@@ -66,7 +73,7 @@ Menu can by opened by clicking on `<MenuTrigger />` or by calling context method
6673

6774
**Note:** It is necessary that `<MenuTrigger />` is a direct child of `<Menu />`.
6875

69-
### Options
76+
### Properties
7077
| Option | Type | Opt/Required | Default | Note |
7178
|---|---|---|---|---|
7279
|`disabled`|`Boolean`|Optional|`false`|Indicates if trigger can be pressed|
@@ -98,7 +105,7 @@ This component wrapps all menu options.
98105

99106
**Note:** It is necessary that `<MenuOptions />` is a direct child of `<Menu />`.
100107

101-
### Options
108+
### Properties
102109
| Option | Type | Opt/Required | Default | Note |
103110
|---|---|---|---|---|
104111
|`optionsContainerStyle`|`Style`|Optional||Custom styles for options container. Note: this option is deprecated, use `customStyles` option instead|
@@ -127,7 +134,7 @@ See more in custom styling [example](../examples/StylingExample.js).
127134

128135
Wrapper component of menu option.
129136

130-
### Options
137+
### Properties
131138
| Option | Type | Opt/Required | Default | Note |
132139
|---|---|---|---|---|
133140
|`value`|`Any`|Optional||Value of option|

src/MenuContext.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default class MenuContext extends Component {
9595
debug('render menu', this.isMenuOpen(), this._ownLayout);
9696
return (
9797
<View style={{flex:1}} onLayout={e => this._onLayout(e)}>
98-
<View style={[customStyles.menuContextWrapper, style]}>
98+
<View style={[{flex:1}, customStyles.menuContextWrapper, style]}>
9999
{ this.props.children }
100100
</View>
101101
{shouldRenderMenu &&
@@ -182,4 +182,3 @@ MenuContext.childContextTypes = {
182182
menuRegistry: React.PropTypes.object,
183183
menuActions: React.PropTypes.object,
184184
};
185-

0 commit comments

Comments
 (0)