💄 polish notes and events usability
Browse files at this commit57e942f3deb12c85d891fd8423ae2c98520515e5Parent: 9a45c71- style
- 💄 polish notes and events usability
5 changed files +58 -39
- src/components/events/event-card.tsx +17 -15
- src/components/events/event-form.tsx +6 -6
- src/components/notes/note-card.tsx +5 -4
- src/components/notes/note-form.tsx +4 -4
- src/pages/events-page.tsx +26 -10
src/components/events/event-card.tsxmodified+17 -15
| @@ -8,25 +8,27 @@ export function EventCard(props: { event: Event }) { | |||
| 8 | const { locale } = usePreferences(); | 8 | const { locale } = usePreferences(); |
| 9 | return ( | 9 | return ( |
| 10 | <Link to="/events/$id" params={{ id: props.event.id }} class="group block h-full"> | 10 | <Link to="/events/$id" params={{ id: props.event.id }} class="group block h-full"> |
| 11 | - <article class="surface-card relative flex h-full flex-col overflow-hidden transition-all group-hover:-translate-y-0.5 group-hover:border-sky-500/30"> | 11 | + <article class="surface-card relative flex h-full min-h-48 flex-col overflow-hidden transition-all group-hover:-translate-y-0.5 group-hover:border-sky-500/30 group-hover:shadow-sm"> |
| 12 | - <div class="h-1.5 w-full bg-gradient-to-r from-sky-500 via-cyan-400 to-teal-400" /> | 12 | + <div class="absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-sky-500/70 via-cyan-400/50 to-transparent" /> |
| 13 | - <div class="flex flex-1 flex-col p-5"> | 13 | + <div class="flex flex-1 flex-col p-4"> |
| 14 | - <h3 class="font-display text-lg font-semibold leading-snug group-hover:text-primary"> | 14 | + <h3 class="line-clamp-2 font-display text-lg font-semibold leading-snug group-hover:text-primary"> |
| 15 | {props.event.title} | 15 | {props.event.title} |
| 16 | </h3> | 16 | </h3> |
| 17 | - <p class="mt-2 line-clamp-2 flex-1 text-sm text-muted-foreground"> | 17 | + <p class="mt-2 line-clamp-3 flex-1 text-sm leading-relaxed text-muted-foreground"> |
| 18 | {props.event.description || "—"} | 18 | {props.event.description || "—"} |
| 19 | </p> | 19 | </p> |
| 20 | - <div class="mt-4 space-y-1 rounded-sm bg-muted/40 px-3 py-2 text-xs text-muted-foreground"> | 20 | + </div> |
| 21 | - <p> | 21 | + <div class="border-t border-border/60 bg-muted/20 px-4 py-3"> |
| 22 | - <span class="font-medium text-foreground">{t("events.starts")}:</span>{" "} | 22 | + <dl class="grid gap-2 text-xs text-muted-foreground sm:grid-cols-2"> |
| 23 | - {formatDateTime(props.event.starts_at, locale())} | 23 | + <div> |
| 24 | - </p> | 24 | + <dt class="font-medium text-foreground">{t("events.starts")}</dt> |
| 25 | - <p> | 25 | + <dd>{formatDateTime(props.event.starts_at, locale())}</dd> |
| 26 | - <span class="font-medium text-foreground">{t("events.ends")}:</span>{" "} | 26 | + </div> |
| 27 | - {formatDateTime(props.event.ends_at, locale())} | 27 | + <div> |
| 28 | - </p> | 28 | + <dt class="font-medium text-foreground">{t("events.ends")}</dt> |
| 29 | - </div> | 29 | + <dd>{formatDateTime(props.event.ends_at, locale())}</dd> |
| 30 | + </div> | ||
| 31 | + </dl> | ||
| 30 | </div> | 32 | </div> |
| 31 | </article> | 33 | </article> |
| 32 | </Link> | 34 | </Link> |
src/components/events/event-form.tsxmodified+6 -6
| @@ -105,7 +105,7 @@ export function EventForm(props: { | |||
| 105 | <Label for="event-title">{t("form.title")}</Label> | 105 | <Label for="event-title">{t("form.title")}</Label> |
| 106 | <Input | 106 | <Input |
| 107 | id="event-title" | 107 | id="event-title" |
| 108 | - class="rounded-sm" | 108 | + class="h-10 rounded-sm" |
| 109 | value={title()} | 109 | value={title()} |
| 110 | maxlength={200} | 110 | maxlength={200} |
| 111 | required | 111 | required |
| @@ -116,7 +116,7 @@ export function EventForm(props: { | |||
| 116 | <Label for="event-description">{t("form.description")}</Label> | 116 | <Label for="event-description">{t("form.description")}</Label> |
| 117 | <Textarea | 117 | <Textarea |
| 118 | id="event-description" | 118 | id="event-description" |
| 119 | - class="rounded-sm" | 119 | + class="min-h-28 rounded-sm" |
| 120 | value={description()} | 120 | value={description()} |
| 121 | maxlength={2000} | 121 | maxlength={2000} |
| 122 | rows={3} | 122 | rows={3} |
| @@ -128,7 +128,7 @@ export function EventForm(props: { | |||
| 128 | <Label for="event-starts">{t("events.starts")}</Label> | 128 | <Label for="event-starts">{t("events.starts")}</Label> |
| 129 | <Input | 129 | <Input |
| 130 | id="event-starts" | 130 | id="event-starts" |
| 131 | - class="rounded-sm" | 131 | + class="h-10 rounded-sm" |
| 132 | type="datetime-local" | 132 | type="datetime-local" |
| 133 | value={startsLocal()} | 133 | value={startsLocal()} |
| 134 | onInput={(e) => { | 134 | onInput={(e) => { |
| @@ -144,7 +144,7 @@ export function EventForm(props: { | |||
| 144 | <Label for="event-ends">{t("events.ends")}</Label> | 144 | <Label for="event-ends">{t("events.ends")}</Label> |
| 145 | <Input | 145 | <Input |
| 146 | id="event-ends" | 146 | id="event-ends" |
| 147 | - class="rounded-sm" | 147 | + class="h-10 rounded-sm" |
| 148 | type="datetime-local" | 148 | type="datetime-local" |
| 149 | value={endsLocal()} | 149 | value={endsLocal()} |
| 150 | onInput={(e) => { | 150 | onInput={(e) => { |
| @@ -159,12 +159,12 @@ export function EventForm(props: { | |||
| 159 | </div> | 159 | </div> |
| 160 | {error() && <p class="text-sm text-destructive">{error()}</p>} | 160 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 161 | <div class="flex flex-wrap items-center gap-2"> | 161 | <div class="flex flex-wrap items-center gap-2"> |
| 162 | - <Button type="submit" disabled={pending()}> | 162 | + <Button type="submit" class="h-10" disabled={pending()}> |
| 163 | <IconSave /> | 163 | <IconSave /> |
| 164 | {props.submitLabel ?? t("common.save")} | 164 | {props.submitLabel ?? t("common.save")} |
| 165 | </Button> | 165 | </Button> |
| 166 | {props.onCancel && ( | 166 | {props.onCancel && ( |
| 167 | - <Button type="button" variant="outline" onClick={props.onCancel}> | 167 | + <Button type="button" variant="outline" class="h-10" onClick={props.onCancel}> |
| 168 | {t("common.cancel")} | 168 | {t("common.cancel")} |
| 169 | </Button> | 169 | </Button> |
| 170 | )} | 170 | )} |
src/components/notes/note-card.tsxmodified+5 -4
| @@ -18,9 +18,10 @@ export function NoteCard(props: { | |||
| 18 | const [deleteOpen, setDeleteOpen] = createSignal(false); | 18 | const [deleteOpen, setDeleteOpen] = createSignal(false); |
| 19 | 19 | ||
| 20 | return ( | 20 | return ( |
| 21 | - <article class="surface-card flex h-full flex-col overflow-hidden"> | 21 | + <article class="surface-card relative flex h-full min-h-48 flex-col overflow-hidden transition-all hover:border-amber-500/30 hover:shadow-sm"> |
| 22 | - <div class="flex items-start justify-between gap-2 border-b border-border/60 bg-gradient-to-r from-amber-500/10 to-transparent px-5 py-4"> | 22 | + <div class="absolute inset-x-0 top-0 h-1 bg-gradient-to-r from-amber-500/70 via-orange-400/50 to-transparent" /> |
| 23 | - <h3 class="font-display text-lg font-semibold leading-snug">{props.note.title}</h3> | 23 | + <div class="flex items-start justify-between gap-3 border-b border-border/60 px-4 py-4"> |
| 24 | + <h3 class="line-clamp-2 min-w-0 font-display text-lg font-semibold leading-snug">{props.note.title}</h3> | ||
| 24 | <div class="flex shrink-0 gap-1"> | 25 | <div class="flex shrink-0 gap-1"> |
| 25 | <Button type="button" variant="ghost" size="sm" onClick={() => setEditing((v) => !v)}> | 26 | <Button type="button" variant="ghost" size="sm" onClick={() => setEditing((v) => !v)}> |
| 26 | {editing() ? t("common.cancel") : t("common.edit")} | 27 | {editing() ? t("common.cancel") : t("common.edit")} |
| @@ -37,7 +38,7 @@ export function NoteCard(props: { | |||
| 37 | </Button> | 38 | </Button> |
| 38 | </div> | 39 | </div> |
| 39 | </div> | 40 | </div> |
| 40 | - <div class="flex flex-1 flex-col gap-4 p-5"> | 41 | + <div class="flex flex-1 flex-col gap-4 p-4"> |
| 41 | <Show | 42 | <Show |
| 42 | when={editing()} | 43 | when={editing()} |
| 43 | fallback={ | 44 | fallback={ |
src/components/notes/note-form.tsxmodified+4 -4
| @@ -76,7 +76,7 @@ export function NoteForm(props: { | |||
| 76 | <Label for="note-title">{t("form.title")}</Label> | 76 | <Label for="note-title">{t("form.title")}</Label> |
| 77 | <Input | 77 | <Input |
| 78 | id="note-title" | 78 | id="note-title" |
| 79 | - class="rounded-sm" | 79 | + class="h-10 rounded-sm" |
| 80 | value={title()} | 80 | value={title()} |
| 81 | maxlength={200} | 81 | maxlength={200} |
| 82 | required | 82 | required |
| @@ -87,7 +87,7 @@ export function NoteForm(props: { | |||
| 87 | <Label for="note-content">{t("form.content")}</Label> | 87 | <Label for="note-content">{t("form.content")}</Label> |
| 88 | <Textarea | 88 | <Textarea |
| 89 | id="note-content" | 89 | id="note-content" |
| 90 | - class="rounded-sm" | 90 | + class="min-h-28 rounded-sm" |
| 91 | value={content()} | 91 | value={content()} |
| 92 | maxlength={10000} | 92 | maxlength={10000} |
| 93 | rows={4} | 93 | rows={4} |
| @@ -96,12 +96,12 @@ export function NoteForm(props: { | |||
| 96 | </div> | 96 | </div> |
| 97 | {error() && <p class="text-sm text-destructive">{error()}</p>} | 97 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 98 | <div class="flex flex-wrap items-center gap-2"> | 98 | <div class="flex flex-wrap items-center gap-2"> |
| 99 | - <Button type="submit" disabled={pending()}> | 99 | + <Button type="submit" class="h-10" disabled={pending()}> |
| 100 | <IconSave /> | 100 | <IconSave /> |
| 101 | {props.submitLabel ?? t("common.save")} | 101 | {props.submitLabel ?? t("common.save")} |
| 102 | </Button> | 102 | </Button> |
| 103 | {props.onCancel && ( | 103 | {props.onCancel && ( |
| 104 | - <Button type="button" variant="outline" onClick={props.onCancel}> | 104 | + <Button type="button" variant="outline" class="h-10" onClick={props.onCancel}> |
| 105 | {t("common.cancel")} | 105 | {t("common.cancel")} |
| 106 | </Button> | 106 | </Button> |
| 107 | )} | 107 | )} |
src/pages/events-page.tsxmodified+26 -10
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { For, Show, Suspense, createResource, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; |
| 2 | import { getEvents } from "@/api/getEvents"; | 2 | import { getEvents } from "@/api/getEvents"; |
| 3 | import { postEvent } from "@/api/postEvent"; | 3 | import { postEvent } from "@/api/postEvent"; |
| 4 | import { formatApiError } from "@/api/client"; | 4 | import { formatApiError } from "@/api/client"; |
| @@ -9,10 +9,13 @@ import { EventForm } from "@/components/events/event-form"; | |||
| 9 | import { RouteGuard } from "@/components/layout/route-guard"; | 9 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 10 | import { PageHeader } from "@/components/layout/page-header"; | 10 | import { PageHeader } from "@/components/layout/page-header"; |
| 11 | import { PageSpinner } from "@/components/ui/page-spinner"; | 11 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 12 | +import { PaginationControls } from "@/components/ui/pagination-controls"; | ||
| 12 | import { useAuth } from "@/stores/auth-context"; | 13 | import { useAuth } from "@/stores/auth-context"; |
| 13 | import { useT } from "@/stores/preferences-context"; | 14 | import { useT } from "@/stores/preferences-context"; |
| 14 | import { hasMinRole } from "@/lib/roles"; | 15 | import { hasMinRole } from "@/lib/roles"; |
| 15 | 16 | ||
| 17 | +const EVENT_PAGE_SIZE = 9; | ||
| 18 | + | ||
| 16 | export default function EventsPage() { | 19 | export default function EventsPage() { |
| 17 | return ( | 20 | return ( |
| 18 | <RouteGuard> | 21 | <RouteGuard> |
| @@ -27,7 +30,15 @@ function EventsContent() { | |||
| 27 | const [events, { refetch }] = createResource(() => getEvents()); | 30 | const [events, { refetch }] = createResource(() => getEvents()); |
| 28 | const [error, setError] = createSignal(""); | 31 | const [error, setError] = createSignal(""); |
| 29 | const [showForm, setShowForm] = createSignal(false); | 32 | const [showForm, setShowForm] = createSignal(false); |
| 33 | + const [page, setPage] = createSignal(0); | ||
| 30 | const canCreate = () => hasMinRole(auth.user()?.role, "teacher"); | 34 | const canCreate = () => hasMinRole(auth.user()?.role, "teacher"); |
| 35 | + const eventList = createMemo(() => events() ?? []); | ||
| 36 | + const totalPages = createMemo(() => Math.max(1, Math.ceil(eventList().length / EVENT_PAGE_SIZE))); | ||
| 37 | + const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); | ||
| 38 | + const pageItems = createMemo(() => { | ||
| 39 | + const start = safePage() * EVENT_PAGE_SIZE; | ||
| 40 | + return eventList().slice(start, start + EVENT_PAGE_SIZE); | ||
| 41 | + }); | ||
| 31 | 42 | ||
| 32 | return ( | 43 | return ( |
| 33 | <div class="space-y-6"> | 44 | <div class="space-y-6"> |
| @@ -90,15 +101,20 @@ function EventsContent() { | |||
| 90 | </div> | 101 | </div> |
| 91 | } | 102 | } |
| 92 | > | 103 | > |
| 93 | - <ul class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3"> | 104 | + <div class="space-y-4"> |
| 94 | - <For each={list()}> | 105 | + <ul class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3"> |
| 95 | - {(event) => ( | 106 | + <For each={pageItems()}> |
| 96 | - <li class="animate-fade-up"> | 107 | + {(event) => ( |
| 97 | - <EventCard event={event} /> | 108 | + <li class="animate-fade-up"> |
| 98 | - </li> | 109 | + <EventCard event={event} /> |
| 99 | - )} | 110 | + </li> |
| 100 | - </For> | 111 | + )} |
| 101 | - </ul> | 112 | + </For> |
| 113 | + </ul> | ||
| 114 | + <Show when={eventList().length > EVENT_PAGE_SIZE}> | ||
| 115 | + <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> | ||
| 116 | + </Show> | ||
| 117 | + </div> | ||
| 102 | </Show> | 118 | </Show> |
| 103 | )} | 119 | )} |
| 104 | </Show> | 120 | </Show> |