#5 Adding Menus

In the previous post, we added the toolbar in our chrome app using Polymer. Today we will be adding four components :
  • Drawer-panel menu
  • Overflow menu
  • Toast
  • Icons
Add the following to add icons...You can look up here for more icons.

<link rel="import" href="bower_components/core-icons/social-icons.html">

Open "#4 Adding Polymer" post for reference.
Go to the HTML part (inside the Drawer panel) and add the Drawer-panel menu and Icons.

<!--drawer content goes here-->

 <core-menu theme="core-light-theme" class="drawer-menu">
  <core-item label="Explore" icon="explore" style="color: #673ab7;">
  <core-item label="Surprise" icon="redeem" style="color: #ff5177;">
  <core-item label="Shop" icon="shopping-cart" style="color: #38acff;">


Now let's add Overflow menu.
Before adding menu,we need to make some changes so that overflow menu comes at the right corner.
Head down to Main Toolbar part and within core-toolbar tag, add this : 

<core-toolbar class="medium">
<!-- div acts as flex container after layout attribute -->
 <div flex horizontal justified layout>
  <paper-icon-button icon="menu" core-drawer-toggle="" 

  <span style="display:flex;width:100%;justify-content:center;
    align-self:center;">Polymer  Chrome  App</span>

<!--Main content goes here-->

Note that I changed the core-menu button to paper-icon-button...does not make much difference.
Now let's add the overflow menu.

 <paper-icon-button icon="more-vert"></paper-icon-button>
 <paper-dropdown class="dropdown" halign="right">
   <core-menu class="overflow-menu">
     <paper-item id="share">Share</paper-item>

  1. class="dropdown" is necessary.
  2. halign="right" opens the dropdown menu on the left.
And ya..don't forget the styling...

.drawer-menu {
 font-size: 20px;
 font-family: sans-serif;
 color: #555;

Finally we add a Toast which appears on clicking the "Share" item from dropdown menu.

<paper-toast id="toast" text="Thank you for sharing !!!" class="core-transition core-transition-left"></paper-toast>

Add this outside "core-drawer-panel" tag. And to link this to on-click of overflow-menu item , create a javascript file and link it to your HTML.

//link to paper-toast


Loved it ? Feel free to leave comments and share.

                                                                                                                                          Next Post-->

Popular posts from this blog

Extract songs from Saavn app

Double-side Nav Drawer

15 Quotes that prove why Dhoni is The Greatest Captain Indian Cricket has ever seen