Skip to content

Commit

Permalink
✨amp-inline-gallery docs and validation rules (#26708)
Browse files Browse the repository at this point in the history
- Add docs for amp-inline-gallery elements and linking to amp-base-carousel for its usage.
- Add validation rules for amp-inline-gallery elements.
- Fix selector for finding the amp-base-carousel, when it is a direct child of the amp-inline-gallery.
  • Loading branch information
alanorozco committed Feb 10, 2020
1 parent da1fb54 commit e3be1b2
Show file tree
Hide file tree
Showing 7 changed files with 688 additions and 1 deletion.
2 changes: 1 addition & 1 deletion extensions/amp-inline-gallery/0.1/amp-inline-gallery.js
Expand Up @@ -45,7 +45,7 @@ const THUMBNAILS_SELECTORS = 'amp-inline-gallery-thumbnails';
* The selector for the main carousel (i.e. not the one for the thumbnails).
*/
const CAROUSEL_SELECTOR =
':not(amp-inline-gallery-thumbnails) > amp-base-carousel';
'> amp-base-carousel, :not(amp-inline-gallery-thumbnails) > amp-base-carousel';

class AmpInlineGallery extends AMP.BaseElement {
/** @param {!AmpElement} element */
Expand Down
@@ -0,0 +1,57 @@
<!--
Copyright 2020 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the license.
-->
<!--
Test Description:
Tests for the amp-inline-gallery-pagination tag. See the inline comments.
-->
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<link rel="canonical" href="./regular-html-version.html">
<meta name="viewport" content="width=device-width,minimum-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-inline-gallery" src="https://cdn.ampproject.org/v0/amp-inline-gallery-0.1.js"></script>
</head>
<body>
<!-- Invalid: Not in a gallery -->
<amp-inline-gallery-pagination layout="fixed-height" height="24">
</amp-inline-gallery-pagination>
<!-- Invalid: Inset without nodisplay -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-pagination layout="fixed-height" height="24" inset>
</amp-inline-gallery-pagination>
</amp-inline-gallery>
<!-- Valid: Inset with nodisplay -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-pagination layout="nodisplay" inset>
</amp-inline-gallery-pagination>
</amp-inline-gallery>
<!-- Valid: Wrapped with a parent div -->
<amp-inline-gallery layout="container">
<div>
<amp-inline-gallery-pagination layout="nodisplay"inset>
</amp-inline-gallery-pagination>
</div>
</amp-inline-gallery>
<!-- Valid: Non-inset with fixed-height -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-pagination layout="fixed-height" height="24">
</amp-inline-gallery-pagination>
</amp-inline-gallery>
</body>
</html>
@@ -0,0 +1,62 @@
FAIL
| <!--
| Copyright 2020 The AMP HTML Authors. All Rights Reserved.
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS-IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the license.
| -->
| <!--
| Test Description:
| Tests for the amp-inline-gallery-pagination tag. See the inline comments.
| -->
| <!doctype html>
| <html ⚡>
| <head>
| <meta charset="utf-8">
| <link rel="canonical" href="./regular-html-version.html">
| <meta name="viewport" content="width=device-width,minimum-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-inline-gallery" src="https://cdn.ampproject.org/v0/amp-inline-gallery-0.1.js"></script>
| </head>
| <body>
| <!-- Invalid: Not in a gallery -->
| <amp-inline-gallery-pagination layout="fixed-height" height="24">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-pagination.html:32:2 The tag 'amp-inline-gallery-pagination' may only appear as a descendant of tag 'amp-inline-gallery'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-pagination>
| <!-- Invalid: Inset without nodisplay -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-pagination layout="fixed-height" height="24" inset>
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-pagination.html:36:4 The specified layout 'FIXED_HEIGHT' is not supported by tag 'amp-inline-gallery-pagination [inset]'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-pagination>
| </amp-inline-gallery>
| <!-- Valid: Inset with nodisplay -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-pagination layout="nodisplay" inset>
| </amp-inline-gallery-pagination>
| </amp-inline-gallery>
| <!-- Valid: Wrapped with a parent div -->
| <amp-inline-gallery layout="container">
| <div>
| <amp-inline-gallery-pagination layout="nodisplay"inset>
| </amp-inline-gallery-pagination>
| </div>
| </amp-inline-gallery>
| <!-- Valid: Non-inset with fixed-height -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-pagination layout="fixed-height" height="24">
| </amp-inline-gallery-pagination>
| </amp-inline-gallery>
| </body>
| </html>
@@ -0,0 +1,77 @@
<!--
Copyright 2020 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the license.
-->
<!--
Test Description:
Tests for the amp-inline-gallery-thumbnails tag. See the inline comments.
-->
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<link rel="canonical" href="./regular-html-version.html">
<meta name="viewport" content="width=device-width,minimum-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-inline-gallery" src="https://cdn.ampproject.org/v0/amp-inline-gallery-0.1.js"></script>
</head>
<body>
<!-- Invalid: Not in a gallery -->
<amp-inline-gallery-thumbnails layout="fixed-height" height="96">
</amp-inline-gallery-thumbnails>
<!-- Invalid: Aspect ratio height widthout width -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="2">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Invalid: Non-number aspect ratio height-->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="two" aspect-ratio-width="3">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Invalid: Aspect ratio component of zero -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="0" aspect-ratio-width="3">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Invalid: Aspect ratio component of zero (float) -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="0.00" aspect-ratio-width="3">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Invalid: Loop attribute without value -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" loop>
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Valid: Wrapped with a parent div -->
<amp-inline-gallery layout="container">
<div>
<amp-inline-gallery-thumbnails layout="fixed-height" height="96">
</amp-inline-gallery-thumbnails>
</div>
</amp-inline-gallery>
<!-- Valid: Aspect ratio specified -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="2.0" aspect-ratio-width="3">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
<!-- Valid: Loop attribute specified -->
<amp-inline-gallery layout="container">
<amp-inline-gallery-thumbnails layout="fixed-height" height="96" loop="true">
</amp-inline-gallery-thumbnails>
</amp-inline-gallery>
</body>
</html>
@@ -0,0 +1,90 @@
FAIL
| <!--
| Copyright 2020 The AMP HTML Authors. All Rights Reserved.
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS-IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the license.
| -->
| <!--
| Test Description:
| Tests for the amp-inline-gallery-thumbnails tag. See the inline comments.
| -->
| <!doctype html>
| <html ⚡>
| <head>
| <meta charset="utf-8">
| <link rel="canonical" href="./regular-html-version.html">
| <meta name="viewport" content="width=device-width,minimum-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-inline-gallery" src="https://cdn.ampproject.org/v0/amp-inline-gallery-0.1.js"></script>
| </head>
| <body>
| <!-- Invalid: Not in a gallery -->
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:32:2 The tag 'amp-inline-gallery-thumbnails' may only appear as a descendant of tag 'amp-inline-gallery'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| <!-- Invalid: Aspect ratio height widthout width -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="2">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:36:4 The attribute 'aspect-ratio-width' in tag 'amp-inline-gallery-thumbnails' is missing or incorrect, but required by attribute 'aspect-ratio-height'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Invalid: Non-number aspect ratio height-->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="two" aspect-ratio-width="3">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:41:4 The attribute 'aspect-ratio-height' in tag 'amp-inline-gallery-thumbnails' is set to the invalid value 'two'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Invalid: Aspect ratio component of zero -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="0" aspect-ratio-width="3">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:46:4 The attribute 'aspect-ratio-height' in tag 'amp-inline-gallery-thumbnails' is set to the invalid value '0'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Invalid: Aspect ratio component of zero (float) -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="0.00" aspect-ratio-width="3">
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:51:4 The attribute 'aspect-ratio-height' in tag 'amp-inline-gallery-thumbnails' is set to the invalid value '0.00'. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Invalid: Loop attribute without value -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" loop>
>> ^~~~~~~~~
amp-inline-gallery/0.1/test/validator-amp-inline-gallery-thumbnails.html:56:4 The attribute 'loop' in tag 'amp-inline-gallery-thumbnails' is set to the invalid value ''. (see https://amp.dev/documentation/components/amp-inline-gallery)
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Valid: Wrapped with a parent div -->
| <amp-inline-gallery layout="container">
| <div>
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96">
| </amp-inline-gallery-thumbnails>
| </div>
| </amp-inline-gallery>
| <!-- Valid: Aspect ratio specified -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" aspect-ratio-height="2.0" aspect-ratio-width="3">
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| <!-- Valid: Loop attribute specified -->
| <amp-inline-gallery layout="container">
| <amp-inline-gallery-thumbnails layout="fixed-height" height="96" loop="true">
| </amp-inline-gallery-thumbnails>
| </amp-inline-gallery>
| </body>
| </html>

0 comments on commit e3be1b2

Please sign in to comment.