Coder Social home page Coder Social logo

angular-material-sidemenu's Introduction

Angular Material Sidemenu

Introduction

This is a package to create navigation menus using Angular Material. This follows all the design guidelines provided by Google Material spec.

Installation

This package can be installed using npm or bower:

Note: Use version 1.0.6

  • npm install ng-material-sidemenu
  • bower install angular-material-sidemenu

Usage

Include the script and CSS files in you HTML and add ngMaterialSidemenu in you module. Also this module has support for browserify or wiredep.

<link rel="stylesheet" href="path/to/angular-material-sidemenu.css">
<script src="path/to/angular-material-sidemenu.js"></script>

To use icons with ligatures you should include the reference for the Material Icons:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

After that you can add the following markup:

<md-sidemenu>
  <md-sidemenu-group>
    <md-subheader class="md-no-sticky">Caption</md-subheader>

    <md-sidemenu-content collapse-other="true" md-icon="home" md-heading="Menu 1" md-arrow="true">
      <md-sidemenu-button href="#">Submenu 1</md-sidemenu-button>
      <md-sidemenu-button href="#">Submenu 2</md-sidemenu-button>
      <md-sidemenu-button href="#">Submenu 3</md-sidemenu-button>
    </md-sidemenu-content>

    <md-sidemenu-content md-heading="Menu 2" md-arrow="true" on-hover="true">
      <md-sidemenu-button href="#">Submenu 1</md-sidemenu-button>
      <md-sidemenu-button href="#">Submenu 2</md-sidemenu-button>

      <md-sidemenu-content md-heading="Menu 2" md-arrow="true">
        <md-sidemenu-button href="#">Submenu 1</md-sidemenu-button>
        <md-sidemenu-button href="#">Submenu 2</md-sidemenu-button>
        <md-sidemenu-button href="#">Submenu 3</md-sidemenu-button>
      </md-sidemenu-content>
    </md-sidemenu-content>

  </md-sidemenu-group>

  <md-sidemenu-group>
    <md-divider></md-divider>

    <md-subheader class="md-no-sticky">Caption</md-subheader>

    <md-sidemenu-button href="#">Menu 4</md-sidemenu-button>
  </md-sidemenu-group>
</md-sidemenu>

Components

  • <md-sidemenu> Is the main directive to hold all navigation items.

  • <md-sidemenu-group> Is needed to create groups of content.

  • <md-sidemenu-content> Define the collapsible navigation element and there's some attributes to setup. The following attributes are available:

  • collapse-other - You can use to collapse all other elements.
  • on-hover - You can open menu content on hover.
  • md-icon - You can use font icons
  • md-svg-icon - To use external svg icons
  • md-heading - The title of the section
  • md-arrow - An optional boolean to show an indicator arrow
  • <md-sidemenu-button> Add the buttons inside the navigation. The following attributes are available:
  • href - The href for the button
  • ui-sref - The ui-router alternative
  • ui-sref-active - The highlight class to use with ui-router
  • target - The link target attribute

Pretty easy!

License

MIT

angular-material-sidemenu's People

Contributors

andersonfalcao avatar avalarh avatar joaovitor avatar juanmav avatar marcosmoura avatar xandor-io avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-material-sidemenu's Issues

How to use md-svg-icon / Other icon font library like Font Awesome?

I have an application in which I would like to use the font awesome library for the icons. I am not able to change it currently without editing the directive template.
Is there a simpler method?

Also the documentation does not cover how to use the md-svg-icon attribute.
Could you please give some demo or example?

Thank you.

Merge relevant PRs

@marcosmoura There are couple of PRs with some very useful features.
Could you please merge them and release a new version.

Thanks.
Prerak

All the states should start with home.

Is that correct?

If I use something like this:

<md-sidemenu-button ui-sref="test">Submenu 1</md-sidemenu-button>

It always try to find home.test. Is this correct? Is there a way to just define a root state? Or is this a best practice?

Tks a lot!
Ari

ng-repeat breaks collapsing

I've found a bug when using the sidemenu with an ng-repeat.
I've made this plunkr in which you can see that the sidemenu is rendered correctly at first, but it's broken 2 seconds later when some buttons are dynamically added after what we can see as an http request or something like that.

For what I've seen, there's a marginTip which does the magic of "collapsing" the items when the menu is closed. The problem is that marginTop should be recalculated each time the length of the children changes.

I can imagine that this can be solved with a $watcher but maybe someone more experienced can recommend another way of solving it.

I can work on a PR if some of the maintainers says it would be merged.

Thanks!

SVG icons not working

Attempts to use md-svg-icon currently fail. Issue is a lack of {{}} around the md-svg-icon expression in the mdSidemenuContent directive template.

`<md-icon ng-if="$mdSidemenuContent.svgIcon" md-svg-icon="$mdSidemenuContent.svgIcon"></md-icon>`

should be:

`<md-icon ng-if="$mdSidemenuContent.svgIcon" md-svg-icon="{{$mdSidemenuContent.svgIcon}}"></md-icon>`

md-content spilling when sub-items reach a certain number

Hello,
I have noticed that increasing the number of sub-items under a certain md-content affects the view thereby making the items spill out on to the parent view. can you help fix this. I have an attachment showing the spill space.
P.s I made the height of md-content and button to be 62px in css, and i currently have 8 sub items under category 1. At about 6 sub-items, it shows just fine without the large space. Help please.

Thanks.
screenshot 248

TypeError: Cannot read property '$parent' of undefined

angular-material-sidemenu version: 1.0.5
I am using gulp to build and serve my web app.
When I am using gulp-serve the project is starting from my root/src/main/ folder and angular-material-sidemenu is working properly.

but when I do gulp-build, a build is getting generated and saved in root/build/www and angular-material-sidemenu is getting compressed and saved in vendor.js file.

                 <md-sidemenu-group>
                      <md-sidemenu-button ui-sref="journal">
                          <md-icon md-svg-src="content/images/PL_Services.svg">book</md-icon>
                          <span data-translate="sidebar.menu.journal">journal</span>
                      </md-sidemenu-button>
                  </md-sidemenu-group>

This is working correctly and journal state is loaded, but

                  <md-sidemenu-group>
                    <md-sidemenu-content collapse-other="true" md-svg-icon="content/images/PL_Contacts.svg" md-heading="{{'sidebar.menu.contacts.title'|translate}}" md-arrow="true">
                      <md-sidemenu-button ui-sref="contacts">
                        <md-icon class="ng-binding ng-scope material-icons" role="img">person</md-icon>
                        <span data-translate="sidebar.menu.contacts.view">View</span>
                      </md-sidemenu-button>

                      <md-sidemenu-button ui-sref="trustContact">
                        <md-icon class="ng-binding ng-scope material-icons" role="img">person_add</md-icon>
                        <span data-translate="sidebar.menu.contacts.new">Add</span>
                      </md-sidemenu-button>
                    </md-sidemenu-content>
                  </md-sidemenu-group>

is not expanding and showing the two buttons inside the md-sidemenu-content.

It's throwing error TypeError: Cannot read property '$parent' of undefined.

material-sidemenu-err

onHover causes open/close on touch screens

If using onHover, tapping a menu item on a touchscreen results in the menu group opening and then immediately closing. You have to tap it a second time for the menu group to stay open. Presumably, this is on account of the menu responding to both the hover and click events sent to it simultaneously.

New Patch Release

Create new patch release, so we can get the latest update from your bower.json main , so wiredep can help inject the required distribution files instead of just the js

Wrong dependencies types

It seems that there are multiple devdependencies marked only as dependencies in package.json, like gulp for instance. This is causing build errors in my system since it is installing gulp-sass with an old version of node-sass that is not necessary.

Hiding submenu on Firefox

When menu is closed it looks like this:
snapshot2
When it's open it looks like this:
snapshot3

There is clearly whitespace that shouldn't be there when the menu is closed. This works on Chrome.

Original menu on material website approaches this by programmatically setting the hight of the element to 0 when closed and whatever needed when open.

Easier fix here might be to set the margin-top: -<calculated-hight>px; instead of currently margin-top: -120%

md-icon not working

plz have a look at my code
`<md-sidemenulocked="true">

    <md-sidemenu-group>
            <md-subheader class="md-no-sticky">Menu</md-subheader>
            <md-divider></md-divider>
                 <md-sidemenu-content  md-icon="home" md-heading="Home" md-arrow="true" class="material-icons">
                <md-sidemenu-button  href="#">Index</md-sidemenu-button>
            </md-sidemenu-content>
        </md-sidemenu-group>

`

md-icon = "Home" is not working in <md-sidemenu-content>

Activate one of the menu button

How can I activate one of the menu buttons of the menus?
Also, how can I collapse the activate menu after another menu is activated?

menu won't render in IE11

Hi there, I'm using md-sidemenu in my app and it works great in chrome but does not render in IE11. Has anyone experienced this?

Responsive menu

Is this menu inherently responsive or can it be made responsive by just adding a few layout classes ?

ui router errors: Cannot read property 'match' of undefined

I'm using ui router the normal way and as soon as i added my stateprovider .config, i'm seeing the following error. Am I missing something specific to sidemenu? Thank you

Is there a different way we should be using ui-sref?

My routeConfig.js is simple, like so:

(function () {
'use strict';

angular
    .module('myApp')
    .config(function($stateProvider, $urlRouterProvider) {

        $urlRouterProvider.otherwise('home');

        $stateProvider

                .state('home', {
                    url: '/home',
                    templateUrl: 'views/main-home.html'
                })

               .state('contact', {
                    url: '/contact',
                    templateUrl: 'views/main-contact.html',
                    controller: 'contactController'
                });
});

})();

angular.js:13550 TypeError: Cannot read property 'match' of undefined
at parseStateRef (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.js:4109:22)
at link (https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.js:4229:20)
at invokeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:9694:9)
at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:9093:11)
at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8397:13)
at nodeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:9088:24)
at compositeLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8397:13)
at publicLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8277:30)
at lazyCompilation (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8615:25)
at boundTranscludeFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8414:16)

ngClick ?

What about add ng-click to the sidemenu-button ?
I needed to add locally in the sources by myself but this change will be override when i update future versions.

Using version 1.0.5

hi, im relatively new to npm, im trying to update/ reinstall to version 1.0.5

but im receiving this error :
npm ERR! notarget No compatible version found: angular-material-sidemenu@'>=1.0.5 <2.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget 0.0.1, 0.0.2, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 1.0.0, 1.0.1, 1.0.2

and whenever ireinstall i always get the version 1.0.2

will appreciate any help thanks!

Missing demo

Hello! Could you please provide demo on github pages or somewhere else. It will be nice to see component in action without downloading the source

Update main in Bower.json

Please update the main property in your bower.json file to include the dest/**.css file as well.

"main": [
"dest/angular-material-sidemenu.js",
"dest/angular-material-sidemenu.css"
],

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.