File tree 4 files changed +65
-17
lines changed
4 files changed +65
-17
lines changed Original file line number Diff line number Diff line change
1
+ .wrapper {
2
+ display : flex;
3
+ align-items : center;
4
+ flex-direction : column;
5
+ }
6
+
7
+ .title {
8
+ color : # 294e80 ;
9
+ }
10
+
11
+ .postsWrapper {
12
+ width : 270px ;
13
+ }
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
3
- interface Post {
4
- title : string ;
5
- description : string ;
6
- author : string ;
7
- isPublished : boolean ;
8
- }
3
+ import Post , { PostProps } from "../post/Post" ;
4
+ import classNames from "./App.module.css" ;
9
5
10
- const posts : Post [ ] = [
6
+ const posts : PostProps [ ] = [
11
7
{
12
8
title : "example post" ,
13
9
description : "some text" ,
@@ -30,17 +26,11 @@ const posts: Post[] = [
30
26
31
27
const App : React . FC = ( ) => {
32
28
return (
33
- < div >
34
- < h1 > Hello typescript tv!</ h1 >
35
- < div >
29
+ < div className = { classNames . wrapper } >
30
+ < h1 className = { classNames . title } > Hello typescript tv!</ h1 >
31
+ < div className = { classNames . postsWrapper } >
36
32
{ posts . map ( ( post ) => (
37
- < div key = { post . title } >
38
- < p > title: { post . title } </ p >
39
- < p > description: { post . description } </ p >
40
- < p > author: { post . author } </ p >
41
- < p > isPublished: { post . isPublished ? "True" : "False" } </ p >
42
- < hr />
43
- </ div >
33
+ < Post key = { post . title } { ...post } />
44
34
) ) }
45
35
</ div >
46
36
</ div >
Original file line number Diff line number Diff line change
1
+ .title {
2
+ color : red;
3
+ }
4
+
5
+ .description {
6
+ color : purple;
7
+ }
8
+
9
+ .author {
10
+ color : orange;
11
+ }
12
+
13
+ .isPublished {
14
+ color : blue;
15
+ }
Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import classNames from "./Post.module.css" ;
3
+
4
+ export interface PostProps {
5
+ title : string ;
6
+ description : string ;
7
+ author : string ;
8
+ isPublished : boolean ;
9
+ }
10
+
11
+ const Post : React . FC < PostProps > = ( {
12
+ title,
13
+ description,
14
+ author,
15
+ isPublished,
16
+ } ) => {
17
+ return (
18
+ < div key = { title } >
19
+ < p className = { classNames . title } > title: { title } </ p >
20
+ < p className = { classNames . description } > description: { description } </ p >
21
+ < p className = { classNames . author } > author: { author } </ p >
22
+ < p className = { classNames . isPublished } >
23
+ isPublished: { isPublished ? "True" : "False" }
24
+ </ p >
25
+ < hr />
26
+ </ div >
27
+ ) ;
28
+ } ;
29
+
30
+ export default Post ;
You can’t perform that action at this time.
0 commit comments