Skip to content

Commit d678749

Browse files
committed
bs-filter-list /product-index add ngClass : done
1 parent 1d0e835 commit d678749

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

section_19-project/project/src/app/components/products/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface IProduct {
99

1010
export interface ICategory {
1111
categoryName: string;
12-
isSelected: boolean;
12+
isActive: boolean;
1313
}
1414

1515
export interface IListGroup {

section_19-project/project/src/app/components/products/products-index/products-index.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export class ProductsIndexComponent implements OnInit, OnDestroy {
3131
const remap: ICategory[] = categories.map((item: string) => {
3232
return {
3333
categoryName: item,
34-
isSelected: false
34+
isActive: false,
35+
cssClass: 'organic'
3536
}
3637
});
3738
this.listGroup = { list: remap, key: 'categoryName'};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<ul class="list-group">
22
<li *ngFor="let item of list"
33
(click)="toggleActiveClass(item)"
4-
class="list-group-item"
5-
[ngClass]="{'active': item.isSelected}">
4+
class="list-group-item"
5+
[ngClass]='item.isActive && item.cssClass'>
66
{{ item[propertyKey] }}
77
</li>
8-
</ul>
8+
</ul>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ul {
2+
li {
3+
cursor: pointer;
4+
}
5+
}
6+
7+
.active {
8+
z-index: 2;
9+
color: #fff;
10+
}
11+
12+
.primary {
13+
@extend .active;
14+
background-color: #007bff;
15+
border-color: #007bff;
16+
}
17+
18+
.danger {
19+
@extend .active;
20+
background-color: red;
21+
border-color: red;
22+
}
23+
24+
.success {
25+
@extend .active;
26+
background-color: green;
27+
border-color: green;
28+
}
29+
30+
.organic {
31+
@extend .active;
32+
background-color: #CBDB34;
33+
border-color: #CBDB34;
34+
}
35+
36+
37+

section_19-project/project/src/app/reusable-components/bootstrap-list/bootstrap-list.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export class BootstrapListComponent implements OnChanges {
1313

1414
constructor() { }
1515

16-
toggleActiveClass(current) {
16+
toggleActiveClass(current): void {
1717
this.list
1818
.filter(el => el != current)
19-
.forEach(item => item.isSelected = false);
20-
current.isSelected = !current.isSelected;
19+
.forEach(item => item.isActive = false);
20+
current.isActive = !current.isActive;
2121
}
2222

2323
ngOnChanges(change: SimpleChanges): void {

0 commit comments

Comments
 (0)