Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

36 - Single product template #39

Merged
merged 29 commits into from
Apr 18, 2018
Merged

36 - Single product template #39

merged 29 commits into from
Apr 18, 2018

Conversation

mehigh
Copy link
Member

@mehigh mehigh commented Apr 15, 2018

This is left:

  • Top carousel
  • mobile fixed CTA overlay
  • mobile content product details / price size / inlining

And of course copying the product.css from ampstart (i've setup that repo next to this and referenced the CSS with a regular CSS link during development).
Reached 44KB of CSS until now.

single-product

@miina
Copy link
Contributor

miina commented Apr 16, 2018

Started adding theme integration
Currently (within 9d60672) using placeholders for header.php, footer.php, and static comments.php from @mehigh's created HTML template.

Maybe comments.php can be implemented within this PR since that's directly related to the CPT template but perhaps proper header template(s) and footer template could be separate PR-s/issues? Thoughts, @kienstra and @postphotos?

@kienstra
Copy link
Contributor

kienstra commented Apr 17, 2018

Header And Footer Templates

Hi @miina,

...perhaps proper header template(s) and footer template could be separate PR-s/issues

That's a good idea. Separate issues and PRs for header.php and footer.php would help organize this.

And we could merge the templates into develop as soon as they're ready, instead of waiting for all of them.

@DavidCramer
Copy link
Contributor

@miina - please take a look at #38 as it could affect the structures.

@miina
Copy link
Contributor

miina commented Apr 17, 2018

@kienstra Forgot to mention that this PR also fixes #8 (Ratings logic).


?>
<!-- Search -->
<section class='travel-search py4 xs-hide sm-hide relative'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a blocker, but it'd be nice to have double quotes in the template. We can go back and address this after the demo on Thursday.

$reviews = wp_count_comments( get_the_ID() );
?>
<?php /* translators: %d: Number of reviews. */ ?>
<p class="travel-results-result-subtext"><?php echo sprintf( esc_html__( '%d Reviews', 'travel' ), esc_html( $reviews->approved ) ); ?></p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be printf() instead of echo sprintf().

?>
<div class="relative h2 line-height-2 mb1">
<div class="travel-results-result-stars green">
<?php for ( $i = 0; $i < $rating; $i++ ) : ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like:

echo esc_html( str_repeat( '*', $rating ) );

<!-- Search -->
<section class='travel-search py4 xs-hide sm-hide relative'>
<div class='px1 md-px2 pb1 relative'>
<h3 class='travel-search-heading travel-spacing-none h1 bold mb2 center'><?php esc_html_e( 'Have a specific destination in mind?' ); ?></h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this include the text domain of 'travel', and likewise for the other translation functions in the file?

esc_html_e( 'Have a specific destination in mind?', 'travel' )

<option value="1"><?php esc_html_e( 'For 1' ); ?></option>
<?php for ( $i = 2; $i <= 8; $i += 2 ) : ?>
<?php /* translators: %d: The number of people */ ?>
<option value="<?php echo esc_attr( $i ); ?>"><?php echo sprintf( esc_html__( 'For %d', 'travel' ), esc_html( $i ) ); ?></option>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor point, but this could be printf instead of echo sprintf.

<?php endfor; ?>
</select>

<a href="#" class="product-cta-btn ampstart-btn rounded center bold white block col-12"><?php esc_html_e( 'Call to book' ); ?></a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this please use the text domain of 'travel'?


?>
<!-- Popular -->
<?php echo amp_travel_render_similar_adventures(); // WPCS: XSS ok. ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this template tag.

* @package WPAMPTheme
*/

// Ignore the issues of this file since that's just a copied HTML placeholder.
Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this footer.php is only a placeholder, it looks good. We could work on dynamic data later, at least after the screencast this Thursday.

<span class="travel-results-result-subtext mr1">' .
/* translators: %d: The number of reviews */
sprintf( esc_html__( '%d Reviews', 'travel' ), esc_html( $comments->approved ) ) . '</span>
<span class="travel-results-result-subtext"><svg class="travel-icon" viewBox="0 0 77 100"><g fill="none" fillRule="evenodd"><path stroke="currentColor" strokeWidth="7.5" d="M38.794 93.248C58.264 67.825 68 49.692 68 38.848 68 22.365 54.57 9 38 9S8 22.364 8 38.85c0 10.842 9.735 28.975 29.206 54.398a1 1 0 0 0 1.588 0z"></path><circle cx="38" cy="39" r="10" fill="currentColor"></circle></g></svg>
Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin's validator raised invalid_attribute errors forfillRule and strokeWidth.

Similar errors appear on copying this entire <svg> into the AMP validator:

The attribute 'fillrule' may not appear in tag 'g'.
The attribute 'strokewidth' may not appear in tag 'path'

The page is still valid AMP, but the preprocessor stripped those attributes.

$location = ! empty( $locations ) ? $locations[0] : '--';
?>
<p class="travel-results-result-subtext mb1">
<svg class="travel-icon" viewBox="0 0 77 100"><g fill="none" fillrule="evenodd"><path stroke="currentColor" strokewidth="7.5" d="M38.794 93.248C58.264 67.825 68 49.692 68 38.848 68 22.365 54.57 9 38 9S8 22.364 8 38.85c0 10.842 9.735 28.975 29.206 54.398a1 1 0 0 0 1.588 0z"></path><circle cx="38" cy="39" r="10" fill="currentColor"></circle></g></svg>
Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned, it looks like fillrule and strokewidth aren't allowed. The plugin's preprocessor removes them, so the page is still valid AMP. But just so we're aware that they're not appearing on the front-end.

if ( post_password_required() ) {
return;
}

Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outside this PR's diff, but could you please add 'comments' to the 'adventure' CPT 'supports' argument? I think this is blocking the "Popular Adventures" block from displaying, as you can't add ratings (comments) to the 'adventure' post type.

<option value="">--</option>';

for ( $i = 5; $i >= 1; $i-- ) {
echo '<option value="' . esc_attr( $i ) . '">' . sprintf( '%d star(s)', esc_attr( $i ) ) . '</option>';
Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. What do you think of this small change to separate the singular and plural?

Instead of

'%d star(s)'

how about:

_n( '%d star', '%d stars', $i, 'travel' )


<div class="product-cta lg-col-2 lg-right-align">
<h4 class="product-cta-title mb2 line-height-1" [text]="'$' + adventure_current_price">$<?php echo esc_html( get_post_meta( get_the_ID(), 'amp_travel_price', true ) ); ?></h4>
<select class="select-arr mb1 rounded" name="count" on="change:AMP.setState({ adventure_current_price: event.value * adventure_price })">
Copy link
Contributor

@kienstra kienstra Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with updating the price based on the selection.

price-updates

@kienstra kienstra mentioned this pull request Apr 17, 2018
4 tasks
The develop branch deletes that file,
so having changes in that file in this PR
caused merge conflics.
Please do npm run build when checking this out.
@kienstra
Copy link
Contributor

kienstra commented Apr 18, 2018

Building editor-blocks.js

The develop branch removes editor-blocks.js, in order to avoid merge conflicts in PRs. So I also removed that file from this branch to remove the conflict to develop.

Please do npm run build when checking out this branch to use the Gutenberg blocks.

@mehigh
Copy link
Member Author

mehigh commented Apr 18, 2018

The html/css is complete for the page now:
laptop-view
phone-view


for ( $i = 5; $i >= 1; $i-- ) {
/* translators: %d: Rating */
echo '<option value="' . esc_attr( $i ) . '">' . sprintf( _n( '%d star', '%d stars', $i, 'travel' ), number_format_i18n( $i ) ) . '</option>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kienstra This line is now throwing CS error:
includes/functions.php:153:67: error - All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '_n'. (WordPress.XSS.EscapeOutput.OutputNotEscaped).

Any thoughts how to fix that?

Copy link
Contributor

@kienstra kienstra Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @miina, wrapping the _n() call in esc_html() should take care of that. Otherwise:

// WPCS: XSS ok.

@miina
Copy link
Contributor

miina commented Apr 18, 2018

@kienstra Thanks for reviewing, most of the issues should be addressed now. Left the gallery as static for now, hopefully that's OK for now and could be addressed later if needed. There's just one issue that I'm not sure how to fix, any thoughts?

@mehigh Thanks for generating the HTML!
There's one CSS issue that would be great if you could help with -- namely within the Similar Posts section there's a div with class travel-overflow-container. The CSS for the class in the adventure.css looks like this:

.travel-overflow-container {
    display: inline-block;
    min-width: 100vw;
    padding-left: calc((100vw - 72rem) / 2);
    padding-right: calc((100vw - 72rem) / 2);
}

However, with the AMP plugin on it looks like the padding gets stripped and only this is left:

.travel-overflow-container {
    display: inline-block;
    min-width: 100vw;
}

Would be great if you could help with that issue.

@kienstra kienstra self-assigned this Apr 18, 2018
@miina miina changed the title [WIP] 36 - Single product template 36 - Single product template Apr 18, 2018
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Hi @miina and @mehigh,
Thanks for your great work here. The single 'adventure' template looks good.

@kienstra kienstra merged commit 6848c6e into develop Apr 18, 2018
@kienstra kienstra deleted the feature/36-adventure-single branch April 18, 2018 14:19
@postphotos
Copy link

Making sure we capture - related to #36.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants