-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
support custom arrow icon in vertical and inline mode. #182
Conversation
assets/custom-arrow-icon.less
Outdated
@@ -0,0 +1,294 @@ | |||
@menuPrefixCls: rc-menu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里好像跟 index.less 只有三行不一样的代码,是不是应该 @import 'index'
然后覆盖修改的样式。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没必要新增这个文件,支持覆盖 arrowIcon,但是不需要管覆盖的 arrowIcon 的样式。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件要去掉,自定义图标的样式这里不管。
examples/custom-arrow-icon.js
Outdated
console.log(info); | ||
} | ||
|
||
const animation = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里重命名一下吧,好奇怪竟然不报错。
examples/custom-arrow-icon.js
Outdated
import 'rc-menu/assets/custom-arrow-icon.less'; | ||
import animate from 'css-animation'; | ||
|
||
const getSvgIcon = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方能不能通过 example 页面的一个 toggle 来做,否则又是大量重复代码。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
简单的功能,没必要单独写个 demo
src/SubMenu.jsx
Outdated
<i className={`${prefixCls}-arrow`} /> | ||
<i className={`${prefixCls}-arrow`}> | ||
{arrowIcon} | ||
</i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一样的不需要套在 <i>
里。
Deploy preview for rc-menu ready! Built with commit 34356d7 |
assets/custom-arrow-icon.less
Outdated
@@ -0,0 +1,294 @@ | |||
@menuPrefixCls: rc-menu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件要去掉,自定义图标的样式这里不管。
src/SubMenu.jsx
Outdated
@@ -474,7 +479,7 @@ export class SubMenu extends React.Component { | |||
title={typeof props.title === 'string' ? props.title : undefined} | |||
> | |||
{props.title} | |||
<i className={`${prefixCls}-arrow`} /> | |||
{arrowIcon || <i className={`${prefixCls}-arrow`}/>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/>
前要有空格。。
README.md
Outdated
<td>(props: MenuItemProps | SubMenuProps) => ReactNode</td> | ||
<th></th> | ||
<td>specific the arrow icon.</td> | ||
</tr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrowIcon
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
itemIcon
?
@@ -474,7 +483,7 @@ export class SubMenu extends React.Component { | |||
title={typeof props.title === 'string' ? props.title : undefined} | |||
> | |||
{props.title} | |||
<i className={`${prefixCls}-arrow`} /> | |||
{icon || <i className={`${prefixCls}-arrow`} />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 icon 应该只给 MenuItem 用吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md
Outdated
<td>expandIcon</td> | ||
<td>(props: SubMenuProps) => ReactNode</td> | ||
<th></th> | ||
<td>specific the menu item icon.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubMenu
src/SubMenu.jsx
Outdated
@@ -529,7 +540,10 @@ export class SubMenu extends React.Component { | |||
} | |||
} | |||
|
|||
const connected = connect(({ openKeys, activeKey, selectedKeys }, { eventKey, subMenuKey }) => ({ | |||
const connected = connect(( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无关的提交
src/Menu.jsx
Outdated
static contextTypes = { | ||
itemIcon: PropTypes.func, | ||
expandIcon: PropTypes.func, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context 应该去掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -63,6 +63,8 @@ export class SubMenu extends React.Component { | |||
store: PropTypes.object, | |||
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']), | |||
manualRef: PropTypes.func, | |||
itemIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行是多余的?
@@ -366,6 +368,8 @@ export class SubMenu extends React.Component { | |||
prefixCls: props.rootPrefixCls, | |||
id: this._menuId, | |||
manualRef: this.saveMenuInstance, | |||
itemIcon: props.itemIcon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多余的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubMenu也类似Menu一样,需要ItemIcon传给children中的MenuItem。
若去掉则整个Menu只有第一层有图标,SubMenu中的MenuItem都没有图标。
看下测试挂了。 |
master 上是好的,看下有什么区别 |
可以了,rebase 下 master |
fix tests as mini-store upgrade
@picodoth 看下 |
README.md
Outdated
<td>itemIcon</td> | ||
<td>ReactNode | (props: MenuItemProps) => ReactNode</td> | ||
<th></th> | ||
<td>specific the menu item icon.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify icon for menu item.
README.md
Outdated
<td>expandIcon</td> | ||
<td>ReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNode</td> | ||
<th></th> | ||
<td>specific the menu item icon.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify expanded icon for menu item submenu title
README.md
Outdated
<td>itemIcon</td> | ||
<td>ReactNode | (props: MenuItemProps) => ReactNode</td> | ||
<th></th> | ||
<td>specific the menu item icon.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify icon for menu item.
README.md
Outdated
<td>itemIcon</td> | ||
<td>ReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNode</td> | ||
<th></th> | ||
<td>specific the menu item icon.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -30,6 +30,7 @@ export class MenuItem extends React.Component { | |||
multiple: PropTypes.bool, | |||
isSelected: PropTypes.bool, | |||
manualRef: PropTypes.func, | |||
itemIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要 expandIcon 么
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
知道了 expandedicon 只在 submenu 上生效
if (typeof this.props.expandIcon === 'function') { | ||
icon = React.createElement( | ||
this.props.expandIcon, | ||
{ ...this.props } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为啥需要传 props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可以让使用者根据mode等属性使用不同的图标
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没懂,举个🌰?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是啊,那不需要吧, {...this.props}
this.props.expandedIcon 已经包含这个信息了
7.3.0 |
向外暴露
arrowIcon
接口来自定义菜单图标。只限于垂直和内联模式。
以便未来使用svg图标。