Reputation: 1109
I was trying to build an app with layout like youtube web (www.youtube.com), here is my code :
<app-drawer-layout>
<app-drawer id="menuDrawer" slot="drawer">
<div class="drawer-contents">
<paper-icon-item>
<iron-icon icon="inbox" item-icon slot="item-icon"></iron-icon>
<span>inbox</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="favorite" item-icon slot="item-icon"></iron-icon>
<span>favorite</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="polymer" item-icon slot="item-icon"></iron-icon>
<span>polymer</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="question-answer" item-icon slot="item-icon"></iron-icon>
<span>question-answer</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="send" item-icon slot="item-icon"></iron-icon>
<span>send</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="archive" item-icon slot="item-icon"></iron-icon>
<span>archive</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="backup" item-icon slot="item-icon"></iron-icon>
<span>backup</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="dashboard" item-icon slot="item-icon"></iron-icon>
<span>dashboard</span>
</paper-icon-item>
</div>
</app-drawer>
<app-toolbar>
<paper-icon-button id="menuButton" icon="menu" on-tap="_onToggle"></paper-icon-button>
</app-toolbar>
<div id="navigationMap" style="width: 100%; height: 500px;"></div>
</app-drawer-layout>
more complete code was at jsbin : https://jsbin.com/sizeruducu/edit?html,output. I'm facing some problems:
Any comment and answer will be appreciated, thank you.
Upvotes: 1
Views: 109
Reputation: 2737
Follwoing changes are required:
Toggle function to hide the drawer
:
_onToggle() {
//this.$.menuDrawer.toggle();
var drawerLayout = this.$.drawerLayout;
if (drawerLayout.forceNarrow || !drawerLayout.narrow) {
drawerLayout.forceNarrow = !drawerLayout.forceNarrow;
} else {
drawerLayout.drawer.toggle();
}
}
Instead of toggling the app-drawer
, you have to change the layout of app-drawer-layout
.
app-drawer-layout
:
<app-drawer-layout force-narrow id="drawerLayout" fullbleed >
The fullbleed
attribute will make it fit the size of its container.
force-narrow
attribute to force to make narrow layout as you want it to
be.
To change the height of the navigation:
this.$.navigationMap.style.height = window.innerHeight+'px';
If you want to make it like youtube. Click here.
The default value of responsiveWidth
attribute of app-drawer-layout
is 640px
, so you must increase the width
of output in jsbin.
Upvotes: 1