Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/site-header/main-navigation/index.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/site-header/main-navigation/index.jsx
r4223 r5024 1 import React from 'react'; 1 /** 2 * External dependencies. 3 */ 4 import React, { PropTypes } from 'react'; 5 import { connect } from 'react-redux'; 6 import { identity } from 'lodash'; 7 import { localize } from 'i18n-calypso'; 2 8 9 /** 10 * Internal dependencies. 11 */ 3 12 import MenuItem from './menu-item'; 4 13 import SearchForm from 'components/search-form'; 5 14 6 export default React.createClass( { 7 displayName: 'MainNavigation', 15 export const MainNavigation = ( { menuItems, translate } ) => ( 16 <nav id="site-navigation" className="main-navigation" role="navigation"> 17 <button 18 className="menu-toggle dashicons dashicons-arrow-down-alt2" 19 aria-controls="primary-menu" 20 aria-expanded="false" 21 aria-label={ translate( 'Primary Menu' ) } 22 /> 23 <div id="primary-menu" className="menu"> 24 <ul> 25 { menuItems.map( ( menuItem, key ) => <MenuItem key={ key } item={ menuItem } /> ) } 26 <li><SearchForm /></li> 27 </ul> 28 </div> 29 </nav> 30 ); 8 31 9 getDefaultProps() { 10 return { 11 menuItems: [ 12 { 13 path: 'browse/favorites/', 14 label: 'My Favorites' 15 }, 16 { 17 path: 'browse/beta/', 18 label: 'Beta Testing' 19 }, 20 { 21 path: 'developers/', 22 label: 'Developers' 23 } 24 ] 25 } 26 }, 32 MainNavigation.propTypes = { 33 menuItems: PropTypes.arrayOf( PropTypes.object ), 34 translate: PropTypes.func, 35 }; 27 36 28 render() { 29 var menuItems = this.props.menuItems.map( ( menuItem, key ) => <MenuItem key={ key } item={ menuItem } /> ); 37 MainNavigation.defaultProps = { 38 menuItems: [], 39 translate: identity, 40 }; 30 41 31 return ( 32 <nav id="site-navigation" className="main-navigation" role="navigation"> 33 <button className="menu-toggle dashicons dashicons-arrow-down-alt2" aria-controls="primary-menu" aria-expanded="false" aria-label="Primary Menu"></button> 34 <div id="primary-menu" className="menu"> 35 <ul> 36 { menuItems } 37 <li> 38 <SearchForm searchTerm={ this.props.searchTerm } /> 39 </li> 40 </ul> 41 </div> 42 </nav> 43 ) 44 } 45 } ); 42 export default localize( connect( 43 ( state, { translate } ) => ( { 44 menuItems: [ 45 { 46 path: 'browse/favorites/', 47 label: translate( 'My Favorites' ), 48 }, 49 { 50 path: 'browse/beta/', 51 label: translate( 'Beta Testing' ), 52 }, 53 { 54 path: 'developers/', 55 label: translate( 'Developers' ), 56 }, 57 ], 58 } ), 59 )( MainNavigation ) );
Note: See TracChangeset
for help on using the changeset viewer.