Skip to content

Commit

Permalink
Merge pull request #157 from ShankyTiwari/155-merge
Browse files Browse the repository at this point in the history
Resolved Conflict for PR #155
  • Loading branch information
ShankyTiwari authored Dec 20, 2020
2 parents 9dd7cad + 676546d commit 31439c0
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 315 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db
projects/ng-material-multilevel-menu/node_modules/.cache
6 changes: 3 additions & 3 deletions projects/ng-material-multilevel-menu/src/lib/app.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NavigationExtras } from '@angular/router';

export interface MultilevelNodes {
export interface MultilevelNode {
id?: string;
label: string;
faIcon?: string;
Expand All @@ -16,13 +16,13 @@ export interface MultilevelNodes {
externalRedirect?: boolean;
hrefTargetType?: string;
data?: any;
items?: MultilevelNodes[];
items?: MultilevelNode[];
onSelected?: Function;
disabled?: boolean;
expanded?: boolean;
navigationExtras?: NavigationExtras;
dontEmit?: boolean;
hasChilden?: boolean;
hasChildren?: boolean;
isSelected?: boolean;
}

Expand Down
10 changes: 10 additions & 0 deletions projects/ng-material-multilevel-menu/src/lib/common-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export class CommonUtils {

static isNullOrUndefinedOrEmpty = function (object: any): boolean {
return CommonUtils.isNullOrUndefined(object) || object === '';
};

static isNullOrUndefined = function (object: any): boolean {
return object === null || object === undefined;
};
}
5 changes: 4 additions & 1 deletion projects/ng-material-multilevel-menu/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export const CONSTANT = {
DEFAULT_LIST_BACKGROUND_COLOR: `transparent`,
DEFAULT_LIST_FONT_COLOR: `rgba(0,0,0,.87)`,
DEFAULT_HREF_TARGET_TYPE: '_self',
ERROR_MESSAGE: `Invalid data for material Multilevel List Component`
ERROR_MESSAGE: `Invalid data for material Multilevel List Component`,
POSSIBLE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
YES: 'yes',
NO: 'no'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.amml-item {
position: relative;
cursor: pointer;
}

.anml-link {
width: 100%;
display: flex;
justify-content: flex-start;
text-transform: capitalize;
text-decoration: none;
color: inherit;
}

.anml-data {
width: 100%;
height: 48px;
display: flex;
justify-content: flex-start;
}

.disabled-amml-item {
opacity: 0.5;
text-decoration: none;
pointer-events: none;
}

.icon-container {
display: flex;
flex-direction: column;
justify-content: center;
}

.amml-icon-fa {
font-size: 20px;
}

.label {
line-height: 48px;
font-weight: 400;
}

.amml-svg-icon {
width: 22px;
height: 22px;
margin-top: -12px;
}
.amml-icon-arrow-container {
direction: ltr;
display: flex;
align-items: center;
}
div[dir="ltr"] .amml-icon {
margin-right: 16px;
}
div[dir="ltr"].amml-submenu {
margin-left: 16px;
}

div[dir="rtl"] .amml-icon {
margin-left: 16px;
}
div[dir="rtl"].amml-submenu {
margin-right: 16px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<ng-container *ngTemplateOutlet="node.externalRedirect ? redirectLinkTemplate : routerLinkTemplate"></ng-container>

<ng-template #redirectLinkTemplate>
<a class="anml-link" [href]="node.link" [target]="getHrefTargetType()">
<ng-container *ngTemplateOutlet="isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet"></ng-container>
</a>
</ng-template>

<ng-template #routerLinkTemplate>
<a class="anml-link" *ngIf="!node.externalRedirect && node.link" [routerLink]="node.link">
<ng-container *ngTemplateOutlet="isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet"></ng-container>
</a>
<a class="anml-link" *ngIf="!node.link">
<ng-container *ngTemplateOutlet="isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet"></ng-container>
</a>
</ng-template>

<ng-template #linkLabelLtrOutlet>
<div class="anml-data" [dir]="'ltr'">
<ng-container *ngTemplateOutlet="iconContainer"></ng-container>
<span class="label">{{node.label}}</span>
</div>
<div class="amml-icon-arrow-container" *ngIf='node.hasChildren'>
<mat-icon [@ExpandedLTR]="nodeExpandStatus()">
keyboard_arrow_down
</mat-icon>
</div>
</ng-template>

<ng-template #linkLabelRtlOutlet>
<div class="anml-data" [dir]="'rtl'">
<ng-container *ngTemplateOutlet="iconContainer"></ng-container>
<span class="label">{{node.label}}</span>
</div>
<div class="amml-icon-arrow-container" *ngIf='node.hasChildren'>
<mat-icon [@ExpandedRTL]="nodeExpandStatus()">
keyboard_arrow_down
</mat-icon>
</div>
</ng-template>

<ng-template #iconContainer>
<div class="icon-container" [ngSwitch]="getListIcon(node)">
<span *ngSwitchCase="'faIcon'" class="amml-icon amml-icon-fa">
<i [ngClass]="getSelectedFaIcon()"></i>
</span>
<mat-icon *ngSwitchCase="'icon'" class="amml-icon">
{{getSelectedIcon()}}
</mat-icon>
<mat-icon *ngSwitchCase="'svgIcon'" class="amml-icon amml-svg-icon"
svgIcon="{{getSelectedSvgIcon()}}">
</mat-icon>
<img *ngSwitchCase="'imageIcon'" matListAvatar class="amml-icon"
src="{{getSelectedImageIcon()}}" alt="{{node.label}}"/>
</div>
</ng-template>

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ListItemContentComponent } from './list-item-content.component';

describe('ListItemContentComponent', () => {
let component: ListItemContentComponent;
let fixture: ComponentFixture<ListItemContentComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ListItemContentComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ListItemContentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {Component, Input, OnInit} from '@angular/core';
import {MultilevelNode} from '../../app.model';
import {ExpandedLTR, ExpandedRTL} from '../../animation';
import {CommonUtils} from '../../common-utils';
import {CONSTANT} from '../../constants';

@Component({
selector: 'ng-list-item-content',
templateUrl: './list-item-content.component.html',
styleUrls: ['./list-item-content.component.css'],
animations: [ExpandedLTR, ExpandedRTL]
})
export class ListItemContentComponent implements OnInit {
@Input() node: MultilevelNode;
@Input() isRtlLayout: boolean;

constructor() {
// NOOP
}

ngOnInit(): void {
// NOOP
}

getListIcon(node: MultilevelNode): string {
if (!CommonUtils.isNullOrUndefinedOrEmpty(node.icon)) {
return `icon`;
} else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.faIcon)) {
return `faIcon`;
} else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.imageIcon)) {
return `imageIcon`;
} else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.svgIcon)) {
return `svgIcon`;
} else {
return ``;
}
}

getHrefTargetType(): string {
return this.node.hrefTargetType ? this.node.hrefTargetType : CONSTANT.DEFAULT_HREF_TARGET_TYPE;
}

getSelectedSvgIcon(): string {
return this.node.isSelected && this.node.activeSvgIcon ? this.node.activeSvgIcon : this.node.svgIcon;
}

getSelectedIcon(): string {
return this.node.isSelected && this.node.activeIcon ? this.node.activeIcon : this.node.icon;
}

getSelectedFaIcon(): string {
return this.node.isSelected && this.node.activeFaIcon ? this.node.activeFaIcon : this.node.faIcon;
}

getSelectedImageIcon(): string {
return this.node.isSelected && this.node.activeImageIcon ? this.node.activeImageIcon : this.node.imageIcon;
}

nodeExpandStatus(): string {
return this.node.expanded ? CONSTANT.YES : CONSTANT.NO;
}
}
Original file line number Diff line number Diff line change
@@ -1,65 +1,3 @@
.amml-item {
position: relative;
cursor: pointer;
}

.anml-link {
width: 100%;
display: flex;
justify-content: flex-start;
text-transform: capitalize;
text-decoration: none;
color: inherit;
}

.anml-data {
.filled {
width: 100%;
height: 48px;
display: flex;
justify-content: flex-start;
}

.disabled-amml-item {
opacity: 0.5;
text-decoration: none;
pointer-events: none;
}

.icon-container {
display: flex;
flex-direction: column;
justify-content: center;
}

.amml-icon-fa {
font-size: 20px;
}

.label {
line-height: 48px;
font-weight: 400;
}

.amml-svg-icon {
width: 22px;
height: 22px;
margin-top: -12px;
}
.amml-icon-arrow-container {
direction: ltr;
display: flex;
align-items: center;
}
div[dir="ltr"] .amml-icon {
margin-right: 16px;
}
div[dir="ltr"].amml-submenu {
margin-left: 16px;
}

div[dir="rtl"] .amml-icon {
margin-left: 16px;
}
div[dir="rtl"].amml-submenu {
margin-right: 16px;
}
Loading

0 comments on commit 31439c0

Please sign in to comment.