Skip to content

Commit 03b8a0b

Browse files
committed
add code to add tweet
1 parent d34be3e commit 03b8a0b

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TimelineComponent } from './timeline/timeline.component';
1010
declarations: [
1111
AppComponent,
1212
TimelineComponent,
13-
TimeAgoPipe
13+
TimeAgoPipe,
1414
],
1515
imports: [
1616
BrowserModule,

src/app/timeline/timeline.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@
77
{{ tweet.text }}
88
</div>
99
</div>
10+
11+
<div class="create-tweet-container">
12+
<div class="tweet-content">
13+
<textarea cols="50" rows="5" #tweetContent></textarea>
14+
</div>
15+
<div class="footer">
16+
<button class="send-tweet-button" (click)="addTweet(tweetContent.value)">Tweeter</button>
17+
</div>
18+
</div>

src/app/timeline/timeline.component.less

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,26 @@
2727
}
2828
}
2929

30+
.create-tweet-container {
31+
margin-top: 20px;
32+
margin-left: 10px;
33+
34+
textarea {
35+
background: #fff;
36+
border: 1px solid #e6ecf0;
37+
border-radius: 8px;
38+
line-height: 20px;
39+
}
40+
41+
.send-tweet-button {
42+
background-color: #32ADAD;
43+
border-color: transparent;
44+
border-radius: 100px;
45+
color: white;
46+
font-size: 10px;
47+
line-height: 8px;
48+
padding: 6px 16px;
49+
margin-left: 310px;
50+
cursor: pointer;
51+
}
52+
}

src/app/timeline/timeline.component.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,21 @@ export class TimelineComponent implements OnInit {
2222
},
2323
];
2424

25+
user: string = 'Hugo';
26+
2527
constructor() { }
2628

2729
ngOnInit() {
2830
}
2931

32+
addTweet(text: string) {
33+
const tweet: Tweet = {
34+
created_at: new Date().toISOString(),
35+
id: this.tweets.length + 1,
36+
text,
37+
user: this.user
38+
}
39+
this.tweets.push(tweet);
40+
}
41+
3042
}

0 commit comments

Comments
 (0)