Tidy the site's problem pages and typeset math in explanations
The problem page's Explain and recording-review forms took most of the first screen, above the solution. They now fold into the admin bar with the editor, one open at a time; a running job is reported in the bar, so a form can be closed while it works. The problem list is grouped by month when sorted by recency, as one card per month with divided rows, laid out on a fixed grid so rows line up on a phone. Empty status tabs are hidden. Rust solutions are now highlighted, the file picker is styled like the other buttons, header links no longer break mid-word on a phone, and keyboard focus is visible. Markdown everywhere now goes through one renderer that typesets $...$, $$...$$ and ```math with KaTeX. The explanation prompt asked for $...$ only when the statement used it, so formulas came out as inline code; it now asks for LaTeX for math and code spans for code, and the review prompt does the same for complexities. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -49,8 +49,9 @@ const counts = computed(() => {
|
||||
return c;
|
||||
});
|
||||
|
||||
// An empty tab is left out unless it is the one selected (a linked view).
|
||||
const tabs = computed(() =>
|
||||
admin.value ? ["all", "solving", "solved", "skipped"] : [],
|
||||
admin.value ? ["all", "solving", "solved", "skipped"].filter((t) => counts.value[t] || status.value === t) : [],
|
||||
);
|
||||
|
||||
// When a problem was last worked on, for sorting: the solve date if it has
|
||||
@@ -67,6 +68,22 @@ const shown = computed(() => {
|
||||
if (sort.value === "name") return list.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return list.sort((a, b) => when(b).localeCompare(when(a)) || a.name.localeCompare(b.name));
|
||||
});
|
||||
|
||||
// Most recent is split by month, so a long list has landmarks; by name it
|
||||
// is one block. An undated problem sorts last, under "Undated".
|
||||
const groups = computed(() => {
|
||||
if (sort.value === "name") return [{ key: "all", label: "", items: shown.value }];
|
||||
const out = [];
|
||||
for (const p of shown.value) {
|
||||
const w = when(p);
|
||||
const key = w ? w.slice(0, 7) : "none";
|
||||
if (out.at(-1)?.key !== key) {
|
||||
out.push({ key, label: w ? formatDate(w, { month: "long", year: "numeric" }) : "Undated", items: [] });
|
||||
}
|
||||
out.at(-1).items.push(p);
|
||||
}
|
||||
return out;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -99,26 +116,34 @@ const shown = computed(() => {
|
||||
<p v-else-if="error" class="error">{{ error }}</p>
|
||||
<p v-else-if="!shown.length" class="muted">Nothing matches.</p>
|
||||
|
||||
<ul v-else class="list">
|
||||
<li v-for="p in shown" :key="p.name">
|
||||
<RouterLink :to="{ name: 'problem', params: { name: p.name } }" class="row card">
|
||||
<div class="main">
|
||||
<span class="name">{{ title(p.name) }}</span>
|
||||
<span class="meta muted">
|
||||
<template v-if="p.langs.length">{{ p.langs.map((l) => LANG_LABELS[l] || l).join(", ") }}</template>
|
||||
<template v-if="p.tests"> · {{ p.tests }} test{{ p.tests === 1 ? "" : "s" }}</template>
|
||||
<template v-if="p.hasNotes"> · notes</template>
|
||||
<template v-if="p.reviewCount"> · {{ p.reviewCount }} review{{ p.reviewCount === 1 ? "" : "s" }}</template>
|
||||
</span>
|
||||
</div>
|
||||
<div class="side">
|
||||
<span v-if="p.source" class="badge">{{ p.source }}</span>
|
||||
<span v-if="admin || p.status !== 'solved'" class="badge" :class="p.status">{{ STATUS_LABELS[p.status] }}</span>
|
||||
<time v-if="when(p)" class="muted" :datetime="when(p)">{{ formatDate(when(p)) }}</time>
|
||||
</div>
|
||||
</RouterLink>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else class="groups">
|
||||
<section v-for="g in groups" :key="g.key">
|
||||
<h2 v-if="g.label" class="month">{{ g.label }} <span class="n">{{ g.items.length }}</span></h2>
|
||||
<ul class="list card">
|
||||
<li v-for="p in g.items" :key="p.name">
|
||||
<RouterLink :to="{ name: 'problem', params: { name: p.name } }" class="row">
|
||||
<span class="name">{{ title(p.name) }}</span>
|
||||
<span class="sub">
|
||||
<span class="meta muted">
|
||||
<template v-if="p.langs.length">{{ p.langs.map((l) => LANG_LABELS[l] || l).join(", ") }}</template>
|
||||
<template v-if="p.tests"> · {{ p.tests }} test{{ p.tests === 1 ? "" : "s" }}</template>
|
||||
<template v-if="p.hasNotes"> · notes</template>
|
||||
<template v-if="p.hasExplanation"> · explained</template>
|
||||
<template v-if="p.reviewCount"> · {{ p.reviewCount }} review{{ p.reviewCount === 1 ? "" : "s" }}</template>
|
||||
</span>
|
||||
<span class="tags">
|
||||
<span v-if="p.source" class="badge">{{ p.source }}</span>
|
||||
<span v-if="admin || p.status !== 'solved'" class="badge" :class="p.status">{{ STATUS_LABELS[p.status] }}</span>
|
||||
</span>
|
||||
</span>
|
||||
<time v-if="when(p)" class="muted" :class="{ full: !g.label }" :datetime="when(p)">
|
||||
{{ g.label ? formatDate(when(p), { day: "numeric", month: "short" }) : formatDate(when(p)) }}
|
||||
</time>
|
||||
</RouterLink>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -167,42 +192,96 @@ input {
|
||||
flex: 1 1 200px;
|
||||
max-width: 320px;
|
||||
}
|
||||
.list {
|
||||
.groups {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
gap: 20px;
|
||||
}
|
||||
.month {
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.month .n {
|
||||
font-family: var(--font-body);
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-ink-faint);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.list > li + li {
|
||||
border-top: 1px solid var(--color-line-soft);
|
||||
}
|
||||
/* Name and date on the first line, details and badges on the second, at
|
||||
every width, so rows line up instead of wrapping each its own way. On a
|
||||
phone the second line is one flex row, so the badges don't widen the date
|
||||
column and squeeze the name. */
|
||||
.row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
grid-template-areas:
|
||||
"name date"
|
||||
"sub sub";
|
||||
align-items: center;
|
||||
gap: 8px 16px;
|
||||
padding: 12px 16px;
|
||||
gap: 2px 16px;
|
||||
padding: 10px 16px;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
.row:hover {
|
||||
border-color: var(--color-ink-faint);
|
||||
background: var(--color-paper-tint);
|
||||
}
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
li:first-child .row {
|
||||
border-radius: 6px 6px 0 0;
|
||||
}
|
||||
li:last-child .row {
|
||||
border-radius: 0 0 6px 6px;
|
||||
}
|
||||
.name {
|
||||
grid-area: name;
|
||||
font-size: 1.05rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.sub {
|
||||
grid-area: sub;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 4px 12px;
|
||||
}
|
||||
.meta {
|
||||
grid-area: meta;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.side {
|
||||
.tags {
|
||||
grid-area: tags;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.85rem;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
}
|
||||
time {
|
||||
min-width: 7.5em;
|
||||
grid-area: date;
|
||||
font-size: 0.85rem;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Fixed widths, so the dates line up down a card. */
|
||||
@media (min-width: 640px) {
|
||||
time {
|
||||
min-width: 4em;
|
||||
}
|
||||
time.full {
|
||||
min-width: 6.5em;
|
||||
}
|
||||
}
|
||||
/* Wide enough for one line: badges and date in columns of their own. */
|
||||
@media (min-width: 640px) {
|
||||
.row {
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
grid-template-areas:
|
||||
"name tags date"
|
||||
"meta tags date";
|
||||
}
|
||||
.sub {
|
||||
display: contents;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user