Skip to content

Commit

Permalink
✨ amp-story-shopping Updated currency with product price and correct …
Browse files Browse the repository at this point in the history
…Localized currency (#37249)

* updated PR with localization service that fetches the correct lanaguage ISO code, updated the visual diff test

* fixed a few typos

* added dependency

* added ecimal exmaples

* added localization langauge code

* added in i18n visual diff test, changen strings to numbers

* deleted duplicate test

* deleted duplicate test

* removed shopping tag span - will meo it to another PR when ready

* added correct types for parameters

* udpated price in visual diff test

* udtaed unit test

* updated product price

* added localization service stub to unit tests

* added localization service variable

* removed unused allowlist entry

* created a class method, followed pattern

* added back code

* added back code

* added onclick fix

* removed tag data from onclcik method

* removed duplicate page id
  • Loading branch information
jshamble authored Jan 5, 2022
1 parent 098ed12 commit 09cb7c2
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 57 deletions.
14 changes: 9 additions & 5 deletions examples/amp-story/amp-story-shopping.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@
{
"product-tag-id": "hat",
"product-title": "Hootenanny Hat",
"product-price": "799",
"product-price": "799.00",
"product-price-currency": "USD",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-mini-icon.png"
},
{
"product-tag-id": "sunglasses",
"product-title": "Spectacular Spectacles",
"product-price": "400",
"product-price": "400.00",
"product-price-currency": "INR",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-audio-icon.png"
},
{
"product-tag-id": "backpack",
"product-title": "Beastly Backpack",
"product-price": "1000",
"product-price": "1000.00",
"product-price-currency": "BRL",
"product-tag-text": "Beastly Backpack",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-home-icon.png"
}
Expand Down Expand Up @@ -102,7 +105,8 @@
{
"product-tag-id": "city-pop",
"product-title": "Plastic Love",
"product-price": "19"
"product-price": "19",
"product-price-currency": "JPY"
}
]
}
Expand Down Expand Up @@ -155,7 +159,7 @@
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-light-theme" dir="rtl">
<amp-story-page id="inline-light-theme-two" dir="rtl">
<!--
RTL example
-->
Expand Down
3 changes: 2 additions & 1 deletion examples/amp-story/shopping/remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"product-tag-id": "city-pop",
"product-title": "Plastic Love",
"product-price": "19"
"product-price": 19,
"product-price-currency": "JPY"
}
]
}
165 changes: 165 additions & 0 deletions examples/visual-tests/amp-story/amp-story-shopping-lang-de.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<!doctype html>
<!-- This tests the internationalization number formatting for the German Euro (the positioning of commas and decimal points), see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat for more info -->
<html amp lang="de">
<head>
<meta charset="utf-8">
<title>Shopping</title>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-story" src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
<script async custom-element="amp-story-shopping" src="https://cdn.ampproject.org/v0/amp-story-shopping-0.1.js"></script>
<style amp-custom>
[data-tag-id="hat"] {
top: 33%;
left: 7%;
}
[data-tag-id="sunglasses"] {
top: 28%;
left: 43%;
}
[data-tag-id="backpack"] {
top: 33%;
left: 80%;
}
[data-tag-id=city-pop] {
top: 33%;
left: 7%;
}
[data-tag-id=euro-dance] {
top: 43%;
left: 57%;
}
</style>
</head>
<body>
<amp-story
standalone
title="Story Shopping Component"
publisher="AMP Story Shopping"
publisher-logo-src="example.com/logo.png"
poster-portrait-src="example.com/poster.jpg">
<amp-story-page id="inline-light-theme">
<!--
Example of
Inline config.
Multiple product tags with icon defined.
-->
<amp-story-shopping-config layout="nodisplay">
<script type="application/json">
{
"items" : [
{
"product-tag-id": "hat",
"product-title": "Hootenanny Hat",
"product-price": 123456.789,
"product-price-currency": "USD",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-mini-icon.png"
},
{
"product-tag-id": "sunglasses",
"product-title": "Spectacular Spectacles",
"product-price": 123456.789,
"product-price-currency": "INR",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-audio-icon.png"
},
{
"product-tag-id": "backpack",
"product-title": "Beastly Backpack",
"product-price": 123456.789,
"product-price-currency": "BRL",
"product-tag-text": "Beastly Backpack",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-home-icon.png"
},
{
"product-tag-id": "euro-dance",
"product-title": "Dolphin Dance",
"product-price": 123456.789,
"product-price-currency": "EUR"
}
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="/examples/visual-tests/amp-story/img/shopping/bg.png"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-tag-id="hat" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-tag-id="sunglasses" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-tag-id="backpack" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-tag-id="euro-dance" ></amp-story-shopping-tag>
</amp-story-grid-layer>
<amp-story-shopping-attachment></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="remote-dark-theme">
<!--
Example of:
Remote JSON with inline fallback.
Single product tag without icon.
-->
<amp-story-shopping-config layout="nodisplay" src="/examples/amp-story/shopping/remote.json" >
<script type="application/json">
{
"items" : [
{
"product-tag-id": "city-pop",
"product-title": "Plastic Love",
"product-price": 19,
"product-price-currency": "JPY",
}
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="/examples/visual-tests/amp-story/img/shopping/bg.png"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-tag-id="city-pop" ></amp-story-shopping-tag>
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-no-product">
<!--
Example of:
CTA Button not rendering due to no product tags.
-->
<amp-story-shopping-config layout="nodisplay">
<script type="application/json">
{
"items" : []
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="/examples/visual-tests/amp-story/img/shopping/bg.png"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
</amp-story-grid-layer>
<amp-story-shopping-attachment></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="remote-with-product">
<!--
Example of:
CTA Button rendering due to remote product tag existing, but no inline.
-->
<amp-story-shopping-config layout="nodisplay" src="/examples/amp-story/shopping/remote.json" >
<script type="application/json">
{
"items" : []
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="/examples/visual-tests/amp-story/img/shopping/bg.png"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-tag-id="city-pop" ></amp-story-shopping-tag>
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
</amp-story>
</body>
</html>
14 changes: 9 additions & 5 deletions examples/visual-tests/amp-story/amp-story-shopping.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@
{
"product-tag-id": "hat",
"product-title": "Hootenanny Hat",
"product-price": "799",
"product-price": 799.00,
"product-price-currency": "USD",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-mini-icon.png"
},
{
"product-tag-id": "sunglasses",
"product-title": "Spectacular Spectacles",
"product-price": "400",
"product-price": 400.00,
"product-price-currency": "INR",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-audio-icon.png"
},
{
"product-tag-id": "backpack",
"product-title": "Beastly Backpack",
"product-price": "1000",
"product-price": 1000.00,
"product-price-currency": "BRL",
"product-tag-text": "Beastly Backpack",
"product-icon": "/examples/visual-tests/amp-story/img/shopping/nest-home-icon.png"
}
Expand Down Expand Up @@ -102,7 +105,8 @@
{
"product-tag-id": "city-pop",
"product-title": "Plastic Love",
"product-price": "19"
"product-price": 19.00,
"product-price-currency": "JPY",
}
]
}
Expand Down Expand Up @@ -155,7 +159,7 @@
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-light-theme" dir="rtl">
<amp-story-page id="inline-light-theme-two" dir="rtl">
<!--
RTL example
-->
Expand Down
Loading

0 comments on commit 09cb7c2

Please sign in to comment.