Skip to content

Commit 23e2d57

Browse files
add message count display as additional feature
1 parent 55b4de4 commit 23e2d57

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

chat-app/client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function App() {
5454
<h1 className="app_title">Beeko Chat App</h1>
5555
<div className="app_container">
5656
<MessageList messages={messages} />
57-
<MessageForm name={name} onNameChange={setName} onSend={handleSend} />
57+
<MessageForm name={name} onNameChange={setName} onSend={handleSend} messageCount={messages.length} />
5858
</div>
5959
</div>
6060
);

chat-app/client/src/components/MessageForm.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,19 @@
6161
.button:disabled {
6262
opacity: 0.4;
6363
cursor: not-allowed;
64+
}
65+
66+
.actions {
67+
display: flex;
68+
justify-content: space-between;
69+
align-items: center;
70+
}
71+
72+
.count {
73+
font-size: 0.85rem;
74+
font-weight: 600;
75+
color: #fbbf24;
76+
border: 2px solid #fbbf24;
77+
padding: 0.4rem 1rem;
78+
border-radius: 6px;
6479
}

chat-app/client/src/components/MessageForm.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ interface Props {
55
name: string;
66
onNameChange: (name: string) => void;
77
onSend: (text: string) => void;
8+
messageCount: number;
89
}
910

10-
function MessageForm({ name, onNameChange, onSend }: Props) {
11+
function MessageForm({ name, onNameChange, onSend, messageCount }: Props) {
1112
const [text, setText] = useState("");
1213

1314
const handleSubmit = (e: React.FormEvent) => {
@@ -45,13 +46,18 @@ function MessageForm({ name, onNameChange, onSend }: Props) {
4546
rows={3}
4647
/>
4748
</div>
48-
<button
49-
className="button"
50-
type="submit"
51-
disabled={!name.trim() || !text.trim()}
52-
>
53-
Send
54-
</button>
49+
<div className="actions">
50+
51+
<span className="count">messages: {messageCount}</span>
52+
53+
<button
54+
className="button"
55+
type="submit"
56+
disabled={!name.trim() || !text.trim()}
57+
>
58+
Send
59+
</button>
60+
</div>
5561
</form>
5662
);
5763
}

0 commit comments

Comments
 (0)