Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructured to be closer to HTML partials version. #896

Open
wants to merge 2 commits into
base: ampstart-2.0
Choose a base branch
from

Conversation

alankent
Copy link
Collaborator

This PR is not intended to be merged.

This still has lots of data-amp-bind-* in it, without loading up AmpBind. But it shows progress of renaming all the components to align with the HTML partials version.

It also moves all the AMP State variables from global state to a single nested group. This is not the final version - it should have multiple global namespaces (not one per variable, not one for everything).

@sebastianbenz

Copy link
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

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

I think it's already much better. Left a few comments.

<div className='overflow-scroll'>
<div className='travel-overflow-container'>
<div className='flex justify-center p1 md-px1 mxn1'>
{[
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: extract the list into a variable

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems also to duplicate TravelData

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some I converted from result of converter and then reverse engineered the source template. Next one I think should port the Mustache files rather than the output of the conversion. There are few like this around the place I have not done yet.

@@ -0,0 +1,202 @@
export default function TravelData() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels very hard to read and it also seems to mix different kinds of data (domain and presentational data). I think it'd be better to split this up into multiple files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was copied out of the original template - I have not got to the bottom of the two sets of data - feels like some overlap there as well. Let's work out what we want as components to be listed separately - that might also help clean all this up as well.

'head-tag': {
title: 'Travel Template',
'canonical-path': 'templates/travel/travel.amp',
extensions: ['amp-list', 'amp-bind'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is no longer needed

},
'head-tag': {
title: 'Travel Template',
'canonical-path': 'templates/travel/travel.amp',
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't needed either

@@ -0,0 +1,146 @@
export default function TravelResultsData() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

general question: do we want to shorten default exports to export default () => { ... }?

export default function AmpListProps(includeDates) {
return {
src:
'/api/search?maxPrice=0' +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use URL and URL.searchParams to create the string instead. It's much more readable.

@@ -0,0 +1,16 @@
export default function AmpListProps(includeDates) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe find a better name for this function / file. It's not a util.

* @param {Object} res - The HTTP response object.
* @param {Function} next - The next HTTP handler to execute.
*/
function cors(req, res, next) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use @ampproject/toolbox-cors instead.

<AmpState id='fields_maxPrice_edited'>{false}</AmpState>
<AmpState id='query_maxPrice'>{801}</AmpState>
</div>
<AmpState id='display'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not a fan of namespacing via name as it results in unnecessary redundancy. Instead I'd prefer:

<AmpState id="ui">{{
   hero: true,
   reset: false,
  ...
}}<AmpState/>

<link rel="stylesheet" type="text/css" href="/css/travel-results.css" />
</Head>

<AmpState id="display">
Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels redundant

@CLAassistant
Copy link

CLAassistant commented Oct 8, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Alan Kent
❌ alankent


Alan Kent seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

3 participants