-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
358 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import {MenuItem} from '../menu/MenuItem' | ||
|
||
export class BreadCrumb extends Component { | ||
|
||
static defaultProps = { | ||
model:null, | ||
home:null, | ||
style:null, | ||
styleClass:null | ||
}; | ||
|
||
static propTypes = { | ||
model:PropTypes.array, | ||
home:PropTypes.any, | ||
style:PropTypes.object, | ||
styleClass:PropTypes.string | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this.state = {}; | ||
} | ||
|
||
|
||
itemClick(event,item){ | ||
if(item.disabled) { | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
if(!item.url) { | ||
event.preventDefault(); | ||
} | ||
|
||
if(item.command) { | ||
item.command({ | ||
originalEvent: event, | ||
item: item | ||
}); | ||
} | ||
} | ||
|
||
|
||
onHomeClick(event) { | ||
if(this.props.home) { | ||
this.itemClick(event, this.props.home); | ||
} | ||
} | ||
|
||
render() { | ||
var styleClass=classNames('ui-breadcrumb ui-widget ui-widget-header ui-helper-clearfix ui-corner-all',this.props.styleClass); | ||
var homeClass=classNames('ui-menuitem-link',{'ui-state-disabled':this.props.home && this.props.home.disabled}) | ||
|
||
var home,right,menu; | ||
|
||
if(this.props.home){ | ||
home=<li className="ui-breadcrumb-home" > | ||
{this.props.home.url? | ||
<a href={this.props.home.url || '#'} className={homeClass} target={this.props.home.target} | ||
onClick={event=>this.itemClick(event,this.props.home)}> | ||
<span className="fa fa-home"></span> | ||
</a>: | ||
<a href='#' className={homeClass} target={this.props.home.target} | ||
onClick={event=>this.itemClick(event,this.props.home)}> | ||
<span className="fa fa-home"></span> | ||
</a>} | ||
</li> | ||
} | ||
else{ | ||
home=<li className="ui-breadcrumb-home fa fa-home" ></li> | ||
} | ||
if(this.props.model){ | ||
right=<li className="ui-breadcrumb-chevron fa fa-chevron-right"></li> | ||
} | ||
menu=this.props.model && this.props.model.map((item,index)=>{ | ||
var menuItem=<span key={index}> | ||
<li role="menuitem"> | ||
<MenuItem items={item} index={index} menu={this} /> | ||
</li> | ||
{this.props.model.length-1!==index && <li className="ui-breadcrumb-chevron fa fa-chevron-right" style={{marginLeft:4,marginRight:4}}></li>} | ||
</span> | ||
return menuItem; | ||
}) | ||
|
||
return ( | ||
<div className={styleClass} style={this.props.style} ref={el=>this.container=el}> | ||
<ul> | ||
{home} | ||
{right} | ||
{menu} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** Breadcrumb **/ | ||
.ui-breadcrumb { | ||
margin: 0; | ||
padding: 0; | ||
padding: .3em; | ||
} | ||
|
||
.ui-breadcrumb ul { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.ui-breadcrumb ul li { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
|
||
.ui-breadcrumb ul li .ui-menuitem-link { | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
export class MenuItem extends Component{ | ||
static defaultProps = { | ||
index:null, | ||
items:null, | ||
menu:null, | ||
}; | ||
|
||
static propTypes = { | ||
index:PropTypes.number, | ||
items:PropTypes.any, | ||
menu:PropTypes.any | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
this.item=this.props.items; | ||
this.menu=this.props.menu | ||
} | ||
|
||
render() { | ||
var styleClass=classNames('ui-menuitem-link ui-corner-all',{'ui-state-disabled':this.item.disabled}) | ||
var iconClass=classNames('ui-menuitem-icon fa fa-fw',this.item.icon?this.item.icon:null) | ||
if(this.item.url){ | ||
return ( | ||
<a href={this.item.url || '#'} className={styleClass} target={this.item.target} onClick={event=>this.menu.itemClick(event,this.item)}> | ||
{this.item.icon?<span className={iconClass}></span>:null} | ||
<span className="ui-menuitem-text">{this.item.label}</span> | ||
</a> | ||
); | ||
} | ||
else{ | ||
return ( | ||
<a className={styleClass} href="#" target={this.item.target} onClick={event=>this.menu.itemClick(event,this.item)}> | ||
{this.item.icon?<span className={iconClass}></span>:null} | ||
<span className="ui-menuitem-text">{this.item.label}</span> | ||
</a> | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.