Skip to content

Commit 8a5df99

Browse files
committed
Add character counts
1 parent 525bac7 commit 8a5df99

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

client/src/components/AdminView.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,35 @@ export const AdminView = () => {
129129

130130
{errorMessage && <p className="p3 py-4 text-center text-error">{errorMessage}</p>}
131131

132-
<h4>Poll Question</h4>
133-
<input className="input" name="question" value={formData.question} onChange={handleChange} maxLength={150} />
132+
<div className="input-group">
133+
<label className="label">Poll Question</label>
134+
<input
135+
id="titleInput"
136+
className="input"
137+
name="question"
138+
value={formData.question}
139+
onChange={handleChange}
140+
maxLength={150}
141+
/>
142+
<span className="input-char-count">{formData.question.length}/150</span>
143+
</div>
134144

135145
{["answer1", "answer2", "answer3", "answer4", "answer5"].map((field, index) => (
136-
<div key={index}>
137-
<h4>Option {index + 1}</h4>
146+
<div key={index} className="input-group">
147+
<label className="label">Option {index + 1}</label>
138148
<input
149+
id="titleInput"
139150
className="input"
140151
name={field}
141152
value={formData[field as keyof PollFormInputs]}
142153
onChange={handleChange}
143154
maxLength={16}
144155
/>
156+
<span className="input-char-count">{formData[field as keyof PollFormInputs].length}/16</span>
145157
</div>
146158
))}
147159

148-
<h3 className="py-4">Results Display</h3>
160+
<h4 className="pt-4">Results Display</h4>
149161
{/* Using flex and gap to separate the radio buttons */}
150162
<div className="flex gap-4 pb-8">
151163
<label>
@@ -175,7 +187,7 @@ export const AdminView = () => {
175187
{errorMessage && <p className="p3 py-10 text-center text-error">{errorMessage}</p>}
176188

177189
<PageFooter>
178-
<button className="btn btn-primary mb-2" onClick={handleSaveClick} disabled={isSubmitting}>
190+
<button className="btn mb-2" onClick={handleSaveClick} disabled={isSubmitting}>
179191
{isSubmitting ? "Updating..." : "Save"}
180192
</button>
181193
<button className="btn btn-danger" onClick={handleResetClick} disabled={isSubmitting}>

client/src/pages/Home.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ const Home = () => {
7474
};
7575

7676
return (
77-
<PageContainer isLoading={isLoading} headerText="Poll">
77+
<PageContainer isLoading={isLoading}>
7878
{poll && poll.question ? (
7979
<div className="grid gap-4">
80-
<p className="mb-4">{poll.question}</p>
80+
<h4 className="mb-4">{poll.question}</h4>
8181

8282
{/* Display all the poll options dynamically as buttons */}
8383
{poll.answers?.map((ans, i) => {

0 commit comments

Comments
 (0)