Skip to content

Commit 5448df2

Browse files
authored
fix: resolve red star and input field misalignment (freeCodeCamp-2025-Summer-Hackathon#168)
1 parent fd50bac commit 5448df2

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

frontend/src/components/RegisterForm.jsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,22 @@ export function RegisterForm({ redirect_to = '/' }) {
8787

8888
return (
8989
<form ref={formRef} onSubmit={handleSubmit(onSubmit)}>
90-
<label className='floating-label flex justify-between py-2'>
91-
Username: <span className='text-red-500'>*</span>
90+
<div className='form-group'>
91+
<label htmlFor='username' className='form-label'>
92+
Username: <span className='text-red-500'>*</span>
93+
</label>
9294
<label className='input input-sm'>
9395
<UserIcon />
9496
<input
97+
id='username'
9598
{...register('username', { required: true })}
9699
type='Text'
97100
placeholder='Username'
98101
className='input-validator'
99102
aria-invalid={!!errors.username}
100103
/>
101104
</label>
102-
</label>
105+
</div>
103106
{errors.username?.type === 'required' ? (
104107
<p role='alert' className='text-error'>
105108
The field "Username" is required.
@@ -113,38 +116,44 @@ export function RegisterForm({ redirect_to = '/' }) {
113116
)
114117
)}
115118

116-
<label className='floating-label flex justify-between py-2'>
117-
Name: <span className='text-red-500'>*</span>
119+
<div className='form-group'>
120+
<label htmlFor='name' className='form-label'>
121+
Name: <span className='text-red-500'>*</span>
122+
</label>
118123
<label className='input input-sm'>
119124
<UserIcon />
120125
<input
126+
id='name'
121127
{...register('name', { required: true })}
122128
type='Text'
123129
placeholder='Name'
124130
className='input-validator'
125131
aria-invalid={!!errors.name}
126132
/>
127133
</label>
128-
</label>
134+
</div>
129135
{errors.name?.type === 'required' && (
130136
<p role='alert' className='text-error'>
131137
The field "Name" is required.
132138
</p>
133139
)}
134140

135-
<label className='floating-label flex justify-between py-2'>
136-
Password: <span className='text-red-500'>*</span>
141+
<div className='form-group'>
142+
<label htmlFor='password' className='form-label'>
143+
Password: <span className='text-red-500'>*</span>
144+
</label>
137145
<label className='input input-sm'>
138146
<PasswordIcon />
139147
<input
148+
id='password'
140149
{...register('password', { required: true, minLength: 8 })}
141150
type='Password'
142151
placeholder='Password'
143152
className='input-validator'
144153
aria-invalid={!!errors.password}
145154
/>
146155
</label>
147-
</label>
156+
</div>
148157
{errors.password?.type === 'required' ? (
149158
<p role='alert' className='text-error'>
150159
The field "Password" is required.
@@ -157,11 +166,14 @@ export function RegisterForm({ redirect_to = '/' }) {
157166
)
158167
)}
159168

160-
<label className='floating-label flex justify-between py-2'>
161-
Repeat Password: <span className='text-red-500'>*</span>
169+
<div className='form-group'>
170+
<label htmlFor='repeatPassword' className='form-label'>
171+
Repeat Password: <span className='text-red-500'>*</span>
172+
</label>
162173
<label className='input input-sm'>
163174
<PasswordIcon />
164175
<input
176+
id='repeatPassword'
165177
{...register('repeatPassword', {
166178
required: true,
167179
validate: value => getValues('password') === value,
@@ -172,7 +184,7 @@ export function RegisterForm({ redirect_to = '/' }) {
172184
aria-invalid={!!errors.repeatPassword}
173185
/>
174186
</label>
175-
</label>
187+
</div>
176188
{errors.repeatPassword?.type === 'required' ? (
177189
<p role='alert' className='text-error'>
178190
The field "Repeat Password" is required.

frontend/src/styles.css

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
--idea-form-sub-heading-margin-bottom: 1.5rem;
100100
--form-group-margin-bottom: 1rem;
101101
--form-label-margin-bottom: 0.5rem;
102-
--form-input-padding: 1.2rem;
102+
--form-input-padding: 1.3rem;
103103
--form-textarea-min-height: 10rem;
104104
--voting-section-margin-top: 1.5rem;
105105
--voting-section-padding: 1.5rem;
@@ -734,12 +734,19 @@ body {
734734
padding: 0 var(--spacing-md);
735735
}
736736

737+
.idea-form .animated-button {
738+
display: block;
739+
margin: 0 auto;
740+
}
741+
737742
.form-group {
738743
margin-bottom: var(--form-group-margin-bottom);
739744
width: 100%;
740745
display: flex;
741746
flex-direction: column;
742-
align-items: center;
747+
align-items: flex-start;
748+
max-width: 50rem;
749+
margin: 0 auto var(--form-group-margin-bottom);
743750
}
744751

745752
.form-label {
@@ -749,16 +756,20 @@ body {
749756
color: var(--palette-primary-text);
750757
margin-bottom: var(--form-label-margin-bottom);
751758
width: 100%;
752-
max-width: 50rem;
753759
text-align: left;
754760
}
755761

762+
.form-group .input {
763+
width: 100%;
764+
margin: 0;
765+
}
766+
756767
.form-input,
757768
.form-textarea,
758769
.form-select {
759770
width: 100%;
760771
max-width: 50rem;
761-
padding: 1.2rem;
772+
padding: var(--form-input-padding);
762773
border: var(--border-width-thin) solid var(--palette-borders-separators);
763774
border-radius: var(--border-radius-sm);
764775
font-size: 1rem;
@@ -768,7 +779,6 @@ body {
768779
border-color 0.2s ease-in-out,
769780
box-shadow 0.2s ease-in-out;
770781
box-sizing: border-box;
771-
margin-inline: auto;
772782
}
773783

774784
.form-input:focus,

0 commit comments

Comments
 (0)