Skip to content

Commit

Permalink
点击按钮隐藏顶部主导航功能
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 29, 2018
1 parent 1ddaa7e commit 4885aba
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/component/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Header extends Component {
super(props);
this.state = {
type: props.contentType || 'trending',
visible: JSON.parse(localStorage.getItem('osc-header')) || false,
menus: [
{
title: '开发文档',
Expand All @@ -33,15 +34,22 @@ export default class Header extends Component {
this.setState({ type });
onChange(type);
}
onDropDown() {
this.setState({
visible: !this.state.visible,
}, () => {
localStorage.setItem('osc-header', this.state.visible);
});
}
render() {
return (
<div className={ styles.warpper } >
<div className={styles.warpper} style={{ marginTop: this.state.visible ? 0 : -50 }}>
<div className={ styles.logo } >
<a href="http://www.oschina.net/" rel="noopener noreferrer" target="_blank" >
<img title="开源中国" alt="开源中国" src={ logo } />
</a>
</div>
<div className={ styles.menu } >
<div className={styles.menu}>
<div className={styles.nav}>
{this.state.menus.map((item, idx) => {
return (
Expand All @@ -52,8 +60,9 @@ export default class Header extends Component {
<a href="https://gitee.com/" > <img title="码云" alt="码云" src={ gitee } /></a>
<a href="https://github.com/" > <img title="Github" alt="Github" src={ github } /></a>
<a href="http://wangchujiang.com/awesome-mac/index.zh.html" > <img title="Mac精品软件推荐" alt="Mac精品软件推荐" src={ apple } /></a>
{/* <span className={styles.setting}> <img title="Mac精品软件推荐" alt="Mac精品软件推荐" src={setting} /> </span> */}
{/* <span className={styles.setting}> <img title="" alt="" src={setting} /> </span> */}
</div>
<div onClick={this.onDropDown.bind(this)} className={styles.dropDown} />
</div>
);
}
Expand Down
36 changes: 36 additions & 0 deletions src/component/Header.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
display: flex;
align-items: center;
justify-content:space-between;
transition: all .3s;
img {
height: 30px;
}
Expand Down Expand Up @@ -57,4 +58,39 @@
height: 100%;
display: block;
}
}

.dropDown {
float: right;
position: absolute;
margin: 34px 0 0 0;
right: 20px;
width: 8px;
cursor: pointer;
&:hover {
&::after, &::before {
background-color: #009801;
}
}
&:active {
&::after, &::before {
background-color: #015a00;
}
}
&::after, &::before {
content: '';
display: block;
background-color: #afafaf;
transition: all .3s;
}
&::before {
height: 10px;
width: 2px;
margin: 0 0 0 3px;
}
&::after {
width: 8px;
height: 8px;
border-radius: 50%;
}
}
10 changes: 9 additions & 1 deletion src/pages/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ export default class Document extends Component {
<div className={styles.tag}>
{this.state.subMenu.map((item, idx) => {
return (
<span key={idx} onClick={this.onChangeTag.bind(this, item.tag)}>{item.title}</span>
<span
className={classNames({
active: this.state.tag === item.tag,
})}
key={idx}
onClick={this.onChangeTag.bind(this, item.tag)}
>
{item.title}
</span>
);
})}
</div>
Expand Down
15 changes: 13 additions & 2 deletions src/pages/Document.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

.header {
padding: 15px 5px 15px;
padding: 15px 15px 25px;
font-size: 24px;
color: #c1c1c1;
font-size: 18px;
Expand All @@ -20,8 +20,17 @@
margin: 0 0 0 10px;
span {
display: inline-block;
margin: 0 3px;
padding: 0 3px 0 3px;
border-radius: 2px;
height: 18px;
line-height: 18px;
margin: 0 2px;
cursor: pointer;
transition: background-color .3s;
&:hover, &:global(.active) {
background-color: #868686;
color: #fff;
}
}
}
}
Expand All @@ -30,6 +39,7 @@
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 0 15px;
li {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -127,6 +137,7 @@
}
}
}

.zhHans {
circle, path {
color: #606467;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Github.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
padding: 10px;
.title {
margin: 0;
padding: 15px 5px 15px;
padding: 15px 15px 25px;
font-size: 24px;
color: #c1c1c1;
font-size: 18px;
Expand All @@ -18,6 +18,7 @@
}

.list {
padding: 0 15px;
a {
text-decoration: none;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/History.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.list {
line-height: 32px;
padding: 5px 0;
margin: 0 15px;
background-color: #fff;
a {
color: #333;
Expand Down Expand Up @@ -40,7 +41,7 @@

.title {
margin: 0;
padding: 15px 5px 15px;
padding: 15px 15px 25px;
font-size: 24px;
color: #c1c1c1;
font-size: 18px;
Expand Down

0 comments on commit 4885aba

Please sign in to comment.