Skip to content

Commit 956014e

Browse files
committed
add code to add tweet
1 parent d34be3e commit 956014e

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

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)