Skip to content

Commit 01af4ea

Browse files
authored
Merge pull request ShankyTiwari#102 from ShankyTiwari/v9-and-link
V 4.12.0
2 parents 841aa65 + 1379dd7 commit 01af4ea

File tree

48 files changed

+1494
-2232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1494
-2232
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ appitems = [
8383
label: 'NPM',
8484
imageIcon: '/assets/batman.jpg',
8585
link: 'https://www.npmjs.com/package/ng-material-multilevel-menu',
86-
externalRedirect: true
86+
externalRedirect: true,
87+
hrefTargetType: '_blank' // _blank|_self|_parent|_top|framename
8788
},
8889
{
8990
label: 'Item 1 (with Font awesome icon)',
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# ng-material-multilevel-menu
2+
3+
Material Multi-Level Menu for Angular Projects.
4+
5+
## Why ng-material-multilevel-menu?
6+
7+
The main goal of this package is to deliver a slim and Skinny Material Multi-Level Menu for Angular Projects. That can fit into any kind of projects with no muss, no fuss. Within few lines, you will get an animation ready multilevel list that just works.
8+
9+
## Demo
10+
11+
Check the Material Multi-Level Menu in action, [click here](http://plugins.codershood.info/#/plugins/ngmm-plugin).
12+
13+
## Features
14+
1. [Material Icons](https://material.io/tools/icons/?style=baseline) are supported.
15+
2. [FontAwesome Icons](https://fontawesome.com/v4.7.0/icons/) are supported.
16+
3. Use images as icons in the list.
17+
4. Seamlessly work with Angular routing, if provided.
18+
5. RTL supported ([thanks to StavM](https://github.com/StavM)).
19+
20+
## Installation
21+
You can use either the npm or yarn command-line tool to install packages. Use whichever is appropriate for your project in the examples below.
22+
23+
#### NPM
24+
```
25+
npm install --save ng-material-multilevel-menu
26+
```
27+
28+
#### YARN
29+
```
30+
yarn add --save ng-material-multilevel-menu
31+
```
32+
33+
## Usage
34+
Follow below steps to add multi level list in your project
35+
36+
#### 1. Import NgMaterialMultilevelMenuModule
37+
38+
You need to import the ```NgMaterialMultilevelMenuModule``` in the module of your app where you want to use it.
39+
40+
```typescript
41+
import { BrowserModule } from '@angular/platform-browser';
42+
import { NgModule } from '@angular/core';
43+
44+
/* Import the module*/
45+
import { NgMaterialMultilevelMenuModule } from 'ng-material-multilevel-menu';
46+
47+
import { AppComponent } from './app.component';
48+
49+
@NgModule({
50+
declarations: [
51+
AppComponent
52+
],
53+
imports: [
54+
BrowserModule,
55+
NgMaterialMultilevelMenuModule // Import here
56+
],
57+
providers: [],
58+
bootstrap: [AppComponent]
59+
})
60+
export class AppModule { }
61+
```
62+
63+
64+
#### 2. Use <ng-material-multilevel-menu> in your HTML
65+
66+
In your HTML: Use the ```<ng-material-multilevel-menu>``` wherever you like in your project.
67+
68+
```html
69+
<ng-material-multilevel-menu
70+
[configuration]='config'
71+
[items]='appitems'
72+
(selectedItem)="selectedItem($event)"
73+
(selectedLabel)="selectedLabel($event)">
74+
</ng-material-multilevel-menu>
75+
```
76+
77+
#### 3. Structure of array to display the list
78+
79+
Make sure you structure of array should look like array shown below,
80+
```typescript
81+
appitems = [
82+
{
83+
label: 'NPM',
84+
imageIcon: '/assets/batman.jpg',
85+
link: 'https://www.npmjs.com/package/ng-material-multilevel-menu',
86+
externalRedirect: true,
87+
hrefTargetType: '_blank' // _blank|_self|_parent|_top|framename
88+
},
89+
{
90+
label: 'Item 1 (with Font awesome icon)',
91+
faIcon: 'fab fa-500px',
92+
items: [
93+
{
94+
label: 'Item 1.1',
95+
link: '/item-1-1',
96+
faIcon: 'fab fa-accusoft'
97+
},
98+
{
99+
label: 'Item 1.2',
100+
faIcon: 'fab fa-accessible-icon',
101+
disabled: true,
102+
items: [
103+
{
104+
label: 'Item 1.2.1',
105+
link: '/item-1-2-1',
106+
faIcon: 'fa-allergies' // Font awesome default prefix is fas
107+
},
108+
{
109+
label: 'Item 1.2.2',
110+
faIcon: 'fas fa-ambulance',
111+
items: [
112+
{
113+
label: 'Item 1.2.2.1',
114+
faIcon: 'fas fa-anchor', // Still you can specify if you want to
115+
onSelected: function() {
116+
console.log('Item 1.2.2.1');
117+
}
118+
}
119+
]
120+
}
121+
]
122+
}
123+
]
124+
},
125+
{
126+
label: 'Item 2',
127+
icon: 'alarm',
128+
items: [
129+
{
130+
label: 'Item 2.1',
131+
link: '/item-2-1',
132+
icon: 'favorite_border',
133+
activeIcon: 'favorite',
134+
disabled: true,
135+
},
136+
{
137+
label: 'Item 2.2',
138+
link: '/item-2-2',
139+
icon: 'favorite_border',
140+
activeIcon: 'favorite',
141+
navigationExtras: {
142+
queryParams: { order: 'popular', filter: 'new' },
143+
}
144+
}
145+
]
146+
},
147+
{
148+
label: 'Item 3',
149+
icon: 'offline_pin',
150+
onSelected: function() {
151+
console.log('Item 3');
152+
}
153+
},
154+
{
155+
label: 'Item 4',
156+
link: '/item-4',
157+
icon: 'star_rate',
158+
hidden: true
159+
}
160+
];
161+
```
162+
163+
## API
164+
Using ```configuration```, You can customise the appearance of the list.
165+
* ```paddingAtStart: boolean``` => *[optional]* If you don't want padding at the start of the list item, then you can give ```false```. The default value will be ```true```.
166+
* ```interfaceWithRoute: boolean``` => *[required]* only if you want to use Angular Routing with this menu.
167+
* ```highlightOnSelect: boolean``` => *[optional]* If you want to highlight the clicked item in the list, then you can do that by making it ```true```. The default value will be ```false```.
168+
* ```collapseOnSelect: boolean;``` => *[optional]* You have the option to collapse another parent when clicked on the current parent. The default value will be ```false```.
169+
* ```rtlLayout: boolean;``` => *[optional]* whether display is Right To Left. The default value will be ```false```.
170+
* ```classname: string;``` => *[optional]* You can give your own custom class name in order to modify the list appearance.
171+
* ```listBackgroundColor: string;``` => *[optional]* You can apply custom color to the background of the list.
172+
* ```fontColor: string;``` => *[optional]* Changes the color of Text and icons inside the list.
173+
* ```backgroundColor: string;``` => *[optional]* This will change the background color list container.
174+
* ```selectedListFontColor: string;``` => *[optional]* This will change the font color of selected list item.
175+
176+
Below is example how you can apply diffent background and Font colors,
177+
```typescript
178+
config = {
179+
paddingAtStart: true,
180+
interfaceWithRoute: true,
181+
classname: 'my-custom-class',
182+
listBackgroundColor: `rgb(208, 241, 239)`,
183+
fontColor: `rgb(8, 54, 71)`,
184+
backgroundColor: `rgb(208, 241, 239)`,
185+
selectedListFontColor: `red`,
186+
highlightOnSelect: true,
187+
collapseOnSelect: true,
188+
rtlLayout: false
189+
};
190+
```
191+
192+
## Default classes
193+
* ```selected-amml-item```: This class will be applied to currently selected link and it's father links.
194+
* ```active-amml-item```: This class will be applied to currently selected link.
195+
196+
## Dependencies
197+
1. [Angular Material](https://material.angular.io)
198+
199+
## Contribution
200+
201+
I welcome you to fork and add more features into it. If you have any bugs or feature request, please create an issue at [github repository](https://github.com/ShankyTiwari/ng-material-multilevel-menu/issues).
202+
203+
## License
204+
205+
MIT

0 commit comments

Comments
 (0)