Skip to content

Commit

Permalink
✨[Story layout] Added validation to presets (#32114)
Browse files Browse the repository at this point in the history
* Added validation to presets

* Updated regex and ordered alphabetically

* Ran update_tests
  • Loading branch information
mszylkowski committed Jan 22, 2021
1 parent 28cd906 commit 348875b
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 8 deletions.
@@ -0,0 +1,51 @@
<!--
Copyright 2021 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 Story grid layer templates.
-->
<!doctype html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<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-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
<title>Presets story</title>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="canonical" href="index.html">
<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>
</head>

<body>
<amp-story
standalone
publisher="The AMP team"
publisher-logo-src="./img/AMP-Brand-White-Icon.svg"
poster-portrait-src="./img/overview.jpg"
title="Landscape story"
supports-landscape>
<amp-story-page id="cover">
<amp-story-grid-layer preset="2021-background" template="fill">
<amp-img layout="fill" src="./img/example.jpg"></amp-img>
</amp-story-grid-layer>
<amp-story-grid-layer preset="2021-foreground" anchor="left" template="fill">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sit amet massa felis. Integer consequat accumsan velit, in condimentum quam sodales eu. Aliquam ac elit malesuada, iaculis massa egestas, malesuada dui. Suspendisse molestie ultricies mauris, vel tincidunt libero dignissim vel. Vivamus lacinia elit sit amet risus sagittis, sit amet imperdiet leo congue. Quisque finibus at est non commodo. Pellentesque ullamcorper feugiat metus sed ultrices. Vestibulum iaculis egestas ultricies.</p>
</amp-story-grid-layer>
<amp-story-grid-layer preset="2021-foreground" anchor="bottom right" template="fill">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sit amet massa felis. Integer consequat accumsan velit, in condimentum quam sodales eu. Aliquam ac elit malesuada, iaculis massa egestas, malesuada dui. Suspendisse molestie ultricies mauris, vel tincidunt libero dignissim vel. Vivamus lacinia elit sit amet risus sagittis, sit amet imperdiet leo congue. Quisque finibus at est non commodo. Pellentesque ullamcorper feugiat metus sed ultrices. Vestibulum iaculis egestas ultricies.</p>
</amp-story-grid-layer>
</amp-story-page>
</amp-story>
</body>
</html>
@@ -0,0 +1,52 @@
PASS
| <!--
| Copyright 2021 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 Story grid layer templates.
| -->
| <!doctype html>
| <html amp lang="en">
| <head>
| <meta charset="utf-8">
| <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-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
| <title>Presets story</title>
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
| <link rel="canonical" href="index.html">
| <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>
| </head>
|
| <body>
| <amp-story
| standalone
| publisher="The AMP team"
| publisher-logo-src="./img/AMP-Brand-White-Icon.svg"
| poster-portrait-src="./img/overview.jpg"
| title="Landscape story"
| supports-landscape>
| <amp-story-page id="cover">
| <amp-story-grid-layer preset="2021-background" template="fill">
| <amp-img layout="fill" src="./img/example.jpg"></amp-img>
| </amp-story-grid-layer>
| <amp-story-grid-layer preset="2021-foreground" anchor="left" template="fill">
| <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sit amet massa felis. Integer consequat accumsan velit, in condimentum quam sodales eu. Aliquam ac elit malesuada, iaculis massa egestas, malesuada dui. Suspendisse molestie ultricies mauris, vel tincidunt libero dignissim vel. Vivamus lacinia elit sit amet risus sagittis, sit amet imperdiet leo congue. Quisque finibus at est non commodo. Pellentesque ullamcorper feugiat metus sed ultrices. Vestibulum iaculis egestas ultricies.</p>
| </amp-story-grid-layer>
| <amp-story-grid-layer preset="2021-foreground" anchor="bottom right" template="fill">
| <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sit amet massa felis. Integer consequat accumsan velit, in condimentum quam sodales eu. Aliquam ac elit malesuada, iaculis massa egestas, malesuada dui. Suspendisse molestie ultricies mauris, vel tincidunt libero dignissim vel. Vivamus lacinia elit sit amet risus sagittis, sit amet imperdiet leo congue. Quisque finibus at est non commodo. Pellentesque ullamcorper feugiat metus sed ultrices. Vestibulum iaculis egestas ultricies.</p>
| </amp-story-grid-layer>
| </amp-story-page>
| </amp-story>
| </body>
| </html>
25 changes: 17 additions & 8 deletions extensions/amp-story/validator-amp-story.protoascii
Expand Up @@ -157,21 +157,30 @@ tags: { # <amp-story-grid-layer>
tag_name: "AMP-STORY-GRID-LAYER"
mandatory_ancestor: "AMP-STORY-PAGE"
attrs: {
name: "template"
mandatory: true
value: "fill"
value: "horizontal"
value: "thirds"
value: "vertical"
name: "anchor"
value_regex: "top|bottom|left|right|(top|bottom)[ -](left|right)|(left|right)[ -](top|bottom)"
}
attrs: {
name: "aspect-ratio"
value_regex: "\\d+:\\d+"
}
attrs: {
name: "position"
value: "landscape-half-left"
value: "landscape-half-right"
}
attrs: {
name: "aspect-ratio"
value_regex: "\\d+:\\d+"
name: "preset"
value: "2021-background"
value: "2021-foreground"
}
attrs: {
name: "template"
mandatory: true
value: "fill"
value: "horizontal"
value: "thirds"
value: "vertical"
}
descendant_tag_list: "amp-story-grid-layer-allowed-descendants"
reference_points: {
Expand Down

0 comments on commit 348875b

Please sign in to comment.