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

amp-bind: Improve e-commerce example #8924

Merged
merged 7 commits into from Apr 26, 2017

Conversation

dreamofabear
Copy link

In preparation for related code lab:

  • Adds carousel slide indicator, color swatches, default var values, variable prices based on SKU, size and quantity selection and buttons, and inlines CSS.

/to @kmh287

}
</style>
</head>

<body>
<button onclick="AMP.toggleExperiment('amp-bind');window.location.href=window.location.href;">Toggle &lt;amp-bind&gt; experiment</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we keep the experiment toggles in for now?

Copy link
Author

Choose a reason for hiding this comment

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

Really there just for convenience, but onclick is not a valid AMP attribute. We can still use AMP.toggleExperiment in dev console.

<script type="application/json">
{
"0": {
"color": "black",
"image": "./shirts/black.jpg"
"image": "./shirts/black.jpg",
"sizes": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe be a little more explicit in the comments above about why '0' has sizes but the others don't?

Copy link
Author

Choose a reason for hiding this comment

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

Good idea, done. I'll also spell this out more explicitly in the code lab.

<amp-img width=200 height=250 src="./shirts/black.jpg" [src]="shirts[selected.id].image"></amp-img>
</amp-carousel>

<p class="dots">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make these clickable to move around the carousel?

Copy link
Author

Choose a reason for hiding this comment

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

Good idea! Done.

</div>

<div class="options price">
<h6>PRICE : <span [text]="shirts[selected.id].sizes[selectedSize] || '---'">---</span></h6>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to be a heading?

Copy link
Author

Choose a reason for hiding this comment

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

Subheading? 🤷‍♂️

</button>
<button class="mdl-button mdl-button--raised hidden"
[class]="'mdl-button mdl-button--raised ' +
((!selectedSize || !shirts[selected.id].sizes || shirts[selected.id].sizes[selectedSize]) ? 'hidden' : '')">
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment as to when this button is supposed to be shown vs hidden?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, done.

@@ -146,6 +150,9 @@
- Reintroduce variables in object keys (removed in #7582)

<amp-state [src]="..." on="fetch:AMP.setState({"shirts": {selected: {id: event.response}}})"

Note that shirt with ID == "0" contains size data (but other IDs don't)
because it's the default shirt color at page load.
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: Add "Size data for the remaining indices will be downloaded via XHR when their corresponding options are selected." or something like that.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@dreamofabear dreamofabear merged commit 1a60fb2 into ampproject:master Apr 26, 2017
@dreamofabear dreamofabear deleted the ecommerce-codelab branch April 26, 2017 16:56
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* first pass on prettifying ecommerce sample

* more progress on ecommerce sample

* add more sizes

* inline material design lite css

* fix initial value issues

* kevin's comments

* elaborate comment
KenneyE pushed a commit to spotxchange/amphtml that referenced this pull request May 3, 2017
* first pass on prettifying ecommerce sample

* more progress on ecommerce sample

* add more sizes

* inline material design lite css

* fix initial value issues

* kevin's comments

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

Successfully merging this pull request may close these issues.

None yet

3 participants