Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/front-page/plugin-section/plugin-section.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/front-page/plugin-section/plugin-section.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'; 2 7 import { Link } from 'react-router'; 8 import { localize } from 'i18n-calypso'; 3 9 4 10 /** 5 11 * Internal dependencies. 6 12 */ 13 import { getSection, getSectionPlugins } from 'state/selectors'; 7 14 import PluginCard from 'components/plugin-card'; 8 15 9 export default React.createClass( { 10 displayName: 'PluginSection', 11 12 render() { 13 if ( ! this.props.plugins ) { 14 return <div />; 15 } 16 16 /** 17 * 18 * @param {Array} plugins Plugins 19 * @param {Object} section Section 20 * @param {Function} translate Translation function 21 * @return {(XML|null)} Component or null. 22 * @constructor 23 */ 24 export const PluginSection = ( { plugins, section, translate } ) => { 25 if ( plugins ) { 17 26 return ( 18 27 <section className="plugin-section"> 19 28 <header className="section-header"> 20 <h2 className="section-title">{ this.props.section.title }</h2>21 <Link className="section-link" to={ this.props.section.path }>See all</Link>29 <h2 className="section-title">{ section.name }</h2> 30 <Link className="section-link" to={ `/browse/${ section.slug }/` }>{ translate( 'See all' ) }</Link> 22 31 </header> 23 { this.props.plugins.map( slug => 24 <PluginCard key={ slug } slug={ slug } /> 25 ) } 32 { plugins.map( ( plugin ) => <PluginCard key={ plugin.id } plugin={ plugin } /> ) } 26 33 </section> 27 ) 34 ); 28 35 } 29 } ); 36 37 return null; 38 }; 39 40 PluginSection.propTypes = { 41 plugins: PropTypes.array, 42 section: PropTypes.object, 43 translate: PropTypes.func, 44 }; 45 46 PluginSection.defaultProps = { 47 plugins: [], 48 section: {}, 49 translate: identity, 50 }; 51 52 export default connect( 53 ( state, { type } ) => ( { 54 plugins: getSectionPlugins( state, type ).slice( 0, 4 ), 55 section: getSection( state, type ), 56 } ), 57 )( localize( PluginSection ) );
Note: See TracChangeset
for help on using the changeset viewer.