-
Notifications
You must be signed in to change notification settings - Fork 4k
Add validation and documentation for <amp-nested-menu> #25339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hey @ampproject/wg-caching, these files were changed:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking very good and clear! Just a few nits
|
It looks like owners bot is stuck. Could someone from @ampproject/wg-caching take a look? |
|
@cathyxz I'm seeing an error via check links, not owners... |
fcf1cc9 to
1e5d283
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for fixing!
| mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']" | ||
| } | ||
| } | ||
| tags: { # <amp-nested-menu> <button amp-nested-submenu-open/close> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to express this rule?
within
amp-nested-menu, allowed elements can contain either one but not both of these attributes: 'amp-nested-submenu-close', 'amp-nested-submenu-open'
Where allowed elements are: heading tags, buttons, or spans.
Right now, we individually list and specify them, but it would probably be easier if we had one rule and a list of tags to which they applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Use attr_lists, defined here. Example usage.
Code:
attr_lists {
name: "amp-nested-menu-attrs"
attrs: {
name: "amp-nested-submenu"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
attrs: {
name: "amp-nested-submenu-close"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
attrs: {
name: "amp-nested-submenu-open"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
}
Then for each tag element specify it by name:
tags: {
...
attr_lists: "amp-nested-menu-attrs"
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And note my code is wrong since the ones below do not have amp-nested-submenu, only the -open and -close
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That saves writing out the individual attributes, but I guess we still have to defined the tags one by one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are no grouping of TagSpecs which have specific requirements like this on the tag itself. There are grouping of tag names where it serves a specific purpose, like DescendantTagList.
|
@honeybadgerdontcare PTAL? |
|
Thanks a lot for the pointer! Made the change. Let me know if you have further comments. Otherwise I'd like to leave this in a mergeable state by Friday (my last day). |
extensions/amp-nested-menu/validator-amp-nested-menu.protoascii
Outdated
Show resolved
Hide resolved
extensions/amp-nested-menu/validator-amp-nested-menu.protoascii
Outdated
Show resolved
Hide resolved
=( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for merge.
| | <h4 amp-nested-submenu-open></h4> | ||
| | <div amp-nested-submenu></div> | ||
| >> ^~~~~~~~~ | ||
| amp-nested-menu/0.1/test/validator-amp-nested-menu-error.html:59:12 The attribute 'amp-nested-submenu' may not appear in tag 'div'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unfortunate error message since it really should be reporting the issue is it being a descendant of amp-accordion. We should file an issue against the validator on error selection once this is submitted so the issue can point it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #25499. Thank you!
f4032b6 to
9af4c20
Compare
* cl/279189628 When heights or sizes is empty, the layout should be fixed * cl/279442666 Revision bump for #25339 * Removed unwanted files from pull request
* cl/279189628 When heights or sizes is empty, the layout should be fixed * cl/279442666 Revision bump for ampproject#25339 * Removed unwanted files from pull request
I2I: #25049
Add validation and test files for the
<amp-nested-menu>extension.The following items are enforced via validation:
<amp-sidebar>.layout=fill.<amp-list><amp-accordion><amp-img>amp-nested-submenu: can be applied todiv's only, and cannot be the descendant of<amp-accordion>amp-nested-submenu-open: can be applied todiv,span,buttonor heading tagsamp-nested-submenu-close: same as above/cc @nainar we decided to not support ads for now since according to documentation it's not among the allowed components inside sidebar.
Demo: https://amp-sidebar-nested.firebaseapp.com/