Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
eccc65a
added shopping tag flip on specific position
jshamble Dec 13, 2021
9e8731a
removed a few console logs, added better code flow with less varaible…
jshamble Dec 13, 2021
5a17827
added calls to measure and mutate elemetn
jshamble Dec 14, 2021
dfac763
resolved merge conflict
jshamble Jan 7, 2022
2e2c0b7
added rtl fix
jshamble Jan 7, 2022
ae7caf2
fixed a few typos
jshamble Jan 7, 2022
0655d49
Merge branch 'main' into shoptagposition
jshamble Jan 12, 2022
0426ef9
added tag flip working for non rtl order
jshamble Jan 13, 2022
e2da174
rmeoved gitignore file
jshamble Jan 14, 2022
c622b38
added tag flip and onresize callback for tag flip, added helper funct…
jshamble Jan 14, 2022
128c4d0
added tag flip fix
jshamble Jan 14, 2022
f426d8c
using page size to determine, might need to fix page size bug to not …
jshamble Jan 18, 2022
ee3c407
Merge branch 'main' into shoptagposition
jshamble Jan 18, 2022
b32d1f0
added refactor of measure element
jshamble Jan 19, 2022
ba110ee
added getlyaoutbox
jshamble Jan 19, 2022
828b623
added get layout box calculation adn page size
jshamble Jan 19, 2022
3bb9156
fixed merge conflicts
jshamble Jan 20, 2022
86aeb86
Merge branch 'main' into shoptagposition
jshamble Jan 21, 2022
bc89057
added correct measurements for transforms, added correct placement fo…
jshamble Jan 24, 2022
ed6af3c
removed space
jshamble Jan 24, 2022
6f48eab
added main files
jshamble Jan 25, 2022
2d9a3d1
removed trailing whitespace
jshamble Jan 25, 2022
4d67d41
added proper rtl test
jshamble Jan 27, 2022
de65f8b
fixed allto initialize and rtl visual diff test
jshamble Jan 27, 2022
45da724
fixed store service page size dimensions for unit test
jshamble Jan 27, 2022
5762255
fixed mutatelement for shopping tag flip
jshamble Jan 27, 2022
7354224
migrated resize code to another PR
jshamble Jan 29, 2022
878bf67
resolved mrege conflicts
jshamble Jan 29, 2022
b3b6570
Merge branch 'main' into shoptagposition
jshamble Jan 31, 2022
85acd92
fixed settings
jshamble Jan 31, 2022
a604cfa
added space
jshamble Jan 31, 2022
d9d801a
removed space
jshamble Jan 31, 2022
b8158e1
fixed merge conflict
jshamble Feb 1, 2022
46ab9b8
added shopping tag position
jshamble Feb 1, 2022
20e168a
added iamphtml to classes
jshamble Feb 1, 2022
b45a992
added fix for double measure ele,metn callback
jshamble Feb 1, 2022
3a6e823
Merge branch 'main' into shoptagposition
jshamble Feb 1, 2022
1f8711c
Merge branch 'main' into shoptagposition
jshamble Feb 1, 2022
a2c35d7
added page 1 visual diff test
jshamble Feb 2, 2022
3877e03
added rtl to visual test file
jshamble Feb 2, 2022
3193a15
added RTL direction
jshamble Feb 2, 2022
609cec8
removed non rtl exampel form story
jshamble Feb 2, 2022
6c4997c
removed trl exmaples
jshamble Feb 2, 2022
9ad13f5
removed trl exmaples
jshamble Feb 2, 2022
599cc42
removed non rtl exampel from story
jshamble Feb 2, 2022
02dd8da
removed non rtl exampel from story
jshamble Feb 2, 2022
69b204b
added back in interactive tests
jshamble Feb 2, 2022
98a2809
added back in interactive tests
jshamble Feb 2, 2022
fd3cc81
added back in interactive tests
jshamble Feb 2, 2022
fced266
added back in interactive tests
jshamble Feb 2, 2022
b2e6548
added back in interactive tests
jshamble Feb 2, 2022
6a58fcd
resolved merge conflict
jshamble Feb 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
jshamble committed Jan 18, 2022
commit f426d8cfeb3f7093407a5a69e0d7c3ec6f6252a7
27 changes: 15 additions & 12 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-tag.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ amp-story-shopping-tag {
--i-amphtml-shopping-tag-backdrop-filter: blur(20px);
}

.amp-story-shopping-product-tag-text {
.i-amphtml-amp-story-shopping-product-tag-text {
font-weight: 600 !important;
font-size: 11px !important;
line-height: 15.4px !important;
Expand All @@ -23,15 +23,15 @@ amp-story-shopping-tag {
}

/* Maintains the dot position in RTL mode */
[dir=rtl].amp-story-shopping-tag-inner {
[dir=rtl].i-amphtml-amp-story-shopping-tag-inner {
flex-flow: row-reverse !important;
}

[dir=rtl] .amp-story-shopping-tag-dot {
[dir=rtl] .i-amphtml-amp-story-shopping-tag-dot {
margin-inline-start: 4px !important;
}

.amp-story-shopping-tag-inner {
.i-amphtml-amp-story-shopping-tag-inner {
height: 36px !important;
display: flex !important;
align-items: center !important;
Expand All @@ -40,17 +40,21 @@ amp-story-shopping-tag {
opacity: 0 !important;
}

.amp-story-shopping-tag-visible {
.i-amphtml-amp-story-shopping-tag-visible {
opacity: 1 !important;
}

.amp-story-shopping-tag-inner-flipped {
.i-amphtml-amp-story-shopping-tag-inner-flipped {
flex-direction: row-reverse !important;
transform: translate(-80%) !important;
margin-inline-start: 4px !important;
}

.amp-story-shopping-tag-dot {
.i-amphtml-amp-story-shopping-tag-dot-flipped {
margin-inline-start: 4px !important;
}

.i-amphtml-amp-story-shopping-tag-dot {
width: 16px !important;
height: 16px !important;
border-radius: 100% !important;
Expand All @@ -62,10 +66,9 @@ amp-story-shopping-tag {
margin-inline-end: 4px !important;
flex-shrink: 0 !important;
backdrop-filter: var(--i-amphtml-shopping-tag-backdrop-filter) !important;

}

.amp-story-shopping-tag-dot:before {
.i-amphtml-amp-story-shopping-tag-dot:before {
border-radius: 100% !important;
content: '' !important;
width: 8px !important;
Expand All @@ -74,7 +77,7 @@ amp-story-shopping-tag {
box-shadow: 0px 2px 8px var(--i-amphtml-shopping-tag-bg-color) !important;
}

.amp-story-shopping-tag-pill {
.i-amphtml-amp-story-shopping-tag-pill {
display: flex !important;
align-items: center !important;
border-radius: 18px !important;
Expand All @@ -84,7 +87,7 @@ amp-story-shopping-tag {
backdrop-filter: var(--i-amphtml-shopping-tag-backdrop-filter) !important;
}

.amp-story-shopping-tag-pill-image {
.i-amphtml-amp-story-shopping-tag-pill-image {
width: 24px !important;
height: 24px !important;
display: flex !important;
Expand All @@ -98,7 +101,7 @@ amp-story-shopping-tag {
background-position: center !important;
}

.amp-story-shopping-tag-pill-text {
.i-amphtml-amp-story-shopping-tag-pill-text {
font-size: 14px !important;
padding: 0 6px 0 4px !important;
}
64 changes: 34 additions & 30 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,48 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
this.onRtlStateUpdate_(rtlState);
});

this.storeService_.subscribe(StateProperty.PAGE_SIZE, () => {
this.onPageSizeStateUpdate_();
this.storeService_.subscribe(StateProperty.PAGE_SIZE, (pageSizeState) => {
this.shouldTagFlip_(pageSizeState);
Comment thread
jshamble marked this conversation as resolved.
Outdated
});
}

/**
* Helper function to check if the shopping tag should flip if it's too far to the right.
* @param {!Object} pageSize
* @private
*/
shoudTagFlip_() {
const {offsetLeft, offsetWidth} = this.element;
shouldTagFlip_(pageSize) {
this.measureElement(() => {
/* We only check the right hand side, as resizing only expands the border to the right. */
const {offsetLeft, offsetWidth} = this.element;

const storyPageWidth =
this.element.closest('amp-story-page')./*OK*/ offsetWidth;
const shouldFlip = offsetLeft + offsetWidth > storyPageWidth;
const storyPageWidth = pageSize.width;

this.shoppingTagEl_.classList.toggle(
'amp-story-shopping-tag-inner-flipped',
shouldFlip
);
const shouldFlip = offsetLeft + offsetWidth > storyPageWidth;

this.shoppingTagEl_.classList.toggle(
'amp-story-shopping-tag-visible',
true
);
this.mutateElement(() => {
Comment thread
jshamble marked this conversation as resolved.
Outdated
this.shoppingTagEl_.classList.toggle(
'i-amphtml-amp-story-shopping-tag-inner-flipped',
shouldFlip
);

const dotEl = this.shoppingTagEl_.querySelector(
'.i-amphtml-amp-story-shopping-tag-dot'
);

dotEl.classList.toggle(
'i-amphtml-amp-story-shopping-tag-dot-flipped',
shouldFlip
);

this.shoppingTagEl_.classList.toggle(
Comment thread
jshamble marked this conversation as resolved.
'i-amphtml-amp-story-shopping-tag-visible',
true
);
});
});
}

/**
* Reacts to PageSize state updates and triggers the UI for PageSize.
* @private
*/
onPageSizeStateUpdate_() {
this.shoudTagFlip_();
}

/**
* Reacts to RTL state updates and triggers the UI for RTL.
* @param {boolean} rtlState
Expand Down Expand Up @@ -140,14 +144,14 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
renderShoppingTagTemplate_() {
return (
<div
class="amp-story-shopping-tag-inner"
class="i-amphtml-amp-story-shopping-tag-inner"
role="button"
onClick={() => this.onClick_()}
>
<span class="amp-story-shopping-tag-dot"></span>
<span class="amp-story-shopping-tag-pill">
<span class="i-amphtml-amp-story-shopping-tag-dot"></span>
<span class="i-amphtml-amp-story-shopping-tag-pill">
<span
class="amp-story-shopping-tag-pill-image"
class="i-amphtml-amp-story-shopping-tag-pill-image"
style={
this.tagData_['product-icon'] && {
backgroundImage:
Expand All @@ -156,9 +160,9 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
}
}
></span>
<span class="amp-story-shopping-tag-pill-text">
<span class="i-amphtml-amp-story-shopping-tag-pill-text">
{(this.tagData_['product-tag-text'] && (
<span class="amp-story-shopping-product-tag-text">
<span class="i-amphtml-amp-story-shopping-product-tag-text">
{this.tagData_['product-tag-text']}
</span>
)) ||
Expand Down Expand Up @@ -198,7 +202,7 @@ export class AmpStoryShoppingTag extends AMP.BaseElement {
);
this.hasAppendedInnerShoppingTagEl_ = true;

this.shoudTagFlip_();
this.shouldTagFlip_(this.storeService_.get(StateProperty.PAGE_SIZE));
});
}

Expand Down