Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Rename. Do not render CTA.
  • Loading branch information
processprocess committed Jan 28, 2022
commit 2031460dedab1f17b5a557ff2b3da55b639b01ff
22 changes: 8 additions & 14 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Preact from '#core/dom/jsx';
import {Layout_Enum} from '#core/dom/layout';
import {closest} from '#core/dom/query';

import {Services} from '#service';
import {LocalizedStringId_Enum} from '#service/localization/strings';
Expand Down Expand Up @@ -33,27 +34,20 @@ export class AmpStoryShoppingAttachment extends AMP.BaseElement {
/** @private {?Element} */
this.attachmentEl_ = null;

/** @private {!Element} */
this.pageEl_ = this.element.closest('amp-story-page');

/** @private {!Array<!Element>} */
this.shoppingTags_ = Array.from(
this.pageEl_.querySelectorAll('amp-story-shopping-tag')
closest(
element,
(el) => el.tagName === 'AMP-STORY-PAGE'
).querySelectorAll('amp-story-shopping-tag')
);

/** @private @const {!Element} */
this.plpContainer_ = <div></div>;

/** @private {?../../amp-story/1.0/amp-story-store-service.AmpStoryStoreService} */
this.storeService_ = null;

/** @private {?../../../src/service/localization.LocalizationService} */
this.localizationService_ = null;
}

/** @override */
buildCallback() {
loadFonts(this.win, FONTS_TO_LOAD);
if (this.shoppingTags_.length === 0) {
Comment thread
processprocess marked this conversation as resolved.
return;
}
this.attachmentEl_ = (
<amp-story-page-attachment
layout="nodisplay"
Expand Down
13 changes: 4 additions & 9 deletions extensions/amp-story/1.0/amp-story-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export class AmpStoryPage extends AMP.BaseElement {

this.muteAllMedia();

this.renderOpenAttachmentUI_();
this.installPageAttachmentExtension_();

return Promise.all([
this.waitForMediaLayout_().then(() => this.markPageAsLoaded_()),
Expand Down Expand Up @@ -1523,21 +1523,16 @@ export class AmpStoryPage extends AMP.BaseElement {
}

/**
* Renders the open attachment UI affordance.
* Installs the page attachment extension.
* @private
*/
renderOpenAttachmentUI_() {
installPageAttachmentExtension_() {
// AttachmentEl can be any component that extends draggable drawer.
const attachmentEl = this.element.querySelector(
'amp-story-page-attachment, amp-story-page-outlink, amp-story-shopping-attachment'
);

if (
!attachmentEl ||
(attachmentEl.tagName === 'AMP-STORY-SHOPPING-ATTACHMENT' &&
this.element.getElementsByTagName('amp-story-shopping-tag').length ===
0)
) {
if (!attachmentEl) {
return;
}

Expand Down