mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
feat: MenuItem support danger
(#23785)
* feat: Basic danger color * dark of it * danger dark style * invers of dropdown * update less * update snapshot
This commit is contained in:
parent
b66ab37463
commit
98232382f1
@ -34,6 +34,7 @@ const menu = (
|
|||||||
3rd menu item
|
3rd menu item
|
||||||
</a>
|
</a>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
<Menu.Item danger>a danger item</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
@import '../../style/themes/index';
|
@import '../../style/themes/index';
|
||||||
@import '../../style/mixins/index';
|
@import '../../style/mixins/index';
|
||||||
|
@import './status';
|
||||||
|
|
||||||
@dropdown-prefix-cls: ~'@{ant-prefix}-dropdown';
|
@dropdown-prefix-cls: ~'@{ant-prefix}-dropdown';
|
||||||
|
|
||||||
|
12
components/dropdown/style/status.less
Normal file
12
components/dropdown/style/status.less
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@import './index';
|
||||||
|
|
||||||
|
.@{dropdown-prefix-cls}-menu-item {
|
||||||
|
&&-danger {
|
||||||
|
color: @error-color;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: @text-color-inverse;
|
||||||
|
background-color: @error-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ export interface MenuItemProps
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
level?: number;
|
level?: number;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
|
danger?: boolean;
|
||||||
title?: React.ReactNode;
|
title?: React.ReactNode;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -50,7 +51,7 @@ export default class MenuItem extends React.Component<MenuItemProps> {
|
|||||||
|
|
||||||
renderItem = ({ siderCollapsed }: SiderContextProps) => {
|
renderItem = ({ siderCollapsed }: SiderContextProps) => {
|
||||||
const { level, className, children, rootPrefixCls } = this.props;
|
const { level, className, children, rootPrefixCls } = this.props;
|
||||||
const { title, icon, ...rest } = this.props;
|
const { title, icon, danger, ...rest } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuContext.Consumer>
|
<MenuContext.Consumer>
|
||||||
@ -81,6 +82,7 @@ export default class MenuItem extends React.Component<MenuItemProps> {
|
|||||||
<Item
|
<Item
|
||||||
{...rest}
|
{...rest}
|
||||||
className={classNames(className, {
|
className={classNames(className, {
|
||||||
|
[`${rootPrefixCls}-item-danger`]: danger,
|
||||||
[`${rootPrefixCls}-item-only-child`]:
|
[`${rootPrefixCls}-item-only-child`]:
|
||||||
(icon ? childrenLength + 1 : childrenLength) === 1,
|
(icon ? childrenLength + 1 : childrenLength) === 1,
|
||||||
})}
|
})}
|
||||||
|
@ -1113,7 +1113,7 @@ Array [
|
|||||||
Option 3
|
Option 3
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class="ant-menu-item ant-menu-item-only-child"
|
class="ant-menu-item ant-menu-item-danger ant-menu-item-only-child"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
style="padding-left:48px"
|
style="padding-left:48px"
|
||||||
>
|
>
|
||||||
|
@ -61,7 +61,9 @@ class Sider extends React.Component {
|
|||||||
<Menu.Item key="1">Option 1</Menu.Item>
|
<Menu.Item key="1">Option 1</Menu.Item>
|
||||||
<Menu.Item key="2">Option 2</Menu.Item>
|
<Menu.Item key="2">Option 2</Menu.Item>
|
||||||
<Menu.Item key="3">Option 3</Menu.Item>
|
<Menu.Item key="3">Option 3</Menu.Item>
|
||||||
<Menu.Item key="4">Option 4</Menu.Item>
|
<Menu.Item key="4" danger>
|
||||||
|
Option 4
|
||||||
|
</Menu.Item>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu key="sub2" icon={<AppstoreOutlined />} title="Navigation Two">
|
<SubMenu key="sub2" icon={<AppstoreOutlined />} title="Navigation Two">
|
||||||
<Menu.Item key="5">Option 5</Menu.Item>
|
<Menu.Item key="5">Option 5</Menu.Item>
|
||||||
|
@ -58,6 +58,7 @@ More layouts with navigation: [Layout](/components/layout).
|
|||||||
| key | Unique ID of the menu item | string | | |
|
| key | Unique ID of the menu item | string | | |
|
||||||
| title | Set display title for collapsed item | string | | |
|
| title | Set display title for collapsed item | string | | |
|
||||||
| icon | icon of the menu item | ReactNode | | 4.2.0 |
|
| icon | icon of the menu item | ReactNode | | 4.2.0 |
|
||||||
|
| danger | Display the danger style | boolean | false | 4.3.0 |
|
||||||
|
|
||||||
> Note: `icon` is a newly added prop in`4.2.0`. For previous versions, please use the following method to define the icon.
|
> Note: `icon` is a newly added prop in`4.2.0`. For previous versions, please use the following method to define the icon.
|
||||||
>
|
>
|
||||||
|
@ -59,6 +59,7 @@ subtitle: 导航菜单
|
|||||||
| key | item 的唯一标志 | string | | |
|
| key | item 的唯一标志 | string | | |
|
||||||
| title | 设置收缩时展示的悬浮标题 | string | | |
|
| title | 设置收缩时展示的悬浮标题 | string | | |
|
||||||
| icon | 菜单图标 | ReactNode | | 4.2.0 |
|
| icon | 菜单图标 | ReactNode | | 4.2.0 |
|
||||||
|
| danger | 展示错误状态样式 | boolean | false | 4.3.0 |
|
||||||
|
|
||||||
> 注意:`icon` 是 `4.2.0` 新增的属性,之前的版本请使用下面的方式定义图标。
|
> 注意:`icon` 是 `4.2.0` 新增的属性,之前的版本请使用下面的方式定义图标。
|
||||||
>
|
>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
@import '../../style/themes/index';
|
@import '../../style/themes/index';
|
||||||
@import '../../style/mixins/index';
|
@import '../../style/mixins/index';
|
||||||
|
@import './status';
|
||||||
|
|
||||||
@menu-prefix-cls: ~'@{ant-prefix}-menu';
|
@menu-prefix-cls: ~'@{ant-prefix}-menu';
|
||||||
|
|
||||||
|
47
components/menu/style/status.less
Normal file
47
components/menu/style/status.less
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
@import './index';
|
||||||
|
|
||||||
|
.@{menu-prefix-cls} {
|
||||||
|
// Danger
|
||||||
|
&-item-danger&-item {
|
||||||
|
color: @menu-highlight-danger-color;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&-active {
|
||||||
|
color: @menu-highlight-danger-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background: @menu-item-active-danger-bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-selected {
|
||||||
|
color: @menu-highlight-danger-color;
|
||||||
|
> a,
|
||||||
|
> a:hover {
|
||||||
|
color: @menu-highlight-danger-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.@{menu-prefix-cls}:not(.@{menu-prefix-cls}-horizontal) &-selected {
|
||||||
|
background-color: @menu-item-active-danger-bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.@{menu-prefix-cls}-inline &::after {
|
||||||
|
border-right-color: @menu-highlight-danger-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Dark ====================
|
||||||
|
&-dark &-item-danger&-item {
|
||||||
|
&,
|
||||||
|
&:hover,
|
||||||
|
& > a {
|
||||||
|
color: @menu-dark-danger-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-dark&-dark:not(&-horizontal) &-item-danger&-item-selected {
|
||||||
|
color: @menu-dark-highlight-color;
|
||||||
|
background-color: @menu-dark-item-active-danger-bg;
|
||||||
|
}
|
||||||
|
}
|
@ -516,7 +516,9 @@
|
|||||||
@menu-popup-bg: @component-background;
|
@menu-popup-bg: @component-background;
|
||||||
@menu-item-color: @text-color;
|
@menu-item-color: @text-color;
|
||||||
@menu-highlight-color: @primary-color;
|
@menu-highlight-color: @primary-color;
|
||||||
|
@menu-highlight-danger-color: @error-color;
|
||||||
@menu-item-active-bg: @primary-1;
|
@menu-item-active-bg: @primary-1;
|
||||||
|
@menu-item-active-danger-bg: @red-1;
|
||||||
@menu-item-active-border-width: 3px;
|
@menu-item-active-border-width: 3px;
|
||||||
@menu-item-group-title-color: @text-color-secondary;
|
@menu-item-group-title-color: @text-color-secondary;
|
||||||
@menu-icon-size: @font-size-base;
|
@menu-icon-size: @font-size-base;
|
||||||
@ -531,11 +533,13 @@
|
|||||||
|
|
||||||
// dark theme
|
// dark theme
|
||||||
@menu-dark-color: @text-color-secondary-dark;
|
@menu-dark-color: @text-color-secondary-dark;
|
||||||
|
@menu-dark-danger-color: @error-color;
|
||||||
@menu-dark-bg: @layout-header-background;
|
@menu-dark-bg: @layout-header-background;
|
||||||
@menu-dark-arrow-color: #fff;
|
@menu-dark-arrow-color: #fff;
|
||||||
@menu-dark-submenu-bg: #000c17;
|
@menu-dark-submenu-bg: #000c17;
|
||||||
@menu-dark-highlight-color: #fff;
|
@menu-dark-highlight-color: #fff;
|
||||||
@menu-dark-item-active-bg: @primary-color;
|
@menu-dark-item-active-bg: @primary-color;
|
||||||
|
@menu-dark-item-active-danger-bg: @error-color;
|
||||||
@menu-dark-selected-item-icon-color: @white;
|
@menu-dark-selected-item-icon-color: @white;
|
||||||
@menu-dark-selected-item-text-color: @white;
|
@menu-dark-selected-item-text-color: @white;
|
||||||
@menu-dark-item-hover-bg: transparent;
|
@menu-dark-item-hover-bg: transparent;
|
||||||
|
Loading…
Reference in New Issue
Block a user