Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Update React client with latest changes.

This is largely a cleanup commit with some WIP around switching to node-wpapi.

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 */
     4import React, { Component, PropTypes } from 'react';
     5import { identity } from 'lodash';
     6import { localize } from 'i18n-calypso';
    27
    3 export default React.createClass( {
    4     displayName: 'SearchForm',
     8export class SearchForm extends Component {
     9    static propTypes = {
     10        onChange: PropTypes.func,
     11        onSubmit: PropTypes.func,
     12        search: PropTypes.string,
     13        translate: PropTypes.func,
     14    };
    515
    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 );
    924
    1025    render() {
     26        const { onSubmit, search, translate } = this.props;
     27
    1128        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>
    1431                <input
    1532                    className="search-field"
     
    2037                    ref="search"
    2138                    type="search"
    22                     value={ this.props.searchTerm }
     39                    defaultValue={ search }
    2340                />
    2441                <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>
    2744                </button>
    2845            </form>
    29         )
     46        );
    3047    }
    31 } );
     48}
     49
     50export default localize( SearchForm );
Note: See TracChangeset for help on using the changeset viewer.