Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/search-form/search-form.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-form/search-form.jsx
r4223 r5024 1 import React from 'react'; 1 /** 2 * Internal dependencies. 3 */ 4 import React, { Component, PropTypes } from 'react'; 5 import { identity } from 'lodash'; 6 import { localize } from 'i18n-calypso'; 2 7 3 export default React.createClass( { 4 displayName: 'SearchForm', 8 export class SearchForm extends Component { 9 static propTypes = { 10 onChange: PropTypes.func, 11 onSubmit: PropTypes.func, 12 search: PropTypes.string, 13 translate: PropTypes.func, 14 }; 5 15 6 onChange() { 7 this.props.onChange( this.refs.search.value ); 8 }, 16 static defaultProps = { 17 onChange: () => {}, 18 onSubmit: () => {}, 19 search: '', 20 translate: identity, 21 }; 22 23 onChange = () => this.props.onChange( this.refs.search.value ); 9 24 10 25 render() { 26 const { onSubmit, search, translate } = this.props; 27 11 28 return ( 12 <form onSubmit={ this.props.onSubmit } role="search" method="get" className="search-form">13 <label htmlFor="s" className="screen-reader-text"> Search for:</label>29 <form onSubmit={ onSubmit } role="search" method="get" className="search-form"> 30 <label htmlFor="s" className="screen-reader-text">{ translate( 'Search for:' ) }</label> 14 31 <input 15 32 className="search-field" … … 20 37 ref="search" 21 38 type="search" 22 value={ this.props.searchTerm}39 defaultValue={ search } 23 40 /> 24 41 <button className="button button-primary button-search"> 25 <i className="dashicons dashicons-search" ></i>26 <span className="screen-reader-text"> Search plugins</span>42 <i className="dashicons dashicons-search" /> 43 <span className="screen-reader-text">{ translate( 'Search plugins' ) }</span> 27 44 </button> 28 45 </form> 29 ) 46 ); 30 47 } 31 } ); 48 } 49 50 export default localize( SearchForm );
Note: See TracChangeset
for help on using the changeset viewer.