🎨 group form fields into themed card sections with sticky action bar
Browse files at this commit2dc41bbbd6df887adb368ffc1ec85c0fd2726395Parent: 39cfc3b- style
- 🎨 group form fields into themed card sections with sticky action bar
3 changed files +142 -130
- src/components/events/event-form.tsx +64 -60
- src/pages/course-detail-page.tsx +42 -38
- src/pages/courses-page.tsx +36 -32
src/components/events/event-form.tsxmodified+64 -60
| @@ -170,66 +170,70 @@ export function EventForm(props: { | |||
| 170 | 170 | ||
| 171 | return ( | 171 | return ( |
| 172 | <> | 172 | <> |
| 173 | - <form class="space-y-3" onSubmit={handleSubmit}> | 173 | + <form class="space-y-4" onSubmit={handleSubmit}> |
| 174 | - <div class="space-y-1.5 border-sky-500/15 bg-sky-500/[0.03]"> | 174 | + <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm"> |
| 175 | - <Label for="event-title">{t("form.title")}</Label> | 175 | + <div class="space-y-1.5"> |
| 176 | - <Input | 176 | + <Label for="event-title">{t("form.title")}</Label> |
| 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> | ||
| 222 | <Input | 177 | <Input |
| 223 | - id="event-audience-capacity" | 178 | + id="event-title" |
| 224 | - type="number" | 179 | + class="h-11" |
| 225 | - min="1" | 180 | + value={title()} |
| 226 | - inputMode="numeric" | 181 | + maxlength={200} |
| 227 | - placeholder={t("events.capacityOptional")} | 182 | + required |
| 228 | - value={capacity()} | 183 | + onInput={(e) => setTitle(e.currentTarget.value)} |
| 229 | - onInput={(e) => setCapacity(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)} | ||
| 230 | /> | 195 | /> |
| 231 | </div> | 196 | </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> | ||
| 233 | <div class="grid gap-3 rounded-2xl border border-amber-500/15 bg-amber-500/[0.03] p-4"> | 237 | <div class="grid gap-3 rounded-2xl border border-amber-500/15 bg-amber-500/[0.03] p-4"> |
| 234 | <div class="space-y-1.5"> | 238 | <div class="space-y-1.5"> |
| 235 | <Label for="event-starts">{t("events.starts")}</Label> | 239 | <Label for="event-starts">{t("events.starts")}</Label> |
| @@ -295,12 +299,12 @@ export function EventForm(props: { | |||
| 295 | </div> | 299 | </div> |
| 296 | </div> | 300 | </div> |
| 297 | {error() && <p class="text-sm text-destructive">{error()}</p>} | 301 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 298 | - <div class="flex flex-wrap items-center gap-2"> | 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"> |
| 299 | - <Button type="submit" class="h-10" disabled={pending()}> | 303 | + <Button type="submit" class="h-10 flex-1 sm:flex-none" disabled={pending()}> |
| 300 | {props.submitLabel ?? t("common.save")} | 304 | {props.submitLabel ?? t("common.save")} |
| 301 | </Button> | 305 | </Button> |
| 302 | {props.onCancel && ( | 306 | {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}> |
| 304 | {t("common.cancel")} | 308 | {t("common.cancel")} |
| 305 | </Button> | 309 | </Button> |
| 306 | )} | 310 | )} |
src/pages/course-detail-page.tsxmodified+42 -38
| @@ -373,48 +373,52 @@ function CourseDetailContent() { | |||
| 373 | }, t("common.saved")); | 373 | }, t("common.saved")); |
| 374 | }} | 374 | }} |
| 375 | > | 375 | > |
| 376 | - <div class="space-y-1.5"> | 376 | + <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm"> |
| 377 | - <Label for="edit-course-title">{t("form.title")}</Label> | 377 | + <div class="space-y-1.5"> |
| 378 | - <Input | 378 | + <Label for="edit-course-title">{t("form.title")}</Label> |
| 379 | - id="edit-course-title" | 379 | + <Input |
| 380 | - value={title()} | 380 | + id="edit-course-title" |
| 381 | - required | 381 | + value={title()} |
| 382 | - maxlength={200} | 382 | + required |
| 383 | - onInput={(e) => setTitle(e.currentTarget.value)} | 383 | + maxlength={200} |
| 384 | - /> | 384 | + onInput={(e) => setTitle(e.currentTarget.value)} |
| 385 | - </div> | 385 | + /> |
| 386 | - <div class="space-y-1.5"> | 386 | + </div> |
| 387 | - <Label for="edit-course-desc">{t("form.description")}</Label> | 387 | + <div class="space-y-1.5"> |
| 388 | - <Textarea | 388 | + <Label for="edit-course-desc">{t("form.description")}</Label> |
| 389 | - id="edit-course-desc" | 389 | + <Textarea |
| 390 | - value={description()} | 390 | + id="edit-course-desc" |
| 391 | - rows={3} | 391 | + value={description()} |
| 392 | - maxlength={2000} | 392 | + rows={3} |
| 393 | - onInput={(e) => setDescription(e.currentTarget.value)} | 393 | + maxlength={2000} |
| 394 | - /> | 394 | + onInput={(e) => setDescription(e.currentTarget.value)} |
| 395 | - </div> | 395 | + /> |
| 396 | - <div class="space-y-1.5"> | 396 | + </div> |
| 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> | ||
| 408 | </div> | 397 | </div> |
| 409 | - <div class="space-y-1.5"> | 398 | + <div class="space-y-3 rounded-2xl border border-violet-500/15 bg-violet-500/[0.03] p-4 shadow-sm"> |
| 410 | - <Label for="edit-course-capacity">{t("courses.capacity")}</Label> | 399 | + <div class="space-y-1.5"> |
| 411 | - <Input id="edit-course-capacity" type="number" min={1} value={capacity()} placeholder={t("courses.capacityOptional")} onInput={(e) => setCapacity(e.currentTarget.value)} /> | 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> | ||
| 412 | </div> | 416 | </div> |
| 413 | - <div class="flex flex-wrap gap-2"> | 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"> |
| 414 | - <Button type="submit" class="rounded-xl" disabled={pending()}> | 418 | + <Button type="submit" class="flex-1 rounded-xl sm:flex-none" disabled={pending()}> |
| 415 | {t("common.update")} | 419 | {t("common.update")} |
| 416 | </Button> | 420 | </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)}> |
| 418 | {t("common.cancel")} | 422 | {t("common.cancel")} |
| 419 | </Button> | 423 | </Button> |
| 420 | </div> | 424 | </div> |
src/pages/courses-page.tsxmodified+36 -32
| @@ -190,44 +190,48 @@ function CoursesContent() { | |||
| 190 | </div> | 190 | </div> |
| 191 | 191 | ||
| 192 | <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: pageLabel() })} description={t("courses.subtitle", { item: pageLabel() })}> | 192 | <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}> | 193 | + <form class="space-y-4" onSubmit={onCreate}> |
| 194 | - <div class="space-y-1.5"> | 194 | + <div class="space-y-3 rounded-2xl border border-sky-500/15 bg-sky-500/[0.03] p-4 shadow-sm"> |
| 195 | - <Label for="course-title">{t("form.title")}</Label> | 195 | + <div class="space-y-1.5"> |
| 196 | - <Input id="course-title" required maxlength={200} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} /> | 196 | + <Label for="course-title">{t("form.title")}</Label> |
| 197 | - </div> | 197 | + <Input id="course-title" required maxlength={200} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} /> |
| 198 | - <div class="space-y-1.5"> | 198 | + </div> |
| 199 | - <Label for="course-desc">{t("form.description")}</Label> | 199 | + <div class="space-y-1.5"> |
| 200 | - <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /> | 200 | + <Label for="course-desc">{t("form.description")}</Label> |
| 201 | - </div> | 201 | + <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /> |
| 202 | - <div class="space-y-1.5"> | 202 | + </div> |
| 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)} /> | ||
| 212 | </div> | 203 | </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"> |
| 214 | <div class="space-y-1.5"> | 205 | <div class="space-y-1.5"> |
| 215 | - <UserSearchSelect | 206 | + <Label for="course-term">{t("terms.term")}</Label> |
| 216 | - id="course-create-teacher" | 207 | + <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}> |
| 217 | - role="teacher" | 208 | + <option value="">{t("terms.unassigned")}</option> |
| 218 | - value={teacherId()} | 209 | + <For each={terms() ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For> |
| 219 | - onChange={setTeacherId} | 210 | + </Select> |
| 220 | - placeholder={t("courses.assignTeacher")} | ||
| 221 | - label={t("courses.teachers")} | ||
| 222 | - /> | ||
| 223 | </div> | 211 | </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> | ||
| 225 | {error() && <p class="text-sm text-destructive">{error()}</p>} | 229 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 226 | - <div class="flex flex-wrap gap-2"> | 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"> |
| 227 | - <Button type="submit" class="rounded-xl" disabled={pending()}> | 231 | + <Button type="submit" class="flex-1 rounded-xl sm:flex-none" disabled={pending()}> |
| 228 | {t("common.create")} | 232 | {t("common.create")} |
| 229 | </Button> | 233 | </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)}> |
| 231 | {t("common.cancel")} | 235 | {t("common.cancel")} |
| 232 | </Button> | 236 | </Button> |
| 233 | </div> | 237 | </div> |