init commit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<ul class="sidebar-menu">
|
||||
<li *ngFor="let item of data">
|
||||
<a (click)="itemClicked(item);">
|
||||
<i style="margin-top:3px;width:17px" class="fa pull-right" [ngClass]="{'fa-angle-down': !isLeaf(item) && item.isExpend, 'fa-angle-left': !isLeaf(item) && !item.isExpend}"></i>
|
||||
<i class="fa mr-3" [ngClass]="item.icon"></i> <span>{{item.name}}</span>
|
||||
</a>
|
||||
<app-bar-menu [data]="item"></app-bar-menu>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -0,0 +1,58 @@
|
||||
@import "../../theme/scss/variables.scss";
|
||||
|
||||
.sidebar-menu {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 20px;
|
||||
a {
|
||||
color: $color-gray-deep;
|
||||
text-decoration: none;
|
||||
border: 0px;
|
||||
}
|
||||
& > li {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
// padding: 0 10px;
|
||||
background: rgb(50, 65, 84);
|
||||
border-bottom: 2px solid rgb(34, 49, 68);
|
||||
// box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.03);
|
||||
&:hover {
|
||||
& > a {
|
||||
color: $color-gray-deep;
|
||||
border: 0px;
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
& > a {
|
||||
color: $color-gray-deep;
|
||||
border: 0px;
|
||||
}
|
||||
}
|
||||
& > a {
|
||||
padding: 8px 5px 8px 25px;
|
||||
display: block;
|
||||
border-left: 3px solid transparent;
|
||||
color: $color-gray-deep;
|
||||
border: 0px;
|
||||
&:hover {
|
||||
color: $color-white;
|
||||
-webkit-transition: 0.3s;
|
||||
transition: 0.3s;
|
||||
-moz-transition: 0.3s;
|
||||
-webkit-transition: 0.3s;
|
||||
-o-transition: 0.3s;
|
||||
cursor: pointer;
|
||||
filter: alpha(opacity=35);
|
||||
-moz-opacity: 0.35;
|
||||
opacity: 0.35;
|
||||
margin-left: 5px;
|
||||
}
|
||||
& > .fa {
|
||||
&::before{
|
||||
width: 25px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SidebarMenuComponent } from './sidebar-menu.component';
|
||||
|
||||
describe('SidebarMenuComponent', () => {
|
||||
let component: SidebarMenuComponent;
|
||||
let fixture: ComponentFixture<SidebarMenuComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SidebarMenuComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SidebarMenuComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Component, OnInit,Input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar-menu',
|
||||
templateUrl: './sidebar-menu.component.html',
|
||||
styleUrls: ['./sidebar-menu.component.scss']
|
||||
})
|
||||
export class SidebarMenuComponent implements OnInit {
|
||||
//输入数据
|
||||
@Input() data: Array<any>;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
* @param item
|
||||
*/
|
||||
isLeaf(item: any) {
|
||||
return !item.children || !item.children.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单点击事件
|
||||
* @param item
|
||||
*/
|
||||
itemClicked(item: any) {
|
||||
if (!this.isLeaf(item)) {
|
||||
item.isExpend = !item.isExpend;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { SidebarMenuModule } from './sidebar-menu.module';
|
||||
|
||||
describe('SidebarMenuModule', () => {
|
||||
let sidebarMenuModule: SidebarMenuModule;
|
||||
|
||||
beforeEach(() => {
|
||||
sidebarMenuModule = new SidebarMenuModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(sidebarMenuModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SidebarMenuComponent } from './sidebar-menu.component';
|
||||
import { BarMenuModule } from '../bar-menu/bar-menu.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
BarMenuModule
|
||||
],
|
||||
declarations: [SidebarMenuComponent],
|
||||
exports: [SidebarMenuComponent]
|
||||
})
|
||||
export class SidebarMenuModule { }
|
||||
Reference in New Issue
Block a user