Changeset 4467
- Timestamp:
- 12/04/2016 05:14:43 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/favorite-button/button.jsx
r4223 r4467 1 1 import React from 'react'; 2 import { connect } from 'react-redux'; 3 import includes from 'lodash/includes'; 2 4 3 export defaultReact.createClass( {5 const FavoriteButton = React.createClass( { 4 6 displayName: 'FavoriteButton', 5 7 6 getInitialState: function() {7 return {8 favorite: this.props.initialFavorite9 };10 },11 12 8 toggleFavorite( event ) { 13 const component = this, 14 $button = jQuery( event.target ); 9 const $button = jQuery( event.target ); 15 10 16 11 this.props.toggleFavorite( event ); … … 18 13 $button.addClass( 'is-animating' ).one( 'animationend', function() { 19 14 $button.toggleClass( 'is-animating favorited' ); 20 component.setState( { favorite: ! component.state.favorite } );21 15 } ); 22 16 }, … … 25 19 let classNames = [ 'plugin-favorite-heart' ]; 26 20 27 if ( this. state.favorite ) {21 if ( this.props.favorite ) { 28 22 classNames.push( 'favorited' ); 29 23 } … … 32 26 <div className="plugin-favorite"> 33 27 <button type="button" className={ classNames.join( ' ' ) } onClick={ this.toggleFavorite } > 34 <span className="screen-reader-text">{ `Favorite ${ this.props.plugin.name }` }</span> 28 <span className="screen-reader-text"> 29 { this.props.favorite 30 ? `Unfavorite ${ this.props.plugin.name }` 31 : `Favorite ${ this.props.plugin.name }` 32 } 33 </span> 35 34 </button> 36 35 </div> … … 38 37 } 39 38 } ); 39 40 export default connect( 41 ( state, { plugin } ) => ( { 42 favorite: includes( state.favorites, plugin.slug ) 43 } ), 44 )( FavoriteButton ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/favorite-button/index.jsx
r4223 r4467 1 1 import React from 'react'; 2 import { connect } from 'react-redux';3 import includes from 'lodash/includes';4 2 5 3 import FavoriteButton from './button'; … … 10 8 } from 'actions/index'; 11 9 12 const FavoriteButtonContainer =React.createClass( {10 export default React.createClass( { 13 11 componentDidMount() { 14 12 this.getFavorites(); … … 34 32 35 33 render() { 36 return <FavoriteButton { ...this.props }toggleFavorite={ this.toggleFavorite } />;34 return <FavoriteButton toggleFavorite={ this.toggleFavorite } />; 37 35 } 38 36 } ); 39 40 const mapStateToProps = ( state, ownProps ) => ( {41 initialFavorite: includes( state.favorites, ownProps.plugin.slug )42 } );43 44 export default connect( mapStateToProps )( FavoriteButtonContainer ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/favorite-button/style.scss
r4224 r4467 69 69 } 70 70 71 &:focus { 72 outline: thin dotted; 73 } 74 71 75 &:hover, 72 76 &:focus { -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/css/style-rtl.css
r4466 r4467 2171 2171 } 2172 2172 2173 .plugin-favorite .plugin-favorite-heart:focus { 2174 outline: thin dotted; 2175 } 2176 2173 2177 .plugin-favorite .plugin-favorite-heart:hover, .plugin-favorite .plugin-favorite-heart:focus { 2174 2178 text-decoration: none; -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/css/style.css
r4466 r4467 2171 2171 } 2172 2172 2173 .plugin-favorite .plugin-favorite-heart:focus { 2174 outline: thin dotted; 2175 } 2176 2173 2177 .plugin-favorite .plugin-favorite-heart:hover, .plugin-favorite .plugin-favorite-heart:focus { 2174 2178 text-decoration: none; -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
r4410 r4467 68 68 if ( is_user_logged_in() ) : 69 69 $url = Template::get_favourite_link( $post ); 70 $is_favorited = Tools::favorited_plugin( $post ); 70 71 ?> 71 72 <div class="plugin-favorite"> 72 <a href="<?php echo esc_url( $url ); ?>" class="plugin-favorite-heart<?php echo Tools::favorited_plugin( $post ) ? ' favorited' : ''; ?>"></a> 73 <a href="<?php echo esc_url( $url ); ?>" class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>"> 74 <span class="screen-reader-text"> 75 <?php printf( $is_favorited ? __( 'Favorite %s' ) : __( 'Unfavorite %s' ), get_the_title() ); ?> 76 </span> 77 </a> 73 78 <script> 74 79 jQuery( '.plugin-favorite-heart' )
Note: See TracChangeset
for help on using the changeset viewer.