Skip to content

Commit 0af44ca

Browse files
author
Di Wang
committed
settings page - remove btn
1 parent 4adb3f5 commit 0af44ca

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

src/app/dashboard/root/root.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export class RootComponent implements OnInit, OnDestroy {
1010
public id: number;
1111
public backgroundColor: string;
1212
constructor(public settingService: SettingsService) {
13-
this.id = settingService.getSidebarImageIndex();
13+
this.id = settingService.getSidebarImageIndex() + 1;
1414
this.backgroundColor = settingService.getSidebarColor();
1515
}
1616

1717
ngOnInit() {
1818
this.settingService.sidebarImageIndexUpdate.subscribe((id: number) => {
19-
this.id = id;
19+
this.id = id + 1;
2020
});
2121
this.settingService.sidebarColorUpdate.subscribe((color: string) => {
2222
this.backgroundColor = color;

src/app/dashboard/settings/settings.component.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
outline: none;
55
}
66

7-
.sidebar-bg{
7+
.sidebar-img{
88
max-width: 100%;
99
border-radius: 10px;
1010
margin-top: 10px;
11+
cursor: pointer;
1112
-webkit-transition: all 400ms;
1213
-moz-transition: all 400ms;
1314
-ms-transition: all 400ms;
@@ -16,7 +17,7 @@
1617
border: 4px solid transparent;
1718
}
1819

19-
.sidebar-bg:hover{
20+
.sidebar-img:hover{
2021
border-color: rgba(0, 187, 255, 0.5);
2122
-webkit-transition: all 400ms;
2223
-moz-transition: all 400ms;
@@ -25,7 +26,7 @@
2526
transition: all 400ms;
2627
}
2728

28-
.sidebar-btn .active{
29+
.background-image .active{
2930
border-color: #00bbff;
3031
}
3132

src/app/dashboard/settings/settings.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ <h4 class="text-center text-uppercase">Sidebar Background</h4>
2323
</div>
2424
</div>
2525

26-
<div class="col-md-10 col-md-offset-1">
26+
<div class="col-md-10 col-md-offset-1 background-image">
2727
<h4 class="text-uppercase text-center">SideBar Background Image</h4>
2828
<div class="col-md-3 col-sm-3 col-xs-6">
29-
<button class="sidebar-btn" (click)="bgChooseClick(1)"><img src="../../../assets/img/sidebar-1.jpg" alt="sidebar-bg" class="sidebar-bg"/></button>
29+
<img src="../../../assets/img/sidebar-1.jpg" alt="sidebar-bg" class="sidebar-img" (click)="bgChooseClick(0)"/>
3030
</div>
3131
<div class="col-md-3 col-sm-3 col-xs-6">
32-
<button class="sidebar-btn" (click)="bgChooseClick(2)"><img src="../../../assets/img/sidebar-2.jpg" alt="sidebar-bg" class="sidebar-bg"/></button>
32+
<img src="../../../assets/img/sidebar-2.jpg" alt="sidebar-bg" class="sidebar-img" (click)="bgChooseClick(1)"/>
3333
</div>
3434
<div class="col-md-3 col-sm-3 col-xs-6">
35-
<button class="sidebar-btn" (click)="bgChooseClick(3)"><img src="../../../assets/img/sidebar-3.jpg" alt="sidebar-bg" class="sidebar-bg"/></button>
35+
<img src="../../../assets/img/sidebar-3.jpg" alt="sidebar-bg" class="sidebar-img" (click)="bgChooseClick(2)"/>
3636
</div>
3737
<div class="col-md-3 col-sm-3 col-xs-6">
38-
<button class="sidebar-btn" (click)="bgChooseClick(4)"><img src="../../../assets/img/sidebar-4.jpg" alt="sidebar-bg" class="sidebar-bg"/></button>
38+
<img src="../../../assets/img/sidebar-4.jpg" alt="sidebar-bg" class="sidebar-img" (click)="bgChooseClick(3)"/>
3939
</div>
4040
</div>
4141
</div>

src/app/dashboard/settings/settings.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ export class SettingsComponent implements OnInit {
1212

1313
ngOnInit() {
1414
const defaultId = this.settingService.getSidebarImageIndex();
15-
const sideBtns: HTMLCollection = document.getElementsByClassName('sidebar-btn');
16-
sideBtns[defaultId - 1].children[0].className = sideBtns[defaultId - 1].children[0].className + ' active';
15+
const sidebarImgs: HTMLCollection = document.getElementsByClassName('sidebar-img');
16+
sidebarImgs[defaultId].className = sidebarImgs[defaultId].className + ' active';
1717
}
1818

1919
bgChooseClick(id) {
2020
this.settingService.setSidebarImageIndex(id);
21-
const sideBtns: HTMLCollection = document.getElementsByClassName('sidebar-btn');
22-
for (let i = 0; i < sideBtns.length; i++){
23-
sideBtns[i].children[0].className = sideBtns[i].children[0].className.replace(' active', '');
21+
const sidebarImgs: HTMLCollection = document.getElementsByClassName('sidebar-img');
22+
for (let i = 0; i < sidebarImgs.length; i++) {
23+
sidebarImgs[i].className = sidebarImgs[i].className.replace(' active', '');
2424
}
25-
sideBtns[id - 1].children[0].className = sideBtns[id - 1].children[0].className + ' active';
25+
sidebarImgs[id].className = sidebarImgs[id].className + ' active';
2626
}
2727

2828
filterChooseClick(id) {

src/app/services/settings.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable, EventEmitter } from '@angular/core';
22

33
@Injectable()
44
export class SettingsService {
5-
public sidebarImageIndex = 1;
5+
public sidebarImageIndex = 0;
66
public sidebarImageIndexUpdate: EventEmitter<number> = new EventEmitter();
77
public sidebarFilter = '#fff';
88
public sidebarFilterUpdate: EventEmitter<string> = new EventEmitter();

0 commit comments

Comments
 (0)