Skip to content

Commit 3004391

Browse files
committed
Setup Component Store
1 parent d313380 commit 3004391

File tree

9 files changed

+112
-70
lines changed

9 files changed

+112
-70
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.14.0

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
## Setup
44

5-
To get started, ensure that you have _at least_ Node v12 installed. You can verify what version you have installed by running
5+
To get started, ensure that you have the right version of Node installed and selected:
66

77
```sh
8-
node --version
8+
nvm install
99
```
1010

11-
from your terminal. Then, fork this repository to your personal Github account. As you make changes to the codebase during this workshop you will be pushing your changes to your personal fork. You can [learn more about forks here](https://help.github.com/en/github/getting-started-with-github/fork-a-repo).
12-
13-
Once you have forked this repository, clone your fork to your development machine. Then run the following command using your terminal from the root of the repository to install dependencies.
11+
Then run the following command using your terminal from the root of the repository to install dependencies:
1412

1513
```sh
1614
npm install

apps/earnings/src/styles.scss

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ mat-toolbar-row {
1313
justify-content: space-between;
1414
}
1515

16-
p {
17-
margin: 16px;
18-
}
19-
2016
[mat-raised-button] {
2117
width: 100%;
2218
}
@@ -47,40 +43,11 @@ mat-sidenav a {
4743
position: relative;
4844
}
4945

50-
.icon-20 {
51-
font-size: 20px;
52-
}
53-
5446
* {
5547
-webkit-font-smoothing: antialiased;
5648
-moz-osx-font-smoothing: grayscale;
5749
}
5850

59-
table {
60-
border-collapse: collapse;
61-
border-radius: 2px;
62-
border-spacing: 0;
63-
margin: 0 0 32px;
64-
width: 100%;
65-
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.24), 0 0 2px rgba(0, 0, 0, 0.12);
66-
}
67-
68-
th {
69-
font-size: 16px;
70-
font-weight: 400;
71-
padding: 13px 32px;
72-
text-align: left;
73-
color: rgba(0, 0, 0, 0.54);
74-
background: rgba(0, 0, 0, 0.03);
75-
}
76-
77-
td {
78-
color: rgba(0, 0, 0, 0.54);
79-
border: 1px solid rgba(0, 0, 0, 0.03);
80-
font-weight: 400;
81-
padding: 8px 30px;
82-
}
83-
8451
.container {
8552
display: flex;
8653
margin: 10px;
@@ -92,15 +59,6 @@ td {
9259
flex: 1;
9360
}
9461

95-
mat-card-header .mat-card-header-text {
96-
margin-left: 0;
97-
border-bottom: 1px solid #ffd740;
98-
}
99-
100-
mat-card-title h1 {
101-
display: inline;
102-
}
103-
10462
mat-card {
10563
margin-bottom: 20px !important;
10664
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<ng-container *ngIf="!isOnSmallDevice; else showCompactActions">
2+
<button mat-icon-button (click)="selectBook.emit()">
3+
<mat-icon>edit</mat-icon>
4+
</button>
5+
<button mat-icon-button (click)="deleteBook.emit()">
6+
<mat-icon>delete</mat-icon>
7+
</button>
8+
</ng-container>
9+
10+
<ng-template #showCompactActions>
11+
<button mat-icon-button [matMenuTriggerFor]="menu">
12+
<mat-icon>more_vert</mat-icon>
13+
</button>
14+
<mat-menu #menu="matMenu">
15+
<button mat-menu-item (click)="selectBook.emit()">Edit</button>
16+
<button mat-menu-item (click)="deleteBook.emit()">Delete</button>
17+
</mat-menu>
18+
</ng-template>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:host {
2+
display: block;
3+
position: relative;
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component, EventEmitter, Input, Output } from '@angular/core';
2+
3+
@Component({
4+
selector: 'bco-book-actions',
5+
templateUrl: './book-actions.component.html',
6+
styleUrls: ['./book-actions.component.scss'],
7+
})
8+
export class BookActionsComponent {
9+
@Input() isOnSmallDevice: boolean | null = false;
10+
@Output() deleteBook = new EventEmitter();
11+
@Output() selectBook = new EventEmitter();
12+
}

libs/books-page/src/lib/books-list/books-list.component.html

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,37 @@
33
<mat-card-title>
44
<h1>Books</h1>
55
</mat-card-title>
6+
<mat-button-toggle-group aria-label="Sort By">
7+
<mat-button-toggle value="name">
8+
<mat-icon>sort_by_alpha</mat-icon>
9+
</mat-button-toggle>
10+
<mat-button-toggle value="earnings">
11+
<mat-icon>attach_money</mat-icon>
12+
</mat-button-toggle>
13+
</mat-button-toggle-group>
14+
<mat-button-toggle-group aria-label="Sort Order">
15+
<mat-button-toggle value="asc">
16+
<mat-icon>arrow_upward</mat-icon>
17+
</mat-button-toggle>
18+
<mat-button-toggle value="dsc">
19+
<mat-icon>arrow_downward</mat-icon>
20+
</mat-button-toggle>
21+
</mat-button-toggle-group>
622
</mat-card-header>
723
<mat-card-content>
8-
<mat-list>
9-
<mat-list-item
10-
*ngFor="let book of books"
11-
(click)="select.emit(book)"
12-
class="record"
13-
>
14-
<h3 mat-line>{{ book.name }}</h3>
15-
<p mat-line>
16-
{{ book.description }}
17-
</p>
18-
<p>
19-
{{ book.earnings | currency }}
20-
</p>
21-
<button
24+
<div *ngFor="let book of books" class="book">
25+
<div class="bookHeader">
26+
<h3>{{ book.name }}</h3>
27+
<bco-book-actions
2228
*ngIf="!readonly"
23-
mat-icon-button
24-
(click)="delete.emit(book); $event.stopImmediatePropagation()"
25-
>
26-
<mat-icon>close</mat-icon>
27-
</button>
28-
</mat-list-item>
29-
</mat-list>
29+
[isOnSmallDevice]="true"
30+
(selectBook)="select.emit(book)"
31+
(deleteBook)="delete.emit(book)"
32+
></bco-book-actions>
33+
</div>
34+
<p>
35+
{{ book.earnings | currency }}
36+
</p>
37+
</div>
3038
</mat-card-content>
3139
</mat-card>
Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
1-
mat-list-item:not(:first-of-type) {
1+
.book:not(:first-of-type) {
22
border-top: 1px solid #efefef;
33
}
44

55
.symbol {
66
color: #777;
77
}
8+
9+
.bookHeader {
10+
display: flex;
11+
justify-content: space-between;
12+
align-items: center;
13+
width: 100%;
14+
height: 72px;
15+
}
16+
17+
h3 {
18+
font-size: 18px;
19+
font-weight: 500;
20+
margin: 0;
21+
}
22+
23+
bco-book-actions {
24+
flex-grow: 0;
25+
flex-shrink: 0;
26+
}
27+
28+
mat-card-header {
29+
position: relative;
30+
}
31+
32+
mat-button-toggle-group {
33+
transform: scale(0.7);
34+
position: absolute;
35+
top: 8px;
36+
}
37+
38+
mat-button-toggle-group:first-of-type {
39+
right: 100px;
40+
}
41+
42+
mat-button-toggle-group:last-of-type {
43+
right: -10px;
44+
}

libs/books-page/src/lib/books-page.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import { EffectsModule } from '@ngrx/effects';
66
import { MatCardModule } from '@angular/material/card';
77
import { MatInputModule } from '@angular/material/input';
88
import { MatButtonModule } from '@angular/material/button';
9+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
910
import { MatIconModule } from '@angular/material/icon';
1011
import { MatListModule } from '@angular/material/list';
12+
import { MatMenuModule } from '@angular/material/menu';
13+
import { SharedStateBooksModule } from '@book-co/shared-state-books';
14+
import { BookActionsComponent } from './book-actions/book-actions.component';
1115
import { BookDetailComponent } from './book-detail/book-detail.component';
1216
import { BooksListComponent } from './books-list/books-list.component';
1317
import { BooksPageComponent } from './books-page/books-page.component';
1418
import { BooksTotalComponent } from './books-total/books-total.component';
1519
import { BooksApiEffects } from './book-api.effects';
16-
import { SharedStateBooksModule } from '@book-co/shared-state-books';
1720

1821
@NgModule({
1922
imports: [
@@ -26,11 +29,14 @@ import { SharedStateBooksModule } from '@book-co/shared-state-books';
2629
MatCardModule,
2730
MatInputModule,
2831
MatButtonModule,
32+
MatButtonToggleModule,
2933
MatIconModule,
3034
MatListModule,
35+
MatMenuModule,
3136
SharedStateBooksModule,
3237
],
3338
declarations: [
39+
BookActionsComponent,
3440
BookDetailComponent,
3541
BooksListComponent,
3642
BooksPageComponent,

0 commit comments

Comments
 (0)