Skip to content

Commit 118cb69

Browse files
committed
2 parents 4944daa + bccc546 commit 118cb69

File tree

2 files changed

+34
-56
lines changed

2 files changed

+34
-56
lines changed

src/app/projects/components/ProjectCard.tsx

Lines changed: 29 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ export default function ProjectCard({
2626
stars,
2727
tags,
2828
}: Props) {
29-
const [showAllTags, setShowAllTags] = useState(false);
3029
const [expandDescription, setExpandDescription] = useState(false);
3130

3231
return (
33-
<div className='border-2 p-8 transition-[box-shadow] shadow-none hover:shadow-xl bg-slate-50/70 max-w-full h-64 flex flex-col relative'>
32+
<div className='border-2 p-6 transition-[box-shadow] shadow-none hover:shadow-xl bg-slate-50/70 max-w-full h-64 flex flex-col relative'>
3433
{/* Top content section */}
3534
<div className='flex-1 flex flex-col overflow-hidden'>
3635
<div className='flex justify-between items-start mb-3'>
37-
<h3 className='font-bold text-lg tracking-widest text-mindfire-text-black capitalize truncate pr-2'>
36+
<h3 className='font-bold text-lg tracking-widest text-mindfire-text-black capitalize pr-2'>
3837
{title}
3938
</h3>
4039
{parentTitle !== "Upcoming Projects" && stars !== undefined && (
@@ -45,71 +44,46 @@ export default function ProjectCard({
4544
)}
4645
</div>
4746

48-
{/*Description that expands on click */}
47+
{/* Description section with fixed height */}
4948
<div
5049
className={`mb-3 relative cursor-pointer ${
5150
expandDescription ? "max-h-[72px] overflow-y-auto" : ""
5251
}`}
53-
onClick={() => setExpandDescription(!expandDescription)}
52+
onClick={() => {
53+
if (shortDescription.length > 120)
54+
setExpandDescription(!expandDescription);
55+
}}
56+
style={{
57+
minHeight: expandDescription ? "auto" : "4.1rem",
58+
}}
5459
>
5560
<p
5661
className={`text-mf-dark tracking-wide leading-6 ${
57-
expandDescription ? "" : "line-clamp-3"
62+
expandDescription ? "" : "line-clamp-2"
5863
}`}
5964
>
6065
{shortDescription}
6166
</p>
62-
{expandDescription && (
63-
<span className='text-xs text-blue-500 mt-1 block'>less</span>
67+
68+
{/* Only show toggle if the content is long */}
69+
{shortDescription.length > 120 && (
70+
<span className='text-xs text-blue-500 mt-1 block'>
71+
{expandDescription ? "less" : "more"}
72+
</span>
6473
)}
6574
</div>
6675

6776
{parentTitle !== "Upcoming Projects" && tags && tags.length > 0 && (
68-
<div className='mb-2'>
69-
<div
70-
className={`flex gap-2 max-w-full ${
71-
showAllTags ? "overflow-x-auto pb-2" : "overflow-hidden"
72-
}`}
73-
>
74-
{showAllTags
75-
? tags.map((tag, index) => (
76-
<span
77-
key={index}
78-
className='px-2 py-1 text-xs bg-gray-100 text-gray-600 rounded-full border border-red-500 truncate flex-shrink-0'
79-
>
80-
{tag}
81-
</span>
82-
))
83-
: tags.slice(0, 2).map((tag, index) => (
84-
<span
85-
key={index}
86-
className='px-2 py-1 text-xs bg-gray-100 text-gray-600 rounded-full border border-red-500 truncate max-w-[100px]'
87-
>
88-
{tag}
89-
</span>
90-
))}
91-
{!showAllTags && tags.length > 2 && (
92-
<button
93-
onClick={(e) => {
94-
e.stopPropagation();
95-
setShowAllTags(true);
96-
}}
97-
className='px-2 py-1 text-xs bg-gray-100 text-gray-600 rounded-full hover:bg-gray-200 cursor-pointer'
98-
>
99-
+{tags.length - 2} more
100-
</button>
101-
)}
102-
{showAllTags && (
103-
<button
104-
onClick={(e) => {
105-
e.stopPropagation();
106-
setShowAllTags(false);
107-
}}
108-
className='px-2 py-1 text-xs bg-gray-100 text-gray-600 rounded-full hover:bg-gray-200 cursor-pointer flex-shrink-0'
77+
<div className='mt-1'>
78+
<div className={`flex gap-2 max-w-full overflow-x-auto pb-2' `}>
79+
{tags.map((tag, index) => (
80+
<span
81+
key={index}
82+
className='px-2 py-1 text-xs bg-gray-100 text-gray-600 rounded-full border border-red-500 truncate flex-shrink-0'
10983
>
110-
Show less
111-
</button>
112-
)}
84+
{tag}
85+
</span>
86+
))}
11387
</div>
11488
</div>
11589
)}
@@ -119,9 +93,9 @@ export default function ProjectCard({
11993
{parentTitle !== "Upcoming Projects" &&
12094
(githubUrl || documentationUrl) &&
12195
(githubUrl !== "NA" || documentationUrl !== "NA") && (
122-
<div className='absolute bottom-0 left-0 right-0 mx-8'>
123-
<div className='border-t-2 my-2'></div>
124-
<div className='flex gap-4 justify-center my-2'>
96+
<div className='mt-2'>
97+
<div className='border-t-2'></div>
98+
<div className='flex gap-4 justify-center mt-2'>
12599
{githubUrl && githubUrl !== "NA" && (
126100
<Link
127101
href={githubUrl}

src/app/projects/components/ProjectGrid.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ interface Props {
2222
}
2323

2424
export default function ProjectGrid({ title, projectData }: Props) {
25+
const sortedProjects = [...projectData].sort(
26+
(a, b) => (b.stars ?? 0) - (a.stars ?? 0)
27+
);
28+
2529
return (
2630
<section className='mt-20' id='all-projects'>
2731
<div className='flex justify-center items-center gap-4'>
@@ -31,7 +35,7 @@ export default function ProjectGrid({ title, projectData }: Props) {
3135
<ProjectCount totalProjects={projectData.length} />
3236
</div>
3337
<div className='mt-12 px-4 grid gap-6 max-w-6xl mx-auto md:grid-cols-2 lg:grid-cols-3'>
34-
{projectData.map(
38+
{sortedProjects.map(
3539
(
3640
{
3741
title: projectTitle,

0 commit comments

Comments
 (0)