Skip to content

Commit 0f9f161

Browse files
committed
refactor(reactive-list): simple renaming and styling
1 parent 233b398 commit 0f9f161

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed

src/pages/list/reactive-list-label/list-data.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface IDataList {
2-
nameProduct: string;
2+
productName: string;
33
author: string;
44
pictureProduct: string;
55
category: string;
@@ -9,77 +9,77 @@ export interface IDataList {
99

1010
export const LIST_DATA: IDataList[] = [
1111
{
12-
nameProduct: `Beneath a Scarlet Sky: A Novel`,
12+
productName: `Beneath a Scarlet Sky: A Novel`,
1313
author: 'Mark Sullivan',
1414
pictureProduct: './assets/img/reactive-list-labels/beneath _scarlet.jpg',
1515
category: 'Literature & Fiction',
1616
price: 5.99
1717
},
1818
{
19-
nameProduct: `The Orphan's Tale: A Novel`,
19+
productName: `The Orphan's Tale: A Novel`,
2020
author: 'Pam Jenoff',
2121
pictureProduct: './assets/img/reactive-list-labels/the_orphan_tale.jpg',
2222
category: 'Literature & Fiction',
2323
price: 10.37
2424
},
2525
{
26-
nameProduct: 'All the Light We Cannot See: A Novel',
26+
productName: 'All the Light We Cannot See: A Novel',
2727
author: 'Anthony Doerr',
2828
pictureProduct: './assets/img/reactive-list-labels/all_light_we_cannot_see.jpeg',
2929
category: 'Literature & Fiction',
3030
price: 12.99
3131
},
3232
{
33-
nameProduct: 'Rules of Civility: A Novel',
33+
productName: 'Rules of Civility: A Novel',
3434
author: 'Rules of Civility: A Novel',
3535
pictureProduct: './assets/img/reactive-list-labels/rules_civility.jpg',
3636
category: 'Literature & Fiction',
3737
price: 11.79
3838
},
3939
{
40-
nameProduct: 'The Glass Castle: A Memoir',
40+
productName: 'The Glass Castle: A Memoir',
4141
author: 'Jeannette Walls',
4242
pictureProduct: './assets/img/reactive-list-labels/the_glass_castle.jpg',
4343
category: 'Biographies & Memoirs',
4444
price: 5.14
4545
},
4646
{
47-
nameProduct: 'Born a Crime: Stories from a South African Childhood',
47+
productName: 'Born a Crime: Stories from a South African Childhood',
4848
author: 'Trevor Noah',
4949
pictureProduct: './assets/img/reactive-list-labels/born_a_crime.jpg',
5050
category: 'Biographies & Memoirs',
5151
price: 6.0
5252
},
5353
{
54-
nameProduct: 'Al Franken, Giant of the Senate',
54+
productName: 'Al Franken, Giant of the Senate',
5555
author: 'Al Franken',
5656
pictureProduct: './assets/img/reactive-list-labels/giant_of_the_senate.jpg',
5757
category: 'Biographies & Memoirs',
5858
price: 6.39
5959
},
6060
{
61-
nameProduct: 'Pandemic (The Extinction Files Book 1)',
61+
productName: 'Pandemic (The Extinction Files Book 1)',
6262
author: 'A.G. Riddle',
6363
pictureProduct: './assets/img/reactive-list-labels/pandemic.jpg',
6464
category: 'Biographies & Memoirs',
6565
price: 5.47
6666
},
6767
{
68-
nameProduct: 'Origin: A Novel',
68+
productName: 'Origin: A Novel',
6969
author: 'Dan Brown',
7070
pictureProduct: './assets/img/reactive-list-labels/origin.jpg',
7171
category: 'Suspense',
7272
price: 10.99
7373
},
7474
{
75-
nameProduct: 'The Rooster Bar',
75+
productName: 'The Rooster Bar',
7676
author: 'John Grisham',
7777
pictureProduct: './assets/img/reactive-list-labels/the_rooster_bar.jpg',
7878
category: 'Suspense',
7979
price: 10.99
8080
},
8181
{
82-
nameProduct: 'The Life We Bury',
82+
productName: 'The Life We Bury',
8383
author: 'Dan Brown',
8484
pictureProduct: './assets/img/reactive-list-labels/the_life_we_bury.jpg',
8585
category: 'Suspense',

src/pages/list/reactive-list-label/reactive-list-label.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
<button ion-fab> {{ currentCategory }} </button>
1919
</ion-fab>
2020
<ion-card is-visible [content]="content" (visible)="itemIsVisible($event, book)" *ngFor="let book of dataList">
21-
<img [src]="book.pictureProduct"/>
22-
<ion-card-content>
23-
<ion-card-title>
24-
{{ book.nameProduct }}
25-
</ion-card-title>
26-
<p> {{ book.author }} </p>
27-
<b> {{ book.category }} - {{ book.price | currency:'USD' }}</b>
28-
</ion-card-content>
21+
<img [src]="book.pictureProduct" />
22+
<ion-card-content>
23+
<ion-card-title>
24+
{{ book.productName }}
25+
</ion-card-title>
26+
<p> {{ book.author }} </p>
27+
<b> {{ book.category }} - {{ book.price | currency:'USD' }}</b>
28+
</ion-card-content>
2929
</ion-card>
3030
</ion-content>

src/pages/list/reactive-list-label/reactive-list-label.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import { LIST_DATA, IDataList } from './list-data';
66
@IonicPage()
77
@Component({
88
selector: 'page-reactive-list-label',
9-
templateUrl: 'reactive-list-label.html',
9+
templateUrl: 'reactive-list-label.html'
1010
})
1111
export class ReactiveListLabelPage {
12-
1312
public dataList = LIST_DATA;
1413
public currentCategory: string = '';
1514

16-
constructor(public navCtrl: NavController, public navParams: NavParams, private ngZone: NgZone) {
17-
}
15+
constructor(
16+
public navCtrl: NavController,
17+
public navParams: NavParams,
18+
private ngZone: NgZone
19+
) {}
1820

1921
public itemIsVisible($event, book: IDataList) {
2022
console.log(book, $event);
@@ -26,8 +28,11 @@ export class ReactiveListLabelPage {
2628
const obj = {};
2729
let qtdVisibleCategory = 0;
2830
let higherCategory = '';
29-
this.dataList.filter(bk => bk.visible)
30-
.forEach(bk => obj[bk.category] = obj[bk.category] ? obj[bk.category] + 1 : 1);
31+
this.dataList
32+
.filter(bk => bk.visible)
33+
.forEach(
34+
bk => (obj[bk.category] = obj[bk.category] ? obj[bk.category] + 1 : 1)
35+
);
3136
for (const key in obj) {
3237
if (obj[key] > qtdVisibleCategory) {
3338
qtdVisibleCategory = obj[key];
@@ -45,5 +50,4 @@ export class ReactiveListLabelPage {
4550
ionViewDidLoad() {
4651
console.log('ionViewDidLoad ReactiveListLabelPage');
4752
}
48-
4953
}

0 commit comments

Comments
 (0)