Skip to content

Commit 22c807b

Browse files
committed
Remove hardcoded name, create input for user, disable button if user is not set
1 parent 54ebeb6 commit 22c807b

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AngularShopTutorial
1+
# AngularTutorial
22

33
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.2.
44

@@ -25,3 +25,19 @@ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protrac
2525
## Further help
2626

2727
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28+
29+
<hr/>
30+
31+
# Exercice
32+
33+
## Setup:
34+
35+
- Fork the project, and clone it
36+
- create your own dev branch `git checkout -b dev`
37+
- launch `npm install` to download dependencies
38+
39+
## Sync with forked repository:
40+
41+
- use command `git fetch upstream` to retrieve master branch from forked repository. It will create a local upstream/master branch.
42+
- go to your local master branch: `git checkout master`
43+
- merge the upstream master to your local master: ` git merge upstream/master`. You're up to date!

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3+
import { FormsModule } from '@angular/forms';
34
import { TimeAgoPipe } from 'time-ago-pipe';
45

56
import { AppRoutingModule } from './app-routing.module';
@@ -14,7 +15,8 @@ import { TimelineComponent } from './timeline/timeline.component';
1415
],
1516
imports: [
1617
BrowserModule,
17-
AppRoutingModule
18+
AppRoutingModule,
19+
FormsModule,
1820
],
1921
providers: [],
2022
bootstrap: [AppComponent]

src/app/timeline/timeline.component.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<div class="user-box">
2+
<div *ngIf="user"><span>Bienvenue, {{ user | uppercase }}</span></div>
3+
<div *ngIf="!user"><span>Veuillez saisir votre nom </span></div>
4+
<div><small>Modifier: </small><input [(ngModel)]="user" placeholder="votre nom"></div>
5+
</div>
6+
17
<div *ngFor="let tweet of tweets" class="tweet-container">
28
<div class="tweet-header">
39
<strong>{{ tweet.user }}</strong>
@@ -21,6 +27,11 @@
2127
<textarea cols="50" rows="5" #tweetContent></textarea>
2228
</div>
2329
<div class="footer">
24-
<button class="send-tweet-button" (click)="addTweet(tweetContent.value)">Tweeter</button>
30+
<button
31+
class="send-tweet-button"
32+
[class.disabled]="!user"
33+
[disabled]="!user"
34+
(click)="addTweet(tweetContent.value)"
35+
>Tweeter</button>
2536
</div>
2637
</div>

src/app/timeline/timeline.component.less

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@grey: #657786;
2+
13
.tweet-container {
24
margin-top: 10px;
35
margin-left: 10px;
@@ -12,7 +14,7 @@
1214
}
1315

1416
.time {
15-
color: #657786;
17+
color: @grey;
1618
}
1719

1820
.time:before {
@@ -65,3 +67,13 @@
6567
.favorite-count {
6668
margin-left: 4px;
6769
}
70+
71+
.user-box {
72+
margin-bottom: 10px;
73+
padding: 5px;
74+
color: #14171a;
75+
}
76+
77+
.disabled {
78+
background-color: @grey !important;
79+
}

src/app/timeline/timeline.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class TimelineComponent implements OnInit {
2323
},
2424
];
2525

26-
user: string = 'Hugo';
26+
private user;
2727

2828
constructor() { }
2929

0 commit comments

Comments
 (0)