-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from SatyaRajAwasth1/card-view-layout
feature: Adds a card layout for viewing alumni info in card layout where required & implements on profile highlight and profiles page
- Loading branch information
Showing
7 changed files
with
125 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
import { AlumniProfileInfo } from '../utils/types'; | ||
const { name, program, batch, image, slogan, tags, history, slug } = Astro.props as AlumniProfileInfo; | ||
--- | ||
|
||
<div class="bg-gray-800 rounded-lg shadow-lg p-6 hover:shadow-xl transition-shadow duration-300"> | ||
{image?.url ? ( | ||
<img | ||
src={image.url} | ||
alt={`Profile picture of ${name}`} | ||
class="w-full h-48 object-cover rounded-t-lg" | ||
/> | ||
) : ( | ||
<div class="w-full h-48 bg-gray-700 rounded-t-lg flex items-center justify-center"> | ||
<span class="text-gray-400">No Image Available</span> | ||
</div> | ||
)} | ||
<div class="pt-4 text-center"> | ||
<h3 class="text-xl font-semibold">{name}</h3> | ||
<span class="text-sm"> | ||
{program}, Class of {batch} | ||
</span> | ||
{slogan && <p class="text-gray-400 italic">{slogan}</p>} | ||
<div class="flex space-x-2 mt-4 "> | ||
{tags.map((tag, index) => ( | ||
<span | ||
class="bg-blue-200 text-blue-800 text-xs font-semibold px-2 py-1 rounded" | ||
> | ||
{tag} | ||
</span> | ||
))} | ||
</div> | ||
<div class="mt-4 text-left"> | ||
<ul class="text-sm"> | ||
{history.map((item) => ( | ||
<li> | ||
<strong>{item.year}:</strong> {item.position} at {item.company} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
<div class="mt-6 text-center"> | ||
<a | ||
href={`/profiles/${slug}`} | ||
class="text-blue-500 hover:underline" | ||
> | ||
See More | ||
</a> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
--- | ||
import { getCollection } from "astro:content"; | ||
import TwoColLayout from "../../layout/TwoColLayout.astro"; | ||
import ProfileCard from '../../layout/AlumniCardLayout.astro'; | ||
const allProfiles = await getCollection('profiles'); | ||
// A map to hold data in map with year/batch as key and set of profiles in alphabetical order as value | ||
const batchMap = allProfiles.reduce((map, profile) => { | ||
const batch = profile.data.batch; | ||
if (!map.has(batch)) { | ||
map.set(batch, new Set()); | ||
} | ||
map.get(batch).add(profile); | ||
return map; | ||
}, new Map()); | ||
// Convert each set to an array and sort by name | ||
for (const [batch, profilesSet] of batchMap.entries()) { | ||
const profilesArray = Array.from(profilesSet); | ||
profilesArray.sort((a, b) => a.data.name.localeCompare(b.data.name)); | ||
// Replace the set with the sorted array in the map | ||
batchMap.set(batch, profilesArray); | ||
} | ||
// Create an array of sorted years/batches | ||
const sortedYears = Array.from(batchMap.keys()).sort(); | ||
--- | ||
|
||
<TwoColLayout> | ||
Featured Profiles go here | ||
</TwoColLayout> | ||
{sortedYears.map((year) => { | ||
let showAll = false; | ||
|
||
return ( | ||
<div class="mb-8"> | ||
<h3 class="text-lg font-bold flex items-center justify-between"> | ||
{year} Batch | ||
</h3> | ||
<div class="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mt-4 text-white"> | ||
{(showAll ? batchMap.get(year) : batchMap.get(year).slice(0, 3)) | ||
.map((profile) => ( | ||
<ProfileCard key={profile.slug} slug={profile.slug} {...profile.data} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</TwoColLayout> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface AlumniProfileInfo { | ||
name: string; | ||
program: string; | ||
batch: string; | ||
image?: { url: string }; | ||
slogan?: string; | ||
tags: string[]; | ||
history: { year: string; position: string; company: string }[]; | ||
slug: string; | ||
} |