-
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
6 changed files
with
326 additions
and
1 deletion.
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
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,39 @@ | ||
/** TabMenu **/ | ||
.ui-tabmenu { | ||
|
||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav { | ||
margin: 0; | ||
padding: .25em .5em 0 .25em; | ||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav .ui-tabmenuitem { | ||
list-style: none; | ||
float: left; | ||
position: relative; | ||
margin: 0 .2em 1px 0; | ||
padding: 0; | ||
white-space: nowrap; | ||
display: block; | ||
border-bottom: 0; | ||
top: 1px; | ||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav .ui-tabmenuitem a { | ||
float: left; | ||
padding: 0.5em 1em; | ||
text-decoration: none; | ||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav a { | ||
padding: 0.5em 1em; | ||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav .ui-tabmenuitem .ui-icon { | ||
float: left; | ||
} | ||
|
||
.ui-tabmenu .ui-tabmenu-nav .ui-tabmenuitem.ui-state-disabled a { | ||
cursor: default; | ||
} |
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,68 @@ | ||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import {MenuItem} from '../menu/Menu'; | ||
|
||
export class TabMenu extends Component { | ||
|
||
static defaultProps = { | ||
model:null, | ||
activeItem:null, | ||
style:null, | ||
styleClass:null, | ||
}; | ||
|
||
static propTypes = { | ||
model:PropTypes.array, | ||
activeItem:PropTypes.any, | ||
style:PropTypes.any, | ||
styleClass:PropTypes.string, | ||
}; | ||
|
||
|
||
constructor(props) { | ||
super(props); | ||
this.state ={activeItem:this.props.activeItem || this.props.model[0]}; | ||
} | ||
|
||
itemClick(event, item) { | ||
if(item.disabled) { | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
if(!item.url) { | ||
event.preventDefault(); | ||
} | ||
|
||
if(item.command) { | ||
item.command({ | ||
originalEvent: event, | ||
item: item | ||
}); | ||
} | ||
|
||
this.setState({activeItem:item}); | ||
} | ||
|
||
render() { | ||
var tabMenuClass=classNames('ui-tabmenu ui-widget ui-widget-content ui-corner-all',this.props.styleClass); | ||
|
||
var item=this.props.model && this.props.model.map((item,index)=>{ | ||
var listClass=classNames('ui-tabmenuitem ui-state-default ui-corner-top',{'ui-state-disabled':item.disabled}, | ||
{'ui-tabmenuitem-hasicon':item.icon},{'ui-state-active':this.state.activeItem===item}) | ||
var list=<li className={listClass} key={'tabmenuItem_' + index}> | ||
<MenuItem index={index} items={item} menu={this}/> | ||
</li> | ||
return list; | ||
}) | ||
|
||
return ( | ||
<div className={tabMenuClass} style={this.props.style} ref={el=>this.container=el}> | ||
<ul className="ui-tabmenu-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist"> | ||
{item} | ||
</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
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,215 @@ | ||
import React, {Component} from 'react'; | ||
import {Link} from 'react-router'; | ||
import {TabMenu} from '../../components/tabmenu/TabMenu'; | ||
import {TabView,TabPanel} from '../../components/tabview/TabView'; | ||
import {CodeHighlight} from '../../components/codehighlight/CodeHighlight'; | ||
|
||
export class TabMenuDemo extends Component { | ||
|
||
constructor() { | ||
super(); | ||
this.state = {}; | ||
} | ||
|
||
render() { | ||
var items=[ | ||
{label: 'Stats', icon: 'fa-bar-chart'}, | ||
{label: 'Calendar', icon: 'fa-calendar'}, | ||
{label: 'Documentation', icon: 'fa-book'}, | ||
{label: 'Support', icon: 'fa-support'}, | ||
{label: 'Social', icon: 'fa-twitter'} | ||
]; | ||
return ( | ||
<div> | ||
<div className="content-section"> | ||
<div className="feature-intro"> | ||
<h1>TabMenu</h1> | ||
<p>Menu is a navigation/command component that displays items as tab headers.</p> | ||
</div> | ||
</div> | ||
<div className="content-section implementation"> | ||
<TabMenu model={items}/> | ||
</div> | ||
|
||
<TabMenuDoc/> | ||
|
||
</div> | ||
); | ||
} | ||
} | ||
|
||
class TabMenuDoc extends Component { | ||
render() { | ||
return ( | ||
<div className="content-section source"> | ||
<TabView effect="fade"> | ||
<TabPanel header="Documentation"> | ||
<h3>Import</h3> | ||
<CodeHighlight className="language-javascript"> | ||
{` | ||
import {TabMenu} from 'primereact/components/tabmenu/TabMenu'; | ||
`}</CodeHighlight> | ||
<h3>MenuModel API</h3> | ||
<p>TabMenu uses the common menumodel api to define its items, visit <Link to="/menu"> Menu </Link> for details.</p> | ||
|
||
<h3>Getting Started</h3> | ||
<p>TabMenu requires a collection of menuitems as its model.</p> | ||
<CodeHighlight className="language-markup"> | ||
{` | ||
<TabMenu model={items}/> | ||
`} | ||
</CodeHighlight> | ||
<CodeHighlight className="language-markup"> | ||
{` | ||
var items=[ | ||
{label: 'Stats', icon: 'fa-bar-chart'}, | ||
{label: 'Calendar', icon: 'fa-calendar'}, | ||
{label: 'Documentation', icon: 'fa-book'}, | ||
{label: 'Support', icon: 'fa-support'}, | ||
{label: 'Social', icon: 'fa-twitter'} | ||
]; | ||
`} | ||
</CodeHighlight> | ||
<h3>ActiveItem</h3> | ||
<p>By default, first item is activated, use activeItem property to choose the initial active item.</p> | ||
<CodeHighlight className="language-markup"> | ||
{` | ||
<TabMenu model={items} activeItem={items[2]}/> | ||
`} | ||
</CodeHighlight> | ||
|
||
<h3>Attributes</h3> | ||
<div className="doc-tablewrapper"> | ||
<table className="doc-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>model</td> | ||
<td>array</td> | ||
<td>null</td> | ||
<td>An array of menuitems.</td> | ||
</tr> | ||
<tr> | ||
<td>activeItem</td> | ||
<td>MenuItem</td> | ||
<td>null</td> | ||
<td>Defines the default active menuitem</td> | ||
</tr> | ||
<tr> | ||
<td>style</td> | ||
<td>string</td> | ||
<td>null</td> | ||
<td>Inline style of the component.</td> | ||
</tr> | ||
<tr> | ||
<td>styleClass</td> | ||
<td>string</td> | ||
<td>null</td> | ||
<td>Style class of the component.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<h3>Styling</h3> | ||
<p>Following is the list of structural style classes, for theming classes visit <Link to="/theming"> theming</Link> page.</p> | ||
<div className="doc-tablewrapper"> | ||
<table className="doc-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Element</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>ui-tabmenu</td> | ||
<td>Container element.</td> | ||
</tr> | ||
<tr> | ||
<td>ui-tabmenu-nav</td> | ||
<td>List element of headers.</td> | ||
</tr> | ||
<tr> | ||
<td>ui-tabmenuitem</td> | ||
<td>Menuitem element.</td> | ||
</tr> | ||
<tr> | ||
<td>ui-menuitem-link</td> | ||
<td>Link inside a menuitem.</td> | ||
</tr> | ||
<tr> | ||
<td>ui-menuitem-text</td> | ||
<td>Label of a menuitem.</td> | ||
</tr> | ||
<tr> | ||
<td>ui-menuitem-icon</td> | ||
<td>Icon of a menuitem.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<h3>Dependencies</h3> | ||
<p>None.</p> | ||
</TabPanel> | ||
|
||
<TabPanel header="Source"> | ||
<a href="https://github.com/primefaces/primereact/tree/master/src/showcase/tabmenu" className="btn-viewsource" target="_blank"> | ||
<i className="fa fa-github"></i> | ||
<span>View on GitHub</span> | ||
</a> | ||
<CodeHighlight className="language-javascript"> | ||
{` | ||
export class TabMenuDemo extends Component { | ||
constructor() { | ||
super(); | ||
this.state = {}; | ||
} | ||
render() { | ||
var items=[ | ||
{label: 'Stats', icon: 'fa-bar-chart'}, | ||
{label: 'Calendar', icon: 'fa-calendar'}, | ||
{label: 'Documentation', icon: 'fa-book'}, | ||
{label: 'Support', icon: 'fa-support'}, | ||
{label: 'Social', icon: 'fa-twitter'} | ||
]; | ||
return ( | ||
<div> | ||
<div className="content-section"> | ||
<div className="feature-intro"> | ||
<h1>TabMenu</h1>aaaaa | ||
<p>Menu is a navigation/command component that displays items as tab headers.</p> | ||
</div> | ||
</div> | ||
<div className="content-section implementation"> | ||
<TabMenu model={items}/> | ||
</div> | ||
<TabMenuDoc/> | ||
</div> | ||
); | ||
} | ||
} | ||
`} | ||
</CodeHighlight> | ||
</TabPanel> | ||
</TabView> | ||
</div> | ||
) | ||
} | ||
|
||
} |