forge
Explore
Log in

Don't you dare go Hollow

🎨 group form fields into themed card sections with sticky action bar

Browse files at this commit

2dc41bbbd6df887adb368ffc1ec85c0fd2726395Burak BoduroğluParent: 39cfc3b
  • style
    • 🎨 group form fields into themed card sections with sticky action bar
Show full message
style: 🎨 group form fields into themed card sections with sticky action bar
- wrap event/course form fields in bordered card groups with section colors
- make submit/cancel bar sticky at bottom with full-width on mobile
src/components/events/event-form.tsxmodified+64 -60
@@ -170,66 +170,70 @@ export function EventForm(props: {
170170
171171 return (
172172 <>
173- <form class="space-y-3" onSubmit={handleSubmit}>
174- <div class="space-y-1.5 border-sky-500/15 bg-sky-500/[0.03]">
175- <Label for="event-title">{t("form.title")}</Label>
176- <Input
177- id="event-title"
178- class="h-11"
179- value={title()}
180- maxlength={200}
181- required
182- onInput={(e) => setTitle(e.currentTarget.value)}
183- />
184- </div>
185- <div class="space-y-1.5 border-sky-500/15 bg-sky-500/[0.03]">
186- <Label for="event-description">{t("form.description")}</Label>
187- <Textarea
188- id="event-description"
189- class="min-h-28"
190- value={description()}
191- maxlength={2000}
192- rows={3}
193- onInput={(e) => setDescription(e.currentTarget.value)}
194- />
195- </div>
196- <div class="space-y-1.5 border-violet-500/15 bg-violet-500/[0.03]">
197- <Label for="event-audience">{t("events.audience")}</Label>
198- <Select id="event-audience" value={audienceKind()} onChange={(e) => setAudienceKind(e.currentTarget.value as EventAudience["kind"])}>
199- <For each={AUDIENCE_KINDS}>{(kind) => <option value={kind}>{t(`events.audience.${kind}` as MessageKey)}</option>}</For>
200- </Select>
201- </div>
202- <Show when={audienceKind() === "role"}>
203- <div class="space-y-1.5 border-violet-500/15 bg-violet-500/[0.03]">
204- <Label for="event-audience-role">{t("admin.role")}</Label>
205- <Select id="event-audience-role" value={audienceRole()} onChange={(e) => setAudienceRole(e.currentTarget.value as Role)}>
206- <For each={AUDIENCE_ROLES}>{(role) => <option value={role}>{t(`role.${role}` as MessageKey)}</option>}</For>
207- </Select>
208- </div>
209- </Show>
210- <Show when={audienceKind() === "course"}>
211- <div class="space-y-1.5 border-violet-500/15 bg-violet-500/[0.03]">
212- <Label for="event-audience-course">{t("nav.courses")}</Label>
213- <Select id="event-audience-course" value={audienceCourse()} onChange={(e) => setAudienceCourse(e.currentTarget.value)}>
214- <option value="">{t("events.selectCourse")}</option>
215- <For each={courses() ?? []}>{(course) => <option value={course.id}>{course.title}</option>}</For>
216- </Select>
217- </div>
218- </Show>
219- <Show when={audienceKind() === "registration"}>
220- <div class="space-y-1.5 border-violet-500/15 bg-violet-500/[0.03]">
221- <Label for="event-audience-capacity">{t("events.capacity")}</Label>
173+ <form class="space-y-4" onSubmit={handleSubmit}>
174+ <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm">
175+ <div class="space-y-1.5">
176+ <Label for="event-title">{t("form.title")}</Label>
222177 <Input
223- id="event-audience-capacity"
224- type="number"
225- min="1"
226- inputMode="numeric"
227- placeholder={t("events.capacityOptional")}
228- value={capacity()}
229- onInput={(e) => setCapacity(e.currentTarget.value)}
178+ id="event-title"
179+ class="h-11"
180+ value={title()}
181+ maxlength={200}
182+ required
183+ onInput={(e) => setTitle(e.currentTarget.value)}
184+ />
185+ </div>
186+ <div class="space-y-1.5">
187+ <Label for="event-description">{t("form.description")}</Label>
188+ <Textarea
189+ id="event-description"
190+ class="min-h-28"
191+ value={description()}
192+ maxlength={2000}
193+ rows={3}
194+ onInput={(e) => setDescription(e.currentTarget.value)}
230195 />
231196 </div>
232- </Show>
197+ </div>
198+ <div class="space-y-3 rounded-2xl border border-violet-500/15 bg-violet-500/[0.03] p-4 shadow-sm">
199+ <div class="space-y-1.5">
200+ <Label for="event-audience">{t("events.audience")}</Label>
201+ <Select id="event-audience" value={audienceKind()} onChange={(e) => setAudienceKind(e.currentTarget.value as EventAudience["kind"])}>
202+ <For each={AUDIENCE_KINDS}>{(kind) => <option value={kind}>{t(`events.audience.${kind}` as MessageKey)}</option>}</For>
203+ </Select>
204+ </div>
205+ <Show when={audienceKind() === "role"}>
206+ <div class="space-y-1.5">
207+ <Label for="event-audience-role">{t("admin.role")}</Label>
208+ <Select id="event-audience-role" value={audienceRole()} onChange={(e) => setAudienceRole(e.currentTarget.value as Role)}>
209+ <For each={AUDIENCE_ROLES}>{(role) => <option value={role}>{t(`role.${role}` as MessageKey)}</option>}</For>
210+ </Select>
211+ </div>
212+ </Show>
213+ <Show when={audienceKind() === "course"}>
214+ <div class="space-y-1.5">
215+ <Label for="event-audience-course">{t("nav.courses")}</Label>
216+ <Select id="event-audience-course" value={audienceCourse()} onChange={(e) => setAudienceCourse(e.currentTarget.value)}>
217+ <option value="">{t("events.selectCourse")}</option>
218+ <For each={courses() ?? []}>{(course) => <option value={course.id}>{course.title}</option>}</For>
219+ </Select>
220+ </div>
221+ </Show>
222+ <Show when={audienceKind() === "registration"}>
223+ <div class="space-y-1.5">
224+ <Label for="event-audience-capacity">{t("events.capacity")}</Label>
225+ <Input
226+ id="event-audience-capacity"
227+ type="number"
228+ min="1"
229+ inputMode="numeric"
230+ placeholder={t("events.capacityOptional")}
231+ value={capacity()}
232+ onInput={(e) => setCapacity(e.currentTarget.value)}
233+ />
234+ </div>
235+ </Show>
236+ </div>
233237 <div class="grid gap-3 rounded-2xl border border-amber-500/15 bg-amber-500/[0.03] p-4">
234238 <div class="space-y-1.5">
235239 <Label for="event-starts">{t("events.starts")}</Label>
@@ -295,12 +299,12 @@ export function EventForm(props: {
295299 </div>
296300 </div>
297301 {error() && <p class="text-sm text-destructive">{error()}</p>}
298- <div class="flex flex-wrap items-center gap-2">
299- <Button type="submit" class="h-10" disabled={pending()}>
302+ <div class="sticky bottom-0 -mx-5 flex flex-wrap items-center gap-2 border-t border-border bg-background px-5 pb-6 pt-4 sm:-mx-6 sm:px-6 sm:pb-6">
303+ <Button type="submit" class="h-10 flex-1 sm:flex-none" disabled={pending()}>
300304 {props.submitLabel ?? t("common.save")}
301305 </Button>
302306 {props.onCancel && (
303- <Button type="button" variant="outline" class="h-10" onClick={props.onCancel}>
307+ <Button type="button" variant="outline" class="h-10 flex-1 sm:flex-none" onClick={props.onCancel}>
304308 {t("common.cancel")}
305309 </Button>
306310 )}
src/pages/course-detail-page.tsxmodified+42 -38
@@ -373,48 +373,52 @@ function CourseDetailContent() {
373373 }, t("common.saved"));
374374 }}
375375 >
376- <div class="space-y-1.5">
377- <Label for="edit-course-title">{t("form.title")}</Label>
378- <Input
379- id="edit-course-title"
380- value={title()}
381- required
382- maxlength={200}
383- onInput={(e) => setTitle(e.currentTarget.value)}
384- />
385- </div>
386- <div class="space-y-1.5">
387- <Label for="edit-course-desc">{t("form.description")}</Label>
388- <Textarea
389- id="edit-course-desc"
390- value={description()}
391- rows={3}
392- maxlength={2000}
393- onInput={(e) => setDescription(e.currentTarget.value)}
394- />
395- </div>
396- <div class="space-y-1.5">
397- <Label for="edit-course-kind">{t("courses.kind")}</Label>
398- <Select id="edit-course-kind" value={kind()} onChange={(e) => setKind(e.currentTarget.value as CourseKind)}>
399- <For each={COURSE_KINDS}>{(item) => <option value={item}>{courseKindLabel(item)}</option>}</For>
400- </Select>
401- </div>
402- <div class="space-y-1.5">
403- <Label for="edit-course-term">{t("terms.term")}</Label>
404- <Select id="edit-course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}>
405- <option value="">{t("terms.unassigned")}</option>
406- <For each={terms() ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For>
407- </Select>
376+ <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm">
377+ <div class="space-y-1.5">
378+ <Label for="edit-course-title">{t("form.title")}</Label>
379+ <Input
380+ id="edit-course-title"
381+ value={title()}
382+ required
383+ maxlength={200}
384+ onInput={(e) => setTitle(e.currentTarget.value)}
385+ />
386+ </div>
387+ <div class="space-y-1.5">
388+ <Label for="edit-course-desc">{t("form.description")}</Label>
389+ <Textarea
390+ id="edit-course-desc"
391+ value={description()}
392+ rows={3}
393+ maxlength={2000}
394+ onInput={(e) => setDescription(e.currentTarget.value)}
395+ />
396+ </div>
408397 </div>
409- <div class="space-y-1.5">
410- <Label for="edit-course-capacity">{t("courses.capacity")}</Label>
411- <Input id="edit-course-capacity" type="number" min={1} value={capacity()} placeholder={t("courses.capacityOptional")} onInput={(e) => setCapacity(e.currentTarget.value)} />
398+ <div class="space-y-3 rounded-2xl border border-violet-500/15 bg-violet-500/[0.03] p-4 shadow-sm">
399+ <div class="space-y-1.5">
400+ <Label for="edit-course-kind">{t("courses.kind")}</Label>
401+ <Select id="edit-course-kind" value={kind()} onChange={(e) => setKind(e.currentTarget.value as CourseKind)}>
402+ <For each={COURSE_KINDS}>{(item) => <option value={item}>{courseKindLabel(item)}</option>}</For>
403+ </Select>
404+ </div>
405+ <div class="space-y-1.5">
406+ <Label for="edit-course-term">{t("terms.term")}</Label>
407+ <Select id="edit-course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}>
408+ <option value="">{t("terms.unassigned")}</option>
409+ <For each={terms() ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For>
410+ </Select>
411+ </div>
412+ <div class="space-y-1.5">
413+ <Label for="edit-course-capacity">{t("courses.capacity")}</Label>
414+ <Input id="edit-course-capacity" type="number" min={1} value={capacity()} placeholder={t("courses.capacityOptional")} onInput={(e) => setCapacity(e.currentTarget.value)} />
415+ </div>
412416 </div>
413- <div class="flex flex-wrap gap-2">
414- <Button type="submit" class="rounded-xl" disabled={pending()}>
417+ <div class="sticky bottom-0 -mx-5 flex flex-wrap gap-2 border-t border-border bg-background px-5 pb-6 pt-4 sm:-mx-6 sm:px-6 sm:pb-6">
418+ <Button type="submit" class="flex-1 rounded-xl sm:flex-none" disabled={pending()}>
415419 {t("common.update")}
416420 </Button>
417- <Button type="button" variant="outline" class="rounded-xl" onClick={() => setEditing(false)}>
421+ <Button type="button" variant="outline" class="flex-1 rounded-xl sm:flex-none" onClick={() => setEditing(false)}>
418422 {t("common.cancel")}
419423 </Button>
420424 </div>
src/pages/courses-page.tsxmodified+36 -32
@@ -190,44 +190,48 @@ function CoursesContent() {
190190 </div>
191191
192192 <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: pageLabel() })} description={t("courses.subtitle", { item: pageLabel() })}>
193- <form class="space-y-3" onSubmit={onCreate}>
194- <div class="space-y-1.5">
195- <Label for="course-title">{t("form.title")}</Label>
196- <Input id="course-title" required maxlength={200} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} />
197- </div>
198- <div class="space-y-1.5">
199- <Label for="course-desc">{t("form.description")}</Label>
200- <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} />
201- </div>
202- <div class="space-y-1.5">
203- <Label for="course-term">{t("terms.term")}</Label>
204- <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}>
205- <option value="">{t("terms.unassigned")}</option>
206- <For each={terms() ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For>
207- </Select>
208- </div>
209- <div class="space-y-1.5">
210- <Label for="course-capacity">{t("courses.capacity")}</Label>
211- <Input id="course-capacity" type="number" min={1} value={capacity()} placeholder={t("courses.capacityOptional")} onInput={(e) => setCapacity(e.currentTarget.value)} />
193+ <form class="space-y-4" onSubmit={onCreate}>
194+ <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm">
195+ <div class="space-y-1.5">
196+ <Label for="course-title">{t("form.title")}</Label>
197+ <Input id="course-title" required maxlength={200} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} />
198+ </div>
199+ <div class="space-y-1.5">
200+ <Label for="course-desc">{t("form.description")}</Label>
201+ <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} />
202+ </div>
212203 </div>
213- <Show when={hasMinRole(auth.user()?.role, "manager")}>
204+ <div class="space-y-3 rounded-2xl border border-violet-500/15 bg-violet-500/[0.03] p-4 shadow-sm">
214205 <div class="space-y-1.5">
215- <UserSearchSelect
216- id="course-create-teacher"
217- role="teacher"
218- value={teacherId()}
219- onChange={setTeacherId}
220- placeholder={t("courses.assignTeacher")}
221- label={t("courses.teachers")}
222- />
206+ <Label for="course-term">{t("terms.term")}</Label>
207+ <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}>
208+ <option value="">{t("terms.unassigned")}</option>
209+ <For each={terms() ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For>
210+ </Select>
223211 </div>
224- </Show>
212+ <div class="space-y-1.5">
213+ <Label for="course-capacity">{t("courses.capacity")}</Label>
214+ <Input id="course-capacity" type="number" min={1} value={capacity()} placeholder={t("courses.capacityOptional")} onInput={(e) => setCapacity(e.currentTarget.value)} />
215+ </div>
216+ <Show when={hasMinRole(auth.user()?.role, "manager")}>
217+ <div class="space-y-1.5">
218+ <UserSearchSelect
219+ id="course-create-teacher"
220+ role="teacher"
221+ value={teacherId()}
222+ onChange={setTeacherId}
223+ placeholder={t("courses.assignTeacher")}
224+ label={t("courses.teachers")}
225+ />
226+ </div>
227+ </Show>
228+ </div>
225229 {error() && <p class="text-sm text-destructive">{error()}</p>}
226- <div class="flex flex-wrap gap-2">
227- <Button type="submit" class="rounded-xl" disabled={pending()}>
230+ <div class="sticky bottom-0 -mx-5 flex flex-wrap gap-2 border-t border-border bg-background px-5 pb-6 pt-4 sm:-mx-6 sm:px-6 sm:pb-6">
231+ <Button type="submit" class="flex-1 rounded-xl sm:flex-none" disabled={pending()}>
228232 {t("common.create")}
229233 </Button>
230- <Button type="button" variant="outline" class="rounded-xl" onClick={() => setShowForm(false)}>
234+ <Button type="button" variant="outline" class="flex-1 rounded-xl sm:flex-none" onClick={() => setShowForm(false)}>
231235 {t("common.cancel")}
232236 </Button>
233237 </div>