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

[WIP] add platform prop to menu #1200

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions components/menu/PropsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface MenuProps {
onChange?: Function;
level?: number;
height?: number;
platform?: string;
}
3 changes: 2 additions & 1 deletion components/menu/SubMenu.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class SubMenu extends React.Component<any, any> {
}
}
render() {
const { subMenuPrefixCls, radioPrefixCls, subMenuData } = this.props;
const { subMenuPrefixCls, radioPrefixCls, subMenuData, platform } = this.props;
const { selItem } = this.state;

const selected = dataItem => selItem.length > 0 && selItem[0].value === dataItem.value;
Expand All @@ -41,6 +41,7 @@ export default class SubMenu extends React.Component<any, any> {
[`${subMenuPrefixCls}-item-selected`]: selected(dataItem),
[`${subMenuPrefixCls}-item-disabled`]: dataItem.disabled,
})}
platform={platform}
key={idx}
extra={<Radio
checked={selected(dataItem)}
Expand Down
1 change: 1 addition & 0 deletions components/menu/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Properties | Descrition | Type | Default
| value | Selected value of `Menu`, it's a array which includes first and second level's `value`. | Array | [] |
| onChange | Callback called when menu item is selected. | (item: Object): void | |
| height | Height of `Menu`. | number | `document.documentElement.clientHeight / 2` |
| platform (`web only`) | set the special style depends on platform, Options `android`, `ios`, default to be `cross`, which means we will detect UA and change the component style | String | `'cross'`|
4 changes: 3 additions & 1 deletion components/menu/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class Menu extends React.Component<MenuProps, any> {
}

render() {
const { className, style, height, data = [], prefixCls, value, level } = this.props;
const { className, style, height, data = [], prefixCls, value, level, platform } = this.props;
const { firstLevelSelectValue } = this.state;

let subMenuData = data[0].children || [];
Expand Down Expand Up @@ -88,6 +88,7 @@ export default class Menu extends React.Component<MenuProps, any> {
{data.map((dataItem, index) => (
<List.Item
className={dataItem.value === firstLevelSelectValue ? `${prefixCls}-selected` : ''}
platform={platform}
onClick={() => this.onClickFirstLevelItem(dataItem)}
key={`listitem-1-${index}`}
>
Expand All @@ -103,6 +104,7 @@ export default class Menu extends React.Component<MenuProps, any> {
radioPrefixCls={this.props.radioPrefixCls}
subMenuData={subMenuData}
selItem={subSelInitItem}
platform={platform}
onSel={this.onClickSubMenuItem}
/>
</Flex.Item>
Expand Down
1 change: 1 addition & 0 deletions components/menu/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ subtitle: 菜单
| value | 初始值,一级和二级筛选数据的`value`组成的数组 | Array | [] |
| onChange | 选择后的回调函数 | (item: Object): void | |
| height | 筛选组件的高度 | number | `document.documentElement.clientHeight / 2` |
| platform (`web only`) | 设定组件的平台特有样式, 可选值为 `android`, `ios`, 默认为 `cross`, 即组件会自动检测设备 UA 应用不同平台的样式 | String | `'cross'`|