Skip to content

Commit 6bc3392

Browse files
committed
Make catalog page accomodate longer package names
1 parent 8556f1d commit 6bc3392

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/app/[...parts]/_page/catalog/CatalogPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function CatalogPageInner({ specs }: CatalogPageProps) {
3737

3838
return (
3939
<div className="mx-auto w-full max-w-7xl py-8">
40-
<div className="grid grid-cols-1 gap-8 lg:grid-cols-2">
40+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-[2fr,3fr]">
4141
<div className="flex flex-col">
4242
<PackageMeta packument={pack} />
4343
</div>
@@ -55,7 +55,7 @@ async function CatalogPageInner({ specs }: CatalogPageProps) {
5555
function CatalogPageFallback() {
5656
return (
5757
<div className="mx-auto w-full max-w-7xl py-8">
58-
<div className="grid grid-cols-1 gap-8 lg:grid-cols-2">
58+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-[2fr,3fr]">
5959
<div className="flex flex-col">
6060
<Skeleton className="h-96 w-full rounded-md" />
6161
</div>

src/app/[...parts]/_page/catalog/ComparisonList.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ function getHighlightIndex(type: "major" | "minor" | "patch"): number {
2626
}
2727
}
2828

29+
/**
30+
* Threshold for omitting the package name in the "to" spec
31+
* When package name is 24+ characters, we show "pkg@1.0.0...2.0.0" instead of "pkg@1.0.0...pkg@2.0.0"
32+
*/
33+
const PACKAGE_NAME_LENGTH_THRESHOLD = 24;
34+
2935
/**
3036
* Right column showing the list of comparisons
3137
*/
3238
export default function ComparisonList({
3339
packageName,
3440
comparisons,
3541
}: ComparisonListProps) {
42+
const showSecondPackageName =
43+
packageName.length < PACKAGE_NAME_LENGTH_THRESHOLD;
44+
3645
if (comparisons.length === 0) {
3746
return (
3847
<BorderBox>
@@ -73,7 +82,11 @@ export default function ComparisonList({
7382
<span className="text-muted-foreground">
7483
...
7584
</span>
76-
<PackageNamePrefix packageName={packageName} />
85+
{showSecondPackageName ? (
86+
<PackageNamePrefix
87+
packageName={packageName}
88+
/>
89+
) : null}
7790
<VersionWithHighlight
7891
version={comparison.to}
7992
highlightIndex={highlightIndex}

0 commit comments

Comments
 (0)