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

[amp-sidebar 1.0] Un-version sidebar 1.0 #10796

Merged
merged 23 commits into from Aug 7, 2017

Conversation

torch2424
Copy link
Contributor

@torch2424 torch2424 commented Aug 4, 2017

closes #10770

By request of the validation team, and approval by @camelburrito and @dvoytenko , this PR will unversion sidebar.

toolbar will now live as a feature to amp-sidebar, and is hidden under the experimental flag, amp-sidebar toolbar. This PR does the following changes:

History of toolbar.js to ensure it has not changed since PR was opened: https://github.com/ampproject/amphtml/commits/master/extensions/amp-sidebar/1.0/toolbar.js

See the screenshots below showing it will not affect current users, but only experimental toolbar users:

screen shot 2017-08-03 at 6 33 00 pm

screen shot 2017-08-03 at 6 32 47 pm

screen shot 2017-08-03 at 6 32 08 pm

screen shot 2017-08-03 at 6 31 53 pm

screen shot 2017-08-03 at 6 31 46 pm

@@ -15,13 +15,19 @@
*/

import {CSS} from '../../../build/amp-sidebar-0.1.css';
import {Layout} from '../../../src/layout';
import {dev, user} from '../../../src/log';
import {isExperimentOn} from '../../../src/experiments';
import {KeyCodes} from '../../../src/utils/key-codes';
Copy link
Contributor

Choose a reason for hiding this comment

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

Move K between C & L

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

toArray(this.element.querySelectorAll('nav[toolbar]'));

if (toolbarElements.length > 0) {
user().assert(isExperimentOn(this.win, TAG),
Copy link
Contributor

Choose a reason for hiding this comment

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

move the experiment check above - don't assert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/** @override */
onLayoutMeasure() {
// Check our toolbars for changes
this.toolbars_.forEach(toolbar => {
Copy link
Contributor

Choose a reason for hiding this comment

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

experiment guard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

</ul>
</amp-sidebar>
```

*Example: Advanced usage of `amp-sidebar` with anchor links and smooth scrolling*

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not advanced usage - make this a part of the default example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -54,6 +55,52 @@ describes.realWin('amp-sidebar 0.1 version', {
const anchor = iframe.doc.createElement('a');
anchor.href = '#section1';
ampSidebar.appendChild(anchor);
if (options.toolbars) {
Copy link
Contributor

Choose a reason for hiding this comment

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

create a separate describe for tests with toolbar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return Promise.resolve();
});
// Create our individual toolbars
options.toolbars.forEach(toolbarObj => {
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to its own function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -104,6 +117,89 @@ Example:
<button on='tap:sidebar1.close'>x</button>
```

### Toolbar
Copy link
Contributor

Choose a reason for hiding this comment

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

mark it as experimental (Experimental)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

when open side bar, click in menu item to scroll to an element and them close side bar the page scroll up
4 participants