perf: cache search and news archive, drop motion/react from public pages
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 26s
CI / tests-unit (push) Failing after 1m37s
CI / tests-integration (push) Successful in 1m38s
CI / tests-ui (push) Failing after 2m24s
CI / preflight (push) Skipped
CI / deploy (push) Skipped

Closes the four remaining LOW items.

Search and news archive caching
- A leading-wildcard LIKE cannot use an index, so every /search section cost a
  COUNT(*) scan plus an ordered page fetch, and /news did the same for its
  archive. Both now cache: search per section for 30s, the archive for 60s
  under the existing news revision so publishing an article drops it at once.
- Sections are cached independently, so one slow query cannot hold up the rest
  and a failure is not cached as a result.
- The cached value is passed through cacheSafe() so the Redis path and the
  in-process path return the same types; without it a cache hit would hand the
  events grid a string where a miss hands it a Date, and it calls toISOString()
  on that field. Dates are revived on the way out so the public signatures of
  loadNewsArchive and loadPublicSearch are unchanged.
- Archive entries are keyed on the REQUESTED page rather than the clamped one,
  so two requests that clamp onto the same page cannot alias each other.

motion/react out of the public bundle
- Converted the six public-facing users: the radio player, the typewriter text
  (a motion.span with no animation props at all), the photo lightbox, the
  animated counter, the footer CMS-info popup and the scroll reveal. That was
  the actual entry points — the counter and the popup reach the public home page
  and footer through static imports, so removing only the three originally named
  would have left the library in the bundle anyway.
- Each animation moved to a CSS class, and the two that animate on exit now hold
  the element for the length of the fade, which is what AnimatePresence used to
  do.
- motion/react now only ships with /admin and the two already-lazy nav panels.
- Two safety fixes came out of this: the scroll reveal starts at opacity 0, so
  it is forced visible under prefers-reduced-motion and via a <noscript> rule in
  the root layout; and it now emits the .motion-reveal class, which the theme
  panel's "Scroll Reveal" toggle selects and which previously matched nothing.
- The CMS-info backdrop became a real button in a pointer-transparent layer
  instead of a handler on a static element, so click-outside-to-dismiss is
  reachable by keyboard.

Fewer duplicate router refreshes
- Next.js re-renders the current route as part of a server action's own response
  when that action revalidates, and applies it with a seeded navigation; the
  router only skips its own update when the action did NOT revalidate. So the
  refresh after such an action fetched the same tree twice.
- useServerAction takes an opt-in `revalidated` flag that skips it. It is opt-in
  per call rather than derived from an action name, since a rename would
  silently change behaviour. Applied to the two user-facing call sites whose
  actions were verified to revalidate their own route.

Touch targets
- .btn was the one shared control at 40px; it and the lightbox and CMS-info
  close buttons are now 44px, as is the password toggle (the auth input already
  reserved 44px for it). The remaining 32px icon buttons pass WCAG 2.2 AA, which
  only asks for 24px; enlarging those inside inputs and overlays was left alone
  because it risks visual breakage that cannot be checked from here.
This commit is contained in:
openhands committed 2026-10-09 17:35:38 +02:00
1 parent 179484642f
commit 759ae91745
16 files changed
+794 -262

No files matched your search

@@ -33,6 +33,8 @@ export function EventRegisterButton({
run(() => registerForEvent({ eventId }), {
successMessage: t("registerSuccess"),
errorMessage: t("registerError"),
// registerForEvent revalidates /events and /events/<id>.
revalidated: true,
})
}
>
@@ -69,6 +69,8 @@ export function PollVoteForm({
run(() => voteOnPoll({ pollId, votes }), {
successMessage: t("voteSuccess"),
errorMessage: t("voteError"),
// voteOnPoll revalidates /polls and /polls/<id>.
revalidated: true,
});
}
+161 -4
View File
@@ -182,6 +182,88 @@ html {
animation: page-enter-rise 240ms ease-out both;
}
/* ── Radio player entrance (was a motion/react initial/animate pair) ────── */
@keyframes radio-player-enter {
from {
opacity: 0;
transform: translate3d(0, 20px, 0) scale(0.95);
}
to {
opacity: 1;
transform: none;
}
}
.radio-player-enter {
animation: radio-player-enter 400ms cubic-bezier(0.25, 0.1, 0.25, 1) both;
}
/* ── Animated counter entrance (was motion/react on a <span>) ───────────── */
@keyframes counter-rise {
from {
opacity: 0;
transform: translate3d(0, 12px, 0);
}
to {
opacity: 1;
transform: none;
}
}
.counter-rise {
animation: counter-rise 500ms ease-out both;
}
/* ── Scroll reveal (was motion/react whileInView) ───────────────────────── */
.motion-reveal {
opacity: 0;
}
@keyframes motion-reveal-rise {
from {
opacity: 0;
transform: translate3d(0, 24px, 0);
}
to {
opacity: 1;
transform: none;
}
}
.motion-reveal-in {
animation: motion-reveal-rise 550ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* The reveal hides its content until the animation runs, so a visitor who asks
for less motion must get it back immediately. The global reduced-motion block
below already flattens the animation duration; this restores the content. */
@media (prefers-reduced-motion: reduce) {
.motion-reveal {
opacity: 1;
}
}
/* ── Photo lightbox (was an AnimatePresence opacity pair) ───────────────── */
@keyframes lightbox-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes lightbox-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.lightbox-enter {
animation: lightbox-fade-in 200ms ease-out both;
}
/* Paired with the 180ms unmount delay in PhotoLightbox: 200ms in, 180ms out,
matching the 200ms the previous motion transition used. */
.lightbox-exit {
animation: lightbox-fade-out 180ms ease-in both;
}
/* ── Route progress indicator ─────────────────────────────────────────── */
.route-progress {
position: fixed;
@@ -941,7 +1023,10 @@ a:hover {
font-weight: 700;
font-size: 14px;
cursor: pointer;
min-height: 40px;
/* 44px: the comfortable touch-target size (WCAG 2.1 AAA 2.5.5 / Apple HIG).
WCAG 2.2 AA only asks for 24px, so this is a comfort floor rather than a
compliance fix, but every button in the system shares this class. */
min-height: 44px;
transition: all 0.18s ease;
background: color-mix(
in srgb,
@@ -1534,15 +1619,85 @@ a.content-card {
outline: 3px solid color-mix(in srgb, var(--color-primary) 42%, transparent);
outline-offset: 3px;
}
.cms-info-backdrop {
/* Centering layer. Transparent and click-through itself, so only the backdrop
button and the dialog catch pointer events. */
.cms-info-layer {
position: fixed;
inset: 0;
z-index: 1000;
display: grid;
place-items: center;
padding: 1rem;
pointer-events: none;
}
.cms-info-backdrop {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
padding: 0;
border: 0;
cursor: default;
background: rgba(8, 10, 14, 0.68);
backdrop-filter: blur(6px);
pointer-events: auto;
}
/* Enter/exit were motion/react opacity pairs; the dialog itself also used a
scale/translate pair. Paired with the 180ms unmount delay in CmsInfoPopup. */
@keyframes cms-info-backdrop-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes cms-info-backdrop-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes cms-info-dialog-in {
from {
opacity: 0;
transform: scale(0.95) translate3d(0, 10px, 0);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes cms-info-dialog-out {
from {
opacity: 1;
transform: none;
}
to {
opacity: 0;
transform: scale(0.95) translate3d(0, 10px, 0);
}
}
.cms-info-backdrop-enter {
animation: cms-info-backdrop-in 200ms ease-out both;
}
.cms-info-backdrop-exit {
animation: cms-info-backdrop-out 180ms ease-in both;
}
.cms-info-dialog-enter {
animation: cms-info-dialog-in 200ms ease-out both;
}
.cms-info-dialog-exit {
animation: cms-info-dialog-out 180ms ease-in both;
}
/* Sits above the backdrop button inside the pointer-transparent layer. */
.cms-info-dialog-layer {
pointer-events: auto;
position: relative;
z-index: 1;
}
.cms-info-dialog {
position: relative;
@@ -1573,8 +1728,10 @@ a.content-card {
top: 0.75rem;
right: 0.75rem;
display: grid;
width: 2rem;
height: 2rem;
/* 44px touch target (was 2rem/32px) while keeping the circular button visually
the same weight via its border and glyph. */
width: 2.75rem;
height: 2.75rem;
place-items: center;
border: 1px solid
color-mix(
+6
View File
@@ -82,6 +82,12 @@ export default async function RootLayout({
>
<head>
<meta name="theme-default-dark" content={String(defaultDark)} />
{/* Scroll-revealed content starts transparent and is only shown by a
client-side animation. Without JavaScript that animation never
runs, so force it visible instead of leaving the page blank. */}
<noscript>
<style>{".motion-reveal{opacity:1 !important}"}</style>
</noscript>
<Script
src="/scripts/theme-init.js"
strategy="beforeInteractive"