Skip to content

Commit

Permalink
Add a filter menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 15, 2017
1 parent f6a191f commit bd83b22
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Root.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React,{Component} from 'react'
import menuSource from "../data/"
import Menu from "./menu"
import Filter from "./filter"


export default class Root extends Component{
Expand All @@ -21,13 +22,12 @@ export default class Root extends Component{
}else{
source = [];
}
console.log("--->",e,"---2>",key)
this.setState({contentSource:source})
}} />
</div>
<div className="content">
<header className="header">
header menu
<Filter />
</header>

<div className="article-content">
Expand Down
56 changes: 56 additions & 0 deletions src/components/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React,{Component} from 'react'
import {Icons} from './icon'

export default class Filter extends Component {
static defaultProps = {
dataSource:[],
onClick:new Function
}
constructor(props){
super(props)
this.state = {
dataSource:{
"free":{},
"hot":{},
"recommended":{},
"must-have":{},
"app-store":{},
"open-source":{},
},
onClick:this.props.onClick,
selector:"",
}
}
renderListItem(source,onClick){
let elms = [];
for(let i in source){
elms.push(
<li style={i==this.state.selector?styles.active:styles.cancel} key={i} onClick={()=>{
}}>
<Icons type={i}/>
</li>
)
}
return elms
}
render(){
return (
<ul className="menu-filter">
{this.renderListItem(this.state.dataSource,this.props.onClick)}
</ul>
)
}
componentDidMount(){
this.setState({dataSource:this.state.dataSource})
}
}


var styles = {
active:{
backgroundColor:"rgba(255, 255, 255, 0.11)"
},
cancel:{
backgroundColor:"transparent"
}
}
86 changes: 83 additions & 3 deletions src/components/icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ li,ul{
flex-direction:column;
.header{
height: 43px;
overflow: hidden;
-webkit-app-region: drag;
user-select: none;
background-image: linear-gradient(-180deg, #E8E6E8 0%, #D6D4D6 98%);
Expand Down Expand Up @@ -73,6 +74,21 @@ li,ul{
}
i{
padding: 0 5px 0 0;
vertical-align: middle;
display: inline-block;
position: relative;
top: -1px;
}
}
}

.menu-filter{
padding: 0 0 0 7px;
li{
display: inline-block;
margin: 12px 5px;
&:hover{
background-color:rgba(255, 255, 255, 0.11)
}
}
}

0 comments on commit bd83b22

Please sign in to comment.