File tree 2 files changed +73
-9
lines changed
examples/react/components
2 files changed +73
-9
lines changed Original file line number Diff line number Diff line change
1
+ .messagesContainer {
2
+ padding : 20px ;
3
+ max-width : 800px ;
4
+ margin : 0 auto;
5
+ }
6
+
7
+ .messagesList {
8
+ display : flex;
9
+ flex-direction : column;
10
+ gap : 16px ;
11
+ }
12
+
13
+ .messageCard {
14
+ background : # ffffff ;
15
+ border-radius : 8px ;
16
+ padding : 16px ;
17
+ box-shadow : 0 2px 4px rgba (0 , 0 , 0 , 0.1 );
18
+ transition : transform 0.2s ease;
19
+ }
20
+
21
+ .messageCard : hover {
22
+ transform : translateY (-2px );
23
+ }
24
+
25
+ .premiumCard {
26
+ background : linear-gradient (to right, # f6f0ff, # ffffff );
27
+ border-left : 4px solid # 6b4fbb ;
28
+ }
29
+
30
+ .messageHeader {
31
+ display : flex;
32
+ justify-content : space-between;
33
+ align-items : center;
34
+ margin-bottom : 8px ;
35
+ }
36
+
37
+ .sender {
38
+ color : # 2f2f2f ;
39
+ font-size : 1.1em ;
40
+ }
41
+
42
+ .timestamp {
43
+ color : # 666 ;
44
+ font-size : 0.9em ;
45
+ }
46
+
47
+ .messageText {
48
+ margin : 0 ;
49
+ line-height : 1.5 ;
50
+ color : # 4a4a4a ;
51
+ }
52
+
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import type { Message } from "../interfaces" ;
3
+ import styles from "./Messages.module.css" ;
3
4
4
5
interface MessagesProps {
5
6
messages : Array < Message > ;
6
7
}
7
8
8
9
const Messages : React . FC < MessagesProps > = ( { messages } ) => {
9
10
return (
10
- < >
11
+ < div className = { styles . messagesContainer } >
11
12
< h2 > Messages</ h2 >
12
- { messages . map ( ( message , i ) => (
13
- // TODO: format as cards, add timestamp
14
- < p key = { i } className = { message . premium ? "is-premium" : "" } >
15
- < strong > { message . sender } </ strong > :< br />
16
- { message . text }
17
- </ p >
18
- ) ) }
19
- </ >
13
+ < div className = { styles . messagesList } >
14
+ { messages . map ( ( message , i ) => (
15
+ < div
16
+ key = { i }
17
+ className = { `${ styles . messageCard } ${
18
+ message . premium ? styles . premiumCard : ""
19
+ } `}
20
+ >
21
+ < div className = { styles . messageHeader } >
22
+ < strong className = { styles . sender } > { message . sender } </ strong >
23
+ < span className = { styles . timestamp } >
24
+ { new Date ( ) . toLocaleTimeString ( ) }
25
+ </ span >
26
+ </ div >
27
+ < p className = { styles . messageText } > { message . text } </ p >
28
+ </ div >
29
+ ) ) }
30
+ </ div >
31
+ </ div >
20
32
) ;
21
33
} ;
22
34
You can’t perform that action at this time.
0 commit comments