From 8039e4e55a25a5206c0dd08c1f8797e7f2591c9f Mon Sep 17 00:00:00 2001 From: processprocess Date: Mon, 3 May 2021 09:46:04 -0400 Subject: [PATCH 1/3] Validator, component and template. --- examples/amp-story/attachment.html | 32 ++++++------- extensions/amp-story/1.0/amp-story-page.js | 7 +-- extensions/amp-story/1.0/amp-story.js | 1 + .../amp-story/validator-amp-story.protoascii | 45 +++++++++++++++++++ 4 files changed, 66 insertions(+), 19 deletions(-) diff --git a/examples/amp-story/attachment.html b/examples/amp-story/attachment.html index 39766d1c68d4e..7f6841a4f3852 100644 --- a/examples/amp-story/attachment.html +++ b/examples/amp-story/attachment.html @@ -169,11 +169,11 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - + @@ -186,13 +186,13 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -205,12 +205,12 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -223,12 +223,12 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -241,14 +241,14 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -261,14 +261,14 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -281,14 +281,14 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
@@ -301,14 +301,14 @@ Enable experiment by pasting AMP.toggleExperiment('amp-story-page-attachment-ui-v2', true) in console and refreshing.

- - +
diff --git a/extensions/amp-story/1.0/amp-story-page.js b/extensions/amp-story/1.0/amp-story-page.js index c4134eb8a9d52..aa33e337c9ad1 100644 --- a/extensions/amp-story/1.0/amp-story-page.js +++ b/extensions/amp-story/1.0/amp-story-page.js @@ -1737,9 +1737,10 @@ export class AmpStoryPage extends AMP.BaseElement { * @private */ renderOpenAttachmentUI_() { - const attachmentEl = this.element.querySelector( - 'amp-story-page-attachment' - ); + // AttachmentEl can be either amp-story-page-attachment or amp-story-page-outlink + const attachmentEl = this.element.querySelectorAll( + 'amp-story-page-attachment, amp-story-page-outlink' + )[0]; if (!attachmentEl) { return; } diff --git a/extensions/amp-story/1.0/amp-story.js b/extensions/amp-story/1.0/amp-story.js index afd0104dfbab4..14fa3abe5a83b 100644 --- a/extensions/amp-story/1.0/amp-story.js +++ b/extensions/amp-story/1.0/amp-story.js @@ -2985,5 +2985,6 @@ AMP.extension('amp-story', '1.0', (AMP) => { AMP.registerElement('amp-story-grid-layer', AmpStoryGridLayer); AMP.registerElement('amp-story-page', AmpStoryPage); AMP.registerElement('amp-story-page-attachment', AmpStoryPageAttachment); + AMP.registerElement('amp-story-page-outlink', AmpStoryPageAttachment); AMP.registerServiceForDoc('amp-story-render', AmpStoryRenderService); }); diff --git a/extensions/amp-story/validator-amp-story.protoascii b/extensions/amp-story/validator-amp-story.protoascii index c5e96bc68ace4..bb162e011ec45 100644 --- a/extensions/amp-story/validator-amp-story.protoascii +++ b/extensions/amp-story/validator-amp-story.protoascii @@ -921,6 +921,51 @@ tags: { # with no href value: "light" } } +tags: { # Same code as ` with href` + html_format: AMP + tag_name: "AMP-STORY-PAGE-OUTLINK" + spec_name: "amp-story-page-outlink" + mandatory_ancestor: "AMP-STORY-PAGE" + mandatory_last_child: true + attrs: { + name: "layout" + mandatory: true + value: "nodisplay" + } + attrs: { + name: "theme" + value: "custom" + value: "dark" + value: "light" + } + attrs: { + name: "cta-accent-color" + } + attrs: { + name: "cta-accent-element" + value: "background" + value: "text" + } + attrs: { + name: "href" + mandatory: true + value_url: { + protocol: "http" + protocol: "https" + } + } + attrs: { + name: "cta-image" + value_url: { + # protocol: "http" # TODO(honeybaderdontcare): readd once transformers in prod + protocol: "https" + allow_relative: false # TODO(honeybaderdontcare): remove once transformers in prod + } + } + child_tags: { + mandatory_num_child_tags: 0 + } +} tags: { #