theme dark

This commit is contained in:
yuntao.qyt 2015-11-12 14:57:54 +08:00
parent ad54bfeae7
commit 9a3cfc096f
5 changed files with 263 additions and 10 deletions

View File

@ -30,7 +30,7 @@ var Sider = React.createClass({
});
},
render() {
return <Menu onClick={this.handleClick}
return <Menu theme="dark" onClick={this.handleClick}
style={{width:240}}
openKeys={this.state.openKeys}
onOpen={this.onToggle}

View File

@ -23,7 +23,7 @@ var Sider = React.createClass({
});
},
render() {
return <Menu onClick={this.handleClick}
return <Menu theme="dark" onClick={this.handleClick}
style={{width:240}}
defaultOpenKeys={['sub1']}
selectedKeys={[this.state.current]}

View File

@ -14,7 +14,7 @@ function handleClick(e) {
console.log('click', e);
}
ReactDOM.render(<Menu onClick={handleClick} style={{width:240}} mode="vertical">
ReactDOM.render(<Menu theme="dark" onClick={handleClick} style={{width:240}} mode="vertical">
<SubMenu key="sub1" title={<span><Icon type="mail" /><span>导航一</span></span>}>
<Menu.Item key="1">选项1</Menu.Item>
<Menu.Item key="2">选项2</Menu.Item>

View File

@ -38,6 +38,10 @@ const AntMenu = React.createClass({
this.props.onClose();
},
render() {
this.theme = '';
if (this.props.theme) {
this.theme = this.props.theme;
}
let openAnimation = '';
switch (this.props.mode) {
case 'horizontal':
@ -51,14 +55,19 @@ const AntMenu = React.createClass({
break;
default:
}
let props = {
openKeys: this.state.openKeys,
onClick: this.handleClick,
onOpen: this.handleOpenKeys,
onClose: this.handleCloseKeys,
className: this.theme,
};
if (this.props.mode === 'inline') {
return <Menu {...this.props} openAnimation={openAnimation} />;
props = {
className: this.theme,
};
return <Menu {...this.props} {...props} openAnimation={openAnimation} />;
} else {
return <Menu {...this.props} {...props} openTransitionName={openAnimation} />;
}

View File

@ -1,12 +1,12 @@
@menu-prefix-cls: ~"@{css-prefix}menu";
// default theme
.@{menu-prefix-cls} {
outline: none;
margin-bottom: 0;
padding-left: 0; // Override default ul/ol
list-style: none;
z-index: 999;
// border: 1px solid #d9d9d9;
box-shadow: @overlay-shadow;
border-radius: @border-radius-base;
color: @text-color;
@ -58,12 +58,19 @@
&-vertical,
&-inline {
border-right: 1px solid #d9d9d9;
border-right: 1px solid #e9e9e9;
.ant-menu-item-selected,
.ant-menu-item-active {
border-right: 2px solid @primary-color;
.@{menu-prefix-cls}-item {
border-right: 2px solid transparent;
margin-left: -1px;
left: 1px;
position: relative;
z-index: 1;
}
.@{menu-prefix-cls}-selected,
.@{menu-prefix-cls}-item-active {
border-right: 2px solid @primary-color;
}
}
@ -219,7 +226,6 @@
}
&-vertical, &-inline {
padding: 12px 0;
& > .@{menu-prefix-cls}-item, & > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
padding: 0 24px;
font-size: 12px;
@ -280,3 +286,241 @@
top: -1px;
}
}
// dark theme
.dark.@{menu-prefix-cls} {
color: rgba(255, 255, 255, 0.45);
background: #404040;
.@{menu-prefix-cls}-item-group-title {
color: #999;
border-bottom: 1px solid #dedede;
}
.@{menu-prefix-cls}-inline > .@{menu-prefix-cls}-item-active,
.@{menu-prefix-cls}-submenu-inline.@{menu-prefix-cls}-submenu-active,
.@{menu-prefix-cls}-submenu-inline&-submenu-active > .@{menu-prefix-cls}-submenu-title:hover {
background-color: #3F3F3F;
}
.@{menu-prefix-cls}-inline > .@{menu-prefix-cls}-item-active:hover,
.@{menu-prefix-cls}-item-active,
.@{menu-prefix-cls}-submenu-active,
.@{menu-prefix-cls}-submenu-inline.@{menu-prefix-cls}-submenu-active > .@{menu-prefix-cls}-submenu-title:hover {
background-color: #2DB7F5;
color: #FFF;
.anticon {
color: #FFF;
}
}
&-item, &-submenu-title {
margin: 0;
position: relative;
display: block;
white-space: nowrap;
// Disabled state sets text to gray and nukes hover/tab effects
&.@{menu-prefix-cls}-item-disabled, &.@{menu-prefix-cls}-submenu-disabled {
color: #999 !important;
}
}
.@{menu-prefix-cls} > .@{menu-prefix-cls}-item-divider {
height: 1px;
margin: 1px 0;
overflow: hidden;
padding: 0;
line-height: 0;
background-color: #e5e5e5;
}
&-submenu {
position: relative;
> .@{menu-prefix-cls} {
background-color: #fff;
}
&-vertical > .@{menu-prefix-cls}-submenu-title:after {
font-family: "anticon" !important;
font-style: normal;
vertical-align: baseline;
text-align: center;
text-transform: none;
text-rendering: auto;
position: absolute;
transition: transform .3s ease;
content: "\e600";
right: 16px;
.ie-rotate(3);
transform: rotate(270deg) scale(0.75);
}
&-inline > .@{menu-prefix-cls}-submenu-title:after {
font-family: "anticon" !important;
font-style: normal;
vertical-align: baseline;
text-align: center;
text-transform: none;
text-rendering: auto;
position: absolute;
transition: transform .3s ease;
content: "\e600";
right: 16px;
top: 0;
.iconfont-size-under-12px(8px);
}
&-open {
&.@{menu-prefix-cls}-submenu-inline > .@{menu-prefix-cls}-submenu-title:after {
.ie-rotate(1);
transform: rotate(180deg) scale(0.75);
}
}
}
.@{menu-prefix-cls}-submenu-title, .@{menu-prefix-cls}-item {
.anticon {
width: 14px;
margin-right: 8px;
top: -1px;
color: #999;
}
}
&-horizontal {
background-color: #FBFBFB;
border: none;
border-bottom: 1px solid #d9d9d9;
box-shadow: none;
border-radius: 0;
padding-left: 24px;
z-index: 0;
& > .@{menu-prefix-cls}-item,
& > .@{menu-prefix-cls}-submenu {
padding: 0 20px;
line-height: 50px;
position: relative;
top: 1px;
> a , > span{
line-height: 51px;
}
> a {
display: block;
color: @text-color;
&:hover {
color: @primary-color;
}
&:before, &:after {
position: absolute;
background-color: rgba(255, 255, 255, 0.001);
width: 20px;
height: 50px;
content: '';
}
&:before {
left: 0;
}
}
}
& > .@{menu-prefix-cls}-submenu, & > .@{menu-prefix-cls}-item {
float: left;
border-bottom: 2px solid transparent;
margin-right: 24px;
&-active,
&-selected {
border-bottom: 2px solid #2DB7F5;
background-color: #2DB7F5;
color: @primary-color;
.anticon {
color: @primary-color;
}
}
}
&:after {
content: "\20";
display: block;
height: 0;
clear: both;
}
}
.@{menu-prefix-cls}-vertical,
.@{menu-prefix-cls}-inline {
.@{menu-prefix-cls}-submenu {
background: #404040;
}
}
.@{menu-prefix-cls}-vertical,
.@{menu-prefix-cls}-inline {
.@{menu-prefix-cls}-item,
.@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
background-color: #333333;
color: rgba(255, 255, 255, 0.45);
}
}
.@{menu-prefix-cls}-vertical,
.@{menu-prefix-cls}-inline {
border-right: 1px solid #3F3F3F;
.@{menu-prefix-cls}-item.@{menu-prefix-cls}-item-selected,
.@{menu-prefix-cls}-item.@{menu-prefix-cls}-item-active {
border-right: 2px solid #2DB7F5;
background-color: #2DB7F5;
color: #FFF;
}
}
&-vertical, &-horizontal {
.@{menu-prefix-cls}-submenu {
.@{menu-prefix-cls}-item:first-child {
border-radius: @border-radius-base @border-radius-base 0 0;
}
.@{menu-prefix-cls}-item:last-child {
border-radius: 0 0 @border-radius-base @border-radius-base;
}
&:first-child {
border-radius: @border-radius-base @border-radius-base 0 0;
}
&:last-child {
border-radius: 0 0 @border-radius-base @border-radius-base;
}
}
}
&-vertical&-sub {
padding: 0;
transform-origin: 0 0;
& > .@{menu-prefix-cls}-item, & > .@{menu-prefix-cls}-submenu {
transform-origin: 0 0;
}
}
&-root&-vertical,
&-root&-inline {
border-radius: 0;
box-shadow: none;
}
&-sub&-inline {
padding: 0;
border: none;
border-radius: 0;
box-shadow: none;
& > .@{menu-prefix-cls}-item, & > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
line-height: 34px;
height: 34px;
list-style-type: disc;
list-style-position: inside;
}
}
}