Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/elements/tag-selector.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
gap: 0.375rem;
}

// The advanced selector's equivalent of `.groupTags`, and deliberately the same
// gap. Without it the buttons are inline-flex boxes in a plain block, and JSX
// drops the whitespace between them, so a whole category renders as one
// unbroken strip of touching pills.
.advancedTags {
display: flex;
flex-flow: row wrap;
gap: 0.375rem;
}

.tagButton {
font: inherit;
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion src/elements/tag-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function AdvancedTagSelector({ selection, onChange, context = 'models' }: TagSel
return (
<React.Fragment key={categoryId}>
<h4>{category.name}</h4>
<div>
<div className={style.advancedTags}>
{category.tags.map((tagId) => {
const tag = tagData.get(tagId);
const state = getState(tagId, selection);
Expand Down
38 changes: 22 additions & 16 deletions src/pages/datasets/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ function PageContent({ datasetId, staticDatasetData }: Props) {

const dataset = datasetData.get(realDatasetId);

const { webApi, editMode } = useWebApi(IS_DEPLOYED);
// No override argument. `useWebApi`'s parameter means "allow editing even
// though we're deployed", so passing `IS_DEPLOYED` — as this did — made
// being deployed the one condition that switched edit mode on.
const { webApi, editMode } = useWebApi();
const { updateDatasetProperty } = useUpdateDataset(webApi, realDatasetId);

const authors = useMemo(() => {
Expand Down Expand Up @@ -166,15 +169,17 @@ function PageContent({ datasetId, staticDatasetData }: Props) {

if (!dataset) {
return (
<div className="flex flex-col items-center justify-center py-20">
<h2 className="text-2xl font-bold">Dataset not found</h2>
<Link
className="mt-4 text-accent-600 hover:underline"
href="/datasets"
>
Back to datasets
</Link>
</div>
<PageContainer>
<div className="flex flex-col items-center justify-center py-20">
<h2 className="text-2xl font-bold">Dataset not found</h2>
<Link
className="mt-4 text-accent-600 hover:underline"
href="/datasets"
>
Back to datasets
</Link>
</div>
</PageContainer>
);
}

Expand Down Expand Up @@ -383,14 +388,15 @@ function PageContent({ datasetId, staticDatasetData }: Props) {
);
}

// `PageContent` renders its own `PageContainer` — including the not-found
// branch — so this must not wrap it in a second one. The container is the whole
// page shell: header, site notice and footer. Nesting rendered all three twice.
export default function Page({ datasetId, staticDatasetData }: Props) {
return (
<PageContainer wrapper>
<PageContent
datasetId={datasetId}
staticDatasetData={staticDatasetData}
/>
</PageContainer>
<PageContent
datasetId={datasetId}
staticDatasetData={staticDatasetData}
/>
);
}

Expand Down
94 changes: 56 additions & 38 deletions src/pages/models/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ import {
} from '../../lib/util';
import { validateModel } from '../../lib/validate-model';

const MAX_SIMILAR_MODELS = 12 * 2;
// One full row. The card grid is `auto-fill minmax(280px, 1fr)`, which lands on
// four columns at full page width, so four suggestions fill the strip across the
// bottom without leaving a ragged second row.
const MAX_SIMILAR_MODELS = 4;

interface Params extends ParsedUrlQuery {
id: ModelId;
Expand Down Expand Up @@ -407,6 +410,8 @@ export default function Page({
return [...collectionData].filter(([, collection]) => collection.models.includes(modelId)).map(([id]) => id);
}, [modelId, collectionData]);

const hasRelated = collections.length > 0 || similar.length > 0;

const router = useRouter();

const runModelValidation = useCallback(async () => {
Expand Down Expand Up @@ -646,44 +651,14 @@ export default function Page({

<RelatedGuides />
</div>

{/* Related models live in this column so it always has
body: most descriptions are short, and the sidebar is
long, which otherwise left a tall void beside it. */}
{collections.length > 0 && (
<div className="mt-6">
<h2 className="mt-0 mb-4 text-xl font-bold tracking-tight text-ink">
Collections that include this model
</h2>
<ModelCardGrid
collectionData={collectionData}
modelData={modelData}
models={collections}
/>
</div>
)}

{similar.length > 0 && (
<div className="mt-6">
<h2 className="mt-0 mb-4 text-xl font-bold tracking-tight text-ink">Similar models</h2>
{editMode && similarWithScores.length > 0 && (
<details>
<summary>Show scores</summary>{' '}
<pre className="overflow-auto">
{similarWithScores
.map(({ id, score }) => `${score.toFixed(2).padEnd(6)} ${id}`)
.join('\n')}
</pre>
</details>
)}
<ModelCardGrid
modelData={modelData}
models={similar}
/>
</div>
)}
</div>
{/* Right column: Sidebar */}

{/* Sidebar. Deliberately the second grid child rather than
the last: below `lg` the grid collapses to one column and
renders in DOM order, so anything after this would push
downloads and specs below it. The related-model grids
used to live in the column above, which put two full
card grids ahead of the model's own details on a phone. */}
<div className="col-span-1 flex w-full flex-col gap-5">
<DownloadsBlock
editMode={editMode}
Expand Down Expand Up @@ -739,6 +714,49 @@ export default function Page({
/>
</div>
</div>

{/* A full-width strip under both columns rather than more
body for the description column, so the card grids get
the whole page width and read as a footer to the page
instead of a continuation of the article. */}
{hasRelated && (
<div className="col-span-1 flex flex-col gap-6 lg:col-span-3">
{collections.length > 0 && (
<div>
<h2 className="mt-0 mb-4 text-xl font-bold tracking-tight text-ink">
Collections that include this model
</h2>
<ModelCardGrid
collectionData={collectionData}
modelData={modelData}
models={collections}
/>
</div>
)}

{similar.length > 0 && (
<div>
<h2 className="mt-0 mb-4 text-xl font-bold tracking-tight text-ink">
Similar models
</h2>
{editMode && similarWithScores.length > 0 && (
<details>
<summary>Show scores</summary>{' '}
<pre className="overflow-auto">
{similarWithScores
.map(({ id, score }) => `${score.toFixed(2).padEnd(6)} ${id}`)
.join('\n')}
</pre>
</details>
)}
<ModelCardGrid
modelData={modelData}
models={similar}
/>
</div>
)}
</div>
)}
</div>
{editMode && (
<div>
Expand Down
Loading
Loading