Skip to content

Commit

Permalink
🖍 Added shopping tag flip on too far position to the right (#37195)
Browse files Browse the repository at this point in the history
* added shopping tag flip on specific position

* removed a few console logs, added better code flow with less varaible names

* added calls to measure and mutate elemetn

* added rtl fix

* fixed a few typos

* added tag flip working for non rtl order

* rmeoved gitignore file

* added tag flip and onresize callback for tag flip, added helper function for tag flip

* added tag flip fix

* using page size to determine, might need to fix page size bug to not tuse the window of the whoel apge and intead use the window of the mobile regtangle  in a separate pr

* added refactor of measure element

* added getlyaoutbox

* added get layout box calculation adn page size

* added correct measurements for transforms, added correct placement for page_resize callback initilaization

* removed space

* removed trailing whitespace

* added proper rtl test

* fixed allto initialize and rtl visual diff test

* fixed store service page size dimensions for unit test

* fixed mutatelement for shopping tag flip

* migrated resize code to another PR

* fixed settings

* added space

* removed space

* added shopping tag position

* added iamphtml to classes

* added fix for double measure ele,metn callback

* added page 1 visual diff test

* added rtl to visual test file

* added RTL direction

* removed non rtl exampel form story

* removed trl exmaples

* removed trl exmaples

* removed non rtl exampel from story

* removed non rtl exampel from story

* added back in interactive tests

* added back in interactive tests

* added back in interactive tests

* added back in interactive tests

* added back in interactive tests
  • Loading branch information
jshamble committed Feb 2, 2022
1 parent 9486cdb commit 3c95f40
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 218 deletions.
70 changes: 4 additions & 66 deletions examples/amp-story/amp-story-shopping.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
<script async custom-element="amp-story-page-attachment" src="https://cdn.ampproject.org/v0/amp-story-page-attachment-0.1.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-product-id="lamp"],
[data-product-id="lamp-rtl"] {
[data-product-id="lamp"] {
top: 31%;
left: 1%;
}
[data-product-id="art"],
[data-product-id="art-rtl"] {
[data-product-id="art"] {
top: 15%;
left: 40%;
}
[data-product-id="chair"],
[data-product-id="chair-rtl"] {
[data-product-id="chair"] {
top: 53%;
left: 30%;
}
[data-product-id="flowers"],
[data-product-id="flowers-rtl"] {
[data-product-id="flowers"] {
top: 46%;
left: 83%;
}
Expand Down Expand Up @@ -145,64 +141,6 @@
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-light-theme-two" dir="rtl">
<!--
RTL example
-->
<amp-story-shopping-config layout="nodisplay">
<script type="application/json">
{
"items" : [
{
"productId": "lamp-rtl",
"productTitle": "Brass Lamp",
"productBrand": "Lamp Co",
"productPrice": 799.00,
"productPriceCurrency": "AED",
"productTagText": " حبا حبا حبا سعادةا سعادة",
"productImages": ["https://source.unsplash.com/Ry9WBo3qmoc/500x500"]
},
{
"productId": "art-rtl",
"productTitle": "Abstract Art",
"productBrand": "V. Artsy",
"productPriceCurrency": "AED",
"productPrice": 1200.00,
"productTagText": "حبا حب سعادة قط حبا حب سعادة قط ",
"productImages": ["https://source.unsplash.com/BdVQU-NDtA8/500x500"]
},
{
"productId": "chair-rtl",
"productTitle": "Yellow chair",
"productBrand": "Chair Co.",
"productPrice": 1000.00,
"productPriceCurrency": "AED",
"productImages": ["https://source.unsplash.com/DgQGKKLaVhY/500x500"]
},
{
"productId": "flowers-rtl",
"productTitle": "Flowers",
"productBrand": "Very Long Flower Company Name",
"productPrice": 10.00,
"productPriceCurrency": "AED",
"productIcon": "/examples/visual-tests/amp-story/img/shopping/icon.png",
"productImages": ["https://source.unsplash.com/SavQfLRm4Do/500x500"]
}
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-product-id="lamp-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="art-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="chair-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="flowers-rtl" ></amp-story-shopping-tag>
</amp-story-grid-layer>
<amp-story-shopping-attachment></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-no-product">
<!--
Example of:
Expand Down
71 changes: 4 additions & 67 deletions examples/visual-tests/amp-story/amp-story-shopping-lang-de.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@
<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-product-id="lamp"],
[data-product-id="lamp-rtl"] {
[data-product-id="lamp"] {
top: 31%;
left: 1%;
}
[data-product-id="art"],
[data-product-id="art-rtl"] {
[data-product-id="art"] {
top: 15%;
left: 40%;
}
[data-product-id="chair"],
[data-product-id="chair-rtl"] {
[data-product-id="chair"] {
top: 53%;
left: 30%;
}
[data-product-id="flowers"],
[data-product-id="flowers-rtl"] {
[data-product-id="flowers"] {
top: 46%;
left: 83%;
}
Expand Down Expand Up @@ -146,65 +142,6 @@
</amp-story-grid-layer>
<amp-story-shopping-attachment theme="dark"></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-light-theme-two" dir="rtl">
<!--
RTL example
-->
<amp-story-shopping-config layout="nodisplay">
<script type="application/json">
{
"items" : [
{
"productId": "lamp-rtl",
"productTitle": "Brass Lamp",
"productBrand": "Lamp Co",
"productPrice": 799.00,
"productPriceCurrency": "AED",
"productTagText": " حبا حبا حبا سعادةا سعادة",
"productImages": ["https://source.unsplash.com/Ry9WBo3qmoc/500x500"]
},
{
"productId": "art-rtl",
"productTitle": "Abstract Art",
"productBrand": "V. Artsy",
"productPriceCurrency": "AED",
"productPrice": 1200.00,
"productTagText": "حبا حب سعادة قط حبا حب سعادة قط ",
"productImages": ["https://source.unsplash.com/BdVQU-NDtA8/500x500"]
},
{
"productId": "chair-rtl",
"productTitle": "Yellow chair",
"productBrand": "Chair Co.",
"productPrice": 1000.00,
"productPriceCurrency": "AED",
"productIcon": "/examples/visual-tests/amp-story/img/shopping/nest-home-icon.png",
"productImages": ["https://source.unsplash.com/DgQGKKLaVhY/500x500"]
},
{
"productId": "flowers-rtl",
"productTitle": "Flowers",
"productBrand": "Very Long Flower Company Name",
"productPrice": 10.00,
"productPriceCurrency": "AED",
"productIcon": "/examples/visual-tests/amp-story/img/shopping/icon.png",
"productImages": ["https://source.unsplash.com/SavQfLRm4Do/500x500"]
}
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-product-id="lamp-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="art-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="chair-rtl" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="flowers-rtl" ></amp-story-shopping-tag>
</amp-story-grid-layer>
<amp-story-shopping-attachment></amp-story-shopping-attachment>
</amp-story-page>
<amp-story-page id="inline-no-product">
<!--
Example of:
Expand Down
163 changes: 163 additions & 0 deletions examples/visual-tests/amp-story/amp-story-shopping-rtl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<!doctype html>
<html amp lang="en" dir="rtl">
<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-product-id="lamp"] {
top: 31%;
left: 1%;
}
[data-product-id="art"] {
top: 15%;
left: 40%;
}
[data-product-id="chair"] {
top: 53%;
left: 30%;
}
[data-product-id="flowers"] {
top: 46%;
left: 83%;
}
</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" : [
{
"productId": "lamp",
"productTitle": "Brass Lamp",
"productBrand": "Lamp Co",
"productPrice": 799.00,
"productPriceCurrency": "USD",
"productImages": ["https://source.unsplash.com/Ry9WBo3qmoc/500x500"]
},
{
"productId": "art",
"productTitle": "Abstract Art",
"productBrand": "V. Artsy",
"productPrice": 1200.00,
"productPriceCurrency": "INR",
"productImages": ["https://source.unsplash.com/BdVQU-NDtA8/500x500"]
},
{
"productId": "chair",
"productTitle": "Yellow chair",
"productBrand": "Chair Co.",
"productPrice": 1000.00,
"productPriceCurrency": "BRL",
"productTagText": "The perfectly imperfect yellow chair",
"productImages": ["https://source.unsplash.com/DgQGKKLaVhY/500x500"]
},
{
"productId": "flowers",
"productTitle": "Flowers",
"productBrand": "Very Long Flower Company Name",
"productPrice": 10.00,
"productPriceCurrency": "USD",
"productIcon": "/examples/visual-tests/amp-story/img/shopping/icon.png",
"productImages": ["https://source.unsplash.com/SavQfLRm4Do/500x500"]
}
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">
<amp-img layout="fill" src="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-product-id="lamp" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="art" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="chair" ></amp-story-shopping-tag>
<amp-story-shopping-tag data-product-id="flowers" ></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" : [
{
"productId": "art",
"productTitle": "Abstract Art",
"productBrand": "V. Artsy",
"productPrice": 1200.00,
"productPriceCurrency": "JPY",
"productImages": ["https://source.unsplash.com/BdVQU-NDtA8/500x500"]
},
]
}
</script>
</amp-story-shopping-config>
<amp-story-grid-layer template="fill">

<amp-img layout="fill" src="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-product-id="art" ></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="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="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer template="vertical">
<amp-story-shopping-tag data-product-id="art" ></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="https://source.unsplash.com/_HqHX3LBN18/1000x2000"></amp-img>
</amp-story-grid-layer>
<amp-story-shopping-attachment></amp-story-shopping-attachment>
</amp-story-page>
</amp-story>
</body>
</html>

0 comments on commit 3c95f40

Please sign in to comment.