Skip to content

Commit 51d85e9

Browse files
authored
fix collection size (#3723)
* fix collection size * fix height * slice string * add description to collection details * add cols * edit slice length * remove log
1 parent d854b67 commit 51d85e9

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

packages/grant-explorer/src/features/collections/CollectionCard.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ export type CollectionCardProps = {
1111
const CollectionCard = ({ collection, size }: CollectionCardProps) => {
1212
const { cid, name, description } = collection;
1313

14+
const sliceLength = size === "small" ? 165 : 385;
15+
16+
let desc = description;
17+
if (description && description.length > sliceLength) {
18+
desc = description.slice(0, sliceLength) + "...";
19+
}
20+
1421
return (
15-
<BasicCard className="w-full">
22+
<BasicCard className="w-full h-[246px]">
1623
<a
1724
href={collectionPath(cid!)}
1825
data-track-event={`home-collections-card-${size}`}
@@ -21,12 +28,8 @@ const CollectionCard = ({ collection, size }: CollectionCardProps) => {
2128
<CollectionBanner />
2229
</CardHeader>
2330
<div className="p-4 space-y-1">
24-
<div className="font-medium truncate text-xl">
25-
{name}
26-
</div>
27-
<p className="text-grey-400 text-sm">
28-
{description}
29-
</p>
31+
<div className="font-medium truncate text-xl">{name}</div>
32+
<p className="text-grey-400 text-sm">{desc}</p>
3033
</div>
3134
</a>
3235
</BasicCard>

packages/grant-explorer/src/features/collections/CollectionDetails.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CheckIcon, LinkIcon } from "@heroicons/react/20/solid";
33
import { ShoppingCartIcon } from "@heroicons/react/24/outline";
44
import { useState } from "react";
55
import { CollectionV1 } from "./collections";
6+
import { useCollections } from "./hooks/useCollections";
67

78
type Props = {
89
collection: CollectionV1;
@@ -17,17 +18,21 @@ export function CollectionDetails({
1718
projectsInView,
1819
onAddAllApplicationsToCart,
1920
}: Props) {
21+
const collections = useCollections();
22+
23+
// filter collections by collection.href
24+
const description = collections.data?.find(
25+
(c) => c.cid && location.href.includes(c.cid)
26+
)?.description;
27+
2028
return (
2129
<div className="mt-16">
22-
<h3 className="text-4xl font-medium mb-2">{`${
23-
collection.name ?? defaultCollectionName
24-
} (${projectsInView})`}</h3>
25-
<div className="flex">
26-
<div className="text-lg flex-1 whitespace-pre-wrap">
27-
{collection.description}
28-
</div>
29-
<div className="w-96">
30-
<div className="flex justify-end gap-2">
30+
<div className="grid grid-cols-1 md:grid-cols-4 gap-12">
31+
<div className="col-span-1 md:col-span-4 flex flex-col md:flex-row justify-between items-start md:items-center">
32+
<h3 className="text-4xl font-medium">
33+
{`${collection.name ?? defaultCollectionName} (${projectsInView})`}
34+
</h3>
35+
<div className="flex gap-2 mt-4 md:mt-0">
3136
<ShareButton url={location.href} />
3237
<AddToCartButton
3338
current={projectsInView}
@@ -36,6 +41,9 @@ export function CollectionDetails({
3641
/>
3742
</div>
3843
</div>
44+
<div className="col-span-1 md:col-span-3 text-lg flex-1 whitespace-pre-wrap">
45+
{description ?? collection.description}
46+
</div>
3947
</div>
4048
</div>
4149
);

packages/grant-explorer/src/features/discovery/CardBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function CollectionBanner() {
117117
const [gradient] = useState<string[]>(getRandomGradient());
118118
return (
119119
<div
120-
className="h-[70px]"
120+
className="h-[104px]"
121121
style={{
122122
background: `linear-gradient(180deg, #${gradient[0]} 0%, #${gradient[1]} 100%)`,
123123
}}

0 commit comments

Comments
 (0)