Skip to content
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

✨Implement nested menu for sidebar 2.0 #24570

Merged
merged 6 commits into from Sep 30, 2019
Merged

Conversation

leafsy
Copy link
Contributor

@leafsy leafsy commented Sep 17, 2019

Demo: https://amp-sidebar-nested.firebaseapp.com/
Implemented according to the API found here

Add nested menu functionality to the next version of amp-sidebar, currently under experiment.

UPDATE: per recent discussions, the submenu logic has been extracted into a separate component (tentatively named amp-drilldown), which should only reside inside sidebar (this will be enforced via validation later on).

/cc @cathyxz @sparhami @wassgha for review

Copy link
Contributor

@wassgha wassgha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick pass, the demo looks great 😄! I'm not sure how we're handling validator rules with the 1.0 version but at some point those new attributes will need to go into validator-amp-sidebar.protoascii and we will need to make validator tests for them. It would also be great to have a few tests for this new behavior (maybe also include your demo as a manual test?). Thank you :))

extensions/amp-sidebar/1.0/amp-sidebar.css Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/amp-sidebar.js Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/amp-sidebar.js Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/submenu-manager.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cathyxz cathyxz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if we can clarify the logic for the click handlers and clarify what happens to a tap action registered in an open / close element. Let's also make a note to add unit test--either in this PR or file a follow up issue linked in a TODO.

extensions/amp-sidebar/1.0/amp-sidebar.css Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/submenu-manager.js Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/submenu-manager.js Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/amp-sidebar.js Outdated Show resolved Hide resolved
extensions/amp-sidebar/1.0/submenu-manager.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cathyxz cathyxz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good! I think there are only two things that we may need to think about a bit more.

  1. Verify that your implementation properly works with laying things out (i.e. do we need to schedule layout for its children).
  2. We should start compiling a list of validator rules / requirements so we can implement sufficiently robust restrictions.

Nice work!

extensions/amp-drilldown/0.1/amp-drilldown.js Outdated Show resolved Hide resolved
extensions/amp-drilldown/0.1/amp-drilldown.js Outdated Show resolved Hide resolved
extensions/amp-drilldown/0.1/amp-drilldown.js Outdated Show resolved Hide resolved
/** @override */
layoutCallback() {
this.registerEventListeners_();
return Promise.resolve();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you have to call scheduleLayout for all its children here. A good way to test this would be to have a case where the drilldowns contain amp-img (on each submenu), and verify that the images load correctly as we switch between submenus.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added images on each layer and they all appear to load without issues. Is there anything else I should look out for to ensure the behavior is correct?

extensions/amp-drilldown/0.1/amp-drilldown.js Show resolved Hide resolved
extensions/amp-sidebar/1.0/amp-sidebar.js Outdated Show resolved Hide resolved
this.getAmpDoc(),
'amp-drilldown'
);
this.drilldownMenu_ = drilldownMenu;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that the intention here is that only one drilldown menu will exist in amp-sidebar. If yes, we should also add this to validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right; I've added some validation items in the design doc under the current approach.

Copy link
Contributor

@cathyxz cathyxz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually, there is one thing. Can you add your current demos and testing code to the test/manual folder? You can create a subfolder there for amp-sidebar and name your tests amp-sidebar-with-drilldown or something like that. Since this uses amp-list, you can use endpoints from build-system/server/routes/list.js or add your own to that file.

@cathyxz
Copy link
Contributor

cathyxz commented Sep 23, 2019

@dvoytenko this is @leafsy 's work for adding nested menus to amp-sidebar that we discussed in design review last week fyi. We would appreciate your feedback if you have the time.

@@ -725,6 +725,13 @@ exports.extensionBundles = [
latestVersion: '0.2',
type: TYPES.MISC,
},
{
name: 'amp-drilldown',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like historically 'drilldown menus' refer to this type of menu:
image
I'd recommend finding a better name for this, also we probably want to add amp-sidebar-* as a prefix for it since it doesn't seem to make sense outside of amp-sidebar if I'm right

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is under experiment, and we have an ongoing discussion about naming, let's not block on this as we can find/replace the name once we reach an agreement.

@cathyxz cathyxz merged commit 094745c into ampproject:master Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants