Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (10 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/plugin/sections/faq/index.jsx

    r4410 r5024  
    1 import React from 'react';
     1/**
     2 * External 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: 'FAQ',
     8export class FAQ extends Component {
     9        static propTypes = {
     10                content: PropTypes.string,
     11                translate: PropTypes.func,
     12        };
    513
    6         toggleAnswer( event ) {
    7                 var $question = jQuery( event.target );
     14        static defaultProps = {
     15                content: null,
     16                translate: identity,
     17        };
     18
     19        toggleAnswer = ( event ) => {
     20                const $question = jQuery( event.target );
    821
    922                if ( ! $question.is( '.open' ) ) {
    10                         $question.siblings( '.open' ).toggleClass( 'open' ).attr( 'aria-expanded', false ).next( 'dd' ).slideToggle( 200 );
     23                        $question.siblings( '.open' ).toggleClass( 'open' ).attr( 'aria-expanded', false )
     24                                .next( 'dd' ).slideToggle( 200 );
    1125                }
    1226
    13                 $question.toggleClass( 'open' ).attr( 'aria-expanded', function( index, attribute ) {
    14                         return 'true' !== attribute;
    15                 } ).next( 'dd' ).slideToggle( 200 );
    16         },
     27                $question.toggleClass( 'open' ).attr( 'aria-expanded', ( index, attribute ) => ( 'true' !== attribute ) )
     28                        .next( 'dd' ).slideToggle( 200 );
     29        };
    1730
    1831        render() {
    19                 if ( ! this.props.content ) {
    20                         return <div />;
     32                const { content, translate } = this.props;
     33
     34                if ( content ) {
     35                        return (
     36                                <div id="faq" className="section plugin-faq">
     37                                        <h2>{ translate( 'FAQ' ) }</h2>
     38                                        <div onClick={ this.toggleAnswer } dangerouslySetInnerHTML={ { __html: content } } />
     39                                </div>
     40                        );
    2141                }
    2242
    23                 return (
    24                         <div id="faq">
    25                                 <h2>FAQ</h2>
    26                                 <div onClick={ this.toggleAnswer } dangerouslySetInnerHTML={ { __html: this.props.content } } />
    27                         </div>
    28                 )
     43                return null;
    2944        }
    30 } );
     45}
     46
     47export default localize( FAQ );
Note: See TracChangeset for help on using the changeset viewer.