Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/search/search.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/search/search.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 ContentNone from 'components/content-none'; 4 13 import PluginCard from 'components/plugin-card'; 14 import { getSearchResults } from 'state/selectors'; 5 15 6 export default React.createClass( { 7 displayName: 'Search', 16 export const Search = ( { params, plugins, translate } ) => { 17 if ( ! plugins ) { 18 return <div>{ translate( 'Loading…' ) }</div>; 19 } 8 20 9 render() { 10 if ( ! this.props.plugins ) { 11 return <div>{ 'Loading...' }</div>; 12 } 21 if ( 0 === plugins.length ) { 22 return <ContentNone />; 23 } 13 24 14 if ( 0 === this.props.plugins.length ) { 15 return <ContentNone { ...this.props } />; 16 } 25 return ( 26 <div> 27 <header className="page-header"> 28 <h1 className="page-title"> 29 { translate( 'Search results for: {{strong}}%(search)s{{/strong}}', { 30 args: { search: params.search }, 31 components: { strong: <strong /> }, 32 } ) } 33 </h1> 34 <div className="taxonomy-description" /> 35 </header> 36 { plugins.map( ( slug ) => <PluginCard key={ slug } slug={ slug } /> ) } 37 </div> 38 ); 39 }; 17 40 18 return ( 19 <div> 20 <header className="page-header"> 21 <h1 className="page-title">Search results for: <strong>{ this.props.params.searchTerm }</strong></h1> 22 <div className="taxonomy-description"></div> 23 </header> 24 { this.props.plugins.map( slug => 25 <PluginCard key={ slug } slug={ slug } /> 26 ) } 27 </div> 28 ); 29 } 30 } ); 41 Search.propTypes = { 42 params: PropTypes.object, 43 plugins: PropTypes.arrayOf( PropTypes.string ), 44 translate: PropTypes.func, 45 }; 46 47 Search.defaultProps = { 48 params: {}, 49 plugins: [], 50 translate: identity, 51 }; 52 53 export default connect( 54 ( state ) => ( { 55 plugins: getSearchResults( state ), 56 } ), 57 )( localize( Search ) );
Note: See TracChangeset
for help on using the changeset viewer.